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

Suppress task definition diffs for equivalent port mappings. #5833

Merged
merged 1 commit into from
Sep 11, 2018

Conversation

jmcarp
Copy link
Contributor

@jmcarp jmcarp commented Sep 11, 2018

When using the awsvpc networking mode, aws assigns the value of
containerPort to the hostPort for each item in portMappings. This
leads to spurious diffs if the user doesn't set hostPort. This patch
suppresses diffs when using awsvpc networking and the hostPort field
is unset.

[Fixes #3401]

$ make testacc TESTARGS='-run=TestAccAWSAvailabilityZones'
?       github.com/terraform-providers/terraform-provider-aws   [no test files]
=== RUN   TestAccAWSEcsTaskDefinition_basic
--- PASS: TestAccAWSEcsTaskDefinition_basic (10.81s)
=== RUN   TestAccAWSEcsTaskDefinition_withScratchVolume
--- PASS: TestAccAWSEcsTaskDefinition_withScratchVolume (5.30s)
=== RUN   TestAccAWSEcsTaskDefinition_withEcsService
--- PASS: TestAccAWSEcsTaskDefinition_withEcsService (47.95s)
=== RUN   TestAccAWSEcsTaskDefinition_withTaskRoleArn
--- PASS: TestAccAWSEcsTaskDefinition_withTaskRoleArn (8.24s)
=== RUN   TestAccAWSEcsTaskDefinition_withNetworkMode
--- PASS: TestAccAWSEcsTaskDefinition_withNetworkMode (6.14s)
=== RUN   TestAccAWSEcsTaskDefinition_constraint
--- PASS: TestAccAWSEcsTaskDefinition_constraint (5.36s)
=== RUN   TestAccAWSEcsTaskDefinition_changeVolumesForcesNewResource
--- PASS: TestAccAWSEcsTaskDefinition_changeVolumesForcesNewResource (10.78s)
=== RUN   TestAccAWSEcsTaskDefinition_arrays
--- PASS: TestAccAWSEcsTaskDefinition_arrays (4.83s)
=== RUN   TestAccAWSEcsTaskDefinition_Fargate
--- PASS: TestAccAWSEcsTaskDefinition_Fargate (7.27s)
=== RUN   TestAccAWSEcsTaskDefinition_ExecutionRole
--- PASS: TestAccAWSEcsTaskDefinition_ExecutionRole (6.29s)
=== RUN   TestAccAWSEcsTaskDefinition_Inactive
--- PASS: TestAccAWSEcsTaskDefinition_Inactive (11.15s)
PASS
ok      github.com/terraform-providers/terraform-provider-aws/aws       124.882s
...

When using the `awsvpc` networking mode, aws assigns the value of
`containerPort` to the `hostPort` for each item in `portMappings`. This
leads to spurious diffs if the user doesn't set `hostPort`. This patch
suppresses diffs when using `awsvpc` networking and the `hostPort` field
is unset.

[Fixes hashicorp#3401]
@ghost ghost added the size/M Managed by automation to categorize the size of a PR. label Sep 11, 2018
@bflad bflad added service/ecs Issues and PRs that pertain to the ecs service. enhancement Requests to existing resources that expand the functionality or scope. labels Sep 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.

LGTM and ignoring my testing nitpick. Thanks, @jmcarp 🚀

--- PASS: TestAccAWSEcsTaskDefinition_constraint (4.42s)
--- PASS: TestAccAWSEcsTaskDefinition_arrays (4.61s)
--- PASS: TestAccAWSEcsTaskDefinition_withScratchVolume (4.63s)
--- PASS: TestAccAWSEcsTaskDefinition_Inactive (7.05s)
--- PASS: TestAccAWSEcsTaskDefinition_changeVolumesForcesNewResource (7.11s)
--- PASS: TestAccAWSEcsTaskDefinition_basic (7.51s)
--- PASS: TestAccAWSEcsTaskDefinition_withTaskRoleArn (7.80s)
--- PASS: TestAccAWSEcsTaskDefinition_withNetworkMode (7.80s)
--- PASS: TestAccAWSEcsTaskDefinition_Fargate (11.02s)
--- PASS: TestAccAWSEcsTaskDefinition_ExecutionRole (12.07s)
--- PASS: TestAccAWSEcsTaskDefinition_withEcsService (42.81s)

@@ -649,7 +654,7 @@ TASK_DEFINITION
`, tdName)
}

func testAccAWSEcsTaskDefinitionFargate(tdName string) string {
func testAccAWSEcsTaskDefinitionFargate(tdName, portMappings string) string {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: It'd be much better if this was a separate test and test configuration as it does not pertain to the basic functionality of the resource with Fargate

@bflad bflad added this to the v1.36.0 milestone Sep 11, 2018
@bflad bflad merged commit 0b6a163 into hashicorp:master Sep 11, 2018
bflad added a commit that referenced this pull request Sep 11, 2018
@bflad
Copy link
Contributor

bflad commented Sep 13, 2018

This has been released in version 1.36.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 3, 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 3, 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/ecs Issues and PRs that pertain to the ecs service. 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.

aws_ecs_task_definition needs updating even if nothing changes (look at "portMappings")
2 participants