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

Add ComputePlatform to aws_codedeploy_app #4811

Merged
merged 5 commits into from
Jun 14, 2018
Merged

Add ComputePlatform to aws_codedeploy_app #4811

merged 5 commits into from
Jun 14, 2018

Conversation

cgarvis
Copy link
Contributor

@cgarvis cgarvis commented Jun 11, 2018

Fixes #3692

Changes proposed in this pull request:

  • Add ComputePlatform to CodeDeployApp

Output from acceptance testing:

$ make testacc make testacc TESTARGS='-run=TestAccAWSCodeDeployApp'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./... -v -run=TestAccAWSCodeDeployApp -timeout 120m
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSCodeDeployApp_basic
--- PASS: TestAccAWSCodeDeployApp_basic (24.20s)
=== RUN   TestAccAWSCodeDeployApp_computePlatform
--- PASS: TestAccAWSCodeDeployApp_computePlatform (23.75s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       58.844s
``

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jun 11, 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.

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.

@@ -26,6 +27,16 @@ func resourceAwsCodeDeployApp() *schema.Resource {
ForceNew: true,
},

"compute_platform": &schema.Schema{
Copy link
Contributor

@bflad bflad Jun 12, 2018

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 the d.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 as ForceNew: 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`.
Copy link
Contributor

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,
Copy link
Contributor

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"),

@bflad bflad added enhancement Requests to existing resources that expand the functionality or scope. waiting-response Maintainers are waiting on response from community or contributor. labels Jun 12, 2018
@Jamie-BitFlight
Copy link

Looking forward to this PR :)

@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Jun 14, 2018
@cgarvis
Copy link
Contributor Author

cgarvis commented Jun 14, 2018

@bflad updated per your suggestions. Thanks!. Tests look good.

@bflad bflad removed the waiting-response Maintainers are waiting on response from community or contributor. label Jun 14, 2018
@bflad bflad added this to the v1.24.0 milestone Jun 14, 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.

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{
Copy link
Contributor

Choose a reason for hiding this comment

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

😍

@bflad bflad merged commit 13e67da into hashicorp:master Jun 14, 2018
bflad added a commit that referenced this pull request Jun 14, 2018
@cgarvis cgarvis deleted the codedeploy-compute-platform branch June 14, 2018 15:28
@cgarvis
Copy link
Contributor Author

cgarvis commented Jun 14, 2018

👍

@bflad
Copy link
Contributor

bflad commented Jun 25, 2018

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.

@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. size/M Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CodeDeploy to Lambda
3 participants