-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Conversation
There was a problem hiding this 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, |
There was a problem hiding this comment.
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": { |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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" { |
There was a problem hiding this comment.
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.
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. |
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! |
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