-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
Add ComputePlatform to aws_codedeploy_app #4811
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.
Thanks for submitting this @cgarvis! Its off to a good start -- I left you some feedback below. Please let us know if you have any questions or cannot implement it.
aws/resource_aws_codedeploy_app.go
Outdated
@@ -26,6 +27,16 @@ func resourceAwsCodeDeployApp() *schema.Resource { | |||
ForceNew: true, | |||
}, | |||
|
|||
"compute_platform": &schema.Schema{ |
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.
There are two subtle, but important bugs with this attribute currently. 😄
- The read function is not calling
d.Set("compute_platform", ...)
which has two implications: Terraform cannot detect drift of the attribute and in absence of thed.Set()
call with the value, Terraform core is silently passing the configuration value into the Terraform state (which is why the acceptance testing passes) - This attribute cannot be updated in
UpdateApplication
and therefore needs to be set asForceNew: true
to force new resource creation
One other minor nitpick: (the rest of the file hasn't been updated yet, but) as of Go 1.7, the &schema.Schema
is extraneous as its defined by map[string]*schema.Schema
above so we prefer to remove them now 👍
@@ -23,6 +23,7 @@ resource "aws_codedeploy_app" "foo" { | |||
The following arguments are supported: | |||
|
|||
* `name` - (Required) The name of the application. | |||
* `compute_platform` - (Optional) The compute platform can either be `Server` or `Lambda`. |
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.
We should list the default of Server
here 👍
codedeploy.ComputePlatformServer, | ||
codedeploy.ComputePlatformLambda, | ||
}, false), | ||
Default: codedeploy.ComputePlatformServer, |
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.
We should check the default value in TestAccAWSCodeDeployApp_basic
as well (when not provided in the test configuration):
resource.TestCheckResourceAttr("aws_codedeploy_app.foo", "compute_platform", "Server"),
Looking forward to this PR :) |
@bflad updated per your suggestions. Thanks!. Tests look good. |
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.
Thanks so much for the updates, @cgarvis! This was almost there and sorry I wasn't more clear in my previous comment about the read and setting the new attribute to force resource recreation.
On line 95 in the read function, I added the following, which allows Terraform to use the API response to detect if there is a difference between the Terraform configuration value and the API:
d.Set("compute_platform", resp.Application.ComputePlatform)
When I added this, we (expectedly) now see that trying to update the value of the attribute in the Terraform configuration without ForceNew: true
will cause a perpetual difference as the resource has no way to update it in the API:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSCodeDeployApp'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCodeDeployApp -timeout 120m
=== RUN TestAccAWSCodeDeployApp_basic
--- PASS: TestAccAWSCodeDeployApp_basic (22.56s)
=== RUN TestAccAWSCodeDeployApp_computePlatform
--- FAIL: TestAccAWSCodeDeployApp_computePlatform (17.91s)
testing.go:518: Step 1 error: After applying this step and refreshing, the plan was not empty:
DIFF:
UPDATE: aws_codedeploy_app.foo
compute_platform: "Server" => "Lambda"
STATE:
aws_codedeploy_app.foo:
ID = f55617b3-f5a3-437e-a02f-aec0c200e16b:test-codedeploy-app-et3i6
provider = provider.aws
compute_platform = Server
name = test-codedeploy-app-et3i6
FAIL
FAIL github.com/terraform-providers/terraform-provider-aws/aws 40.513s
Setting the new attribute to ForceNew: true
ensures the testing passes as expected:
make testacc TEST=./aws TESTARGS='-run=TestAccAWSCodeDeployApp'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCodeDeployApp -timeout 120m
=== RUN TestAccAWSCodeDeployApp_basic
--- PASS: TestAccAWSCodeDeployApp_basic (19.65s)
=== RUN TestAccAWSCodeDeployApp_computePlatform
--- PASS: TestAccAWSCodeDeployApp_computePlatform (18.91s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 38.600s
I'll include these two lines in a followup commit to yours. 🚀
@@ -20,14 +21,24 @@ func resourceAwsCodeDeployApp() *schema.Resource { | |||
Delete: resourceAwsCodeDeployAppDelete, | |||
|
|||
Schema: map[string]*schema.Schema{ | |||
"name": &schema.Schema{ |
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.
😍
👍 |
This has been released in version 1.24.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! |
Fixes #3692
Changes proposed in this pull request:
ComputePlatform
toCodeDeployApp
Output from acceptance testing: