Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added badge_enabled argument, exported badge_url parameter #3504

Merged
merged 5 commits into from
May 24, 2018

Conversation

vpadronblanco
Copy link
Contributor

Solves

Resolves my problem with branches, reason why I closed #3297

Testing Output:

==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCodeBuildProject_buildBadgeUrlValidation -timeout 120m
=== RUN TestAccAWSCodeBuildProject_buildBadgeUrlValidation
--- PASS: TestAccAWSCodeBuildProject_buildBadgeUrlValidation (24.83s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 24.868s

@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Feb 23, 2018
@bflad bflad added the service/codebuild Issues and PRs that pertain to the codebuild service. label Feb 24, 2018
@ghost ghost added the size/L Managed by automation to categorize the size of a PR. label Feb 28, 2018
@bflad bflad added the enhancement Requests to existing resources that expand the functionality or scope. label May 24, 2018
@bflad bflad added this to the v1.21.0 milestone May 24, 2018
Copy link
Contributor

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @vpadronblanco 👋 Thanks for submitting this! Sorry for the lengthy delay in getting it reviewed. I have left some comments below which I will fix up on merge in a commit after yours (including rebasing against master). We'll get this out there in v1.21.0 of the AWS provider, likely to release middle of next week.

"badge_url": {
Type: schema.TypeString,
Computed: true,
Optional: true,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we cannot set the badge URL via the API, Optional: true should be removed from this attribute. More information: https://www.terraform.io/docs/extend/schemas/schema-behaviors.html#optional

@@ -180,6 +180,16 @@ func resourceAwsCodeBuildProject() *schema.Resource {
Default: "60",
ValidateFunc: validateAwsCodeBuildTimeout,
},
"badge_enabled": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order for Terraform to determine that this parameter has changed from the API, we need to call d.Set("badge_enabled", project.Badge.BadgeEnabled) in the read function.

@@ -451,6 +465,7 @@ func resourceAwsCodeBuildProjectRead(d *schema.ResourceData, meta interface{}) e
d.Set("name", project.Name)
d.Set("service_role", project.ServiceRole)
d.Set("build_timeout", project.TimeoutInMinutes)
d.Set("badge_url", project.Badge.BadgeRequestUrl)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to prevent potential nil dereference panic, we need to wrap these in a nil check:

if project.Badge != nil {
  d.Set("badge_enabled", project.Badge.BadgeEnabled)
  d.Set("badge_url", project.Badge.BadgeRequestUrl)
} else {
  d.Set("badge_enabled", false)
  d.Set("badge_url", "")
}

POLICY
}

resource "aws_iam_policy_attachment" "codebuild_policy_attachment" {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor nitpick: We generally discourage the usage of aws_iam_policy_attachment in preference of aws_iam_role_policy_attachment in this case as the former resource often provides confusing/unexpected behavior for operators if they are unfamiliar with all the caveats of using that resource.

@bflad bflad merged commit a010065 into hashicorp:master May 24, 2018
bflad added a commit that referenced this pull request May 24, 2018
@bflad
Copy link
Contributor

bflad commented May 31, 2018

This has been released in version 1.21.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Requests to existing resources that expand the functionality or scope. service/codebuild Issues and PRs that pertain to the codebuild service. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants