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

r/aws_ecs_task_definition: Provider produced inconsistent final plan for container_definitions after v5.59.0 #38471

Merged
merged 10 commits into from
Jul 23, 2024

Conversation

ewbankkit
Copy link
Contributor

@ewbankkit ewbankkit commented Jul 22, 2024

Description

The root cause was a change in the behavior of the container_definitions attribute's StateFunc when the value is unknown, for example during terraform plan when the attribute's value refers to attributes of other to-be-created resources.

For v5.58.0 the returned value in such cases was [] (an empty array):

2024-07-23T14:34:21.637-0400 [INFO]  provider.terraform-provider-aws: [INFO] container_definitions.StateFunc: v: 74D93920-ED26-11E3-AC10-0800200C9A66, err: decoding JSON: invalid character 'D' after top-level value
2024-07-23T14:34:21.637-0400 [INFO]  provider.terraform-provider-aws: [INFO] container_definitions.StateFunc: json: []

For v5.59.0 the returned value in such cases was null:

2024-07-23T14:27:48.905-0400 [INFO]  provider.terraform-provider-aws: [INFO] container_definitions.StateFunc: v: 74D93920-ED26-11E3-AC10-0800200C9A66, err: json: cannot unmarshal number into Go value of type []types.ContainerDefinition
2024-07-23T14:27:48.905-0400 [INFO]  provider.terraform-provider-aws: [INFO] container_definitions.StateFunc: json: null

Relations

Closes #38461.
Closes #38466.

Output from Acceptance Testing

% make testacc TESTARGS='-run=TestAccECSTaskDefinition_' PKG=ecs ACCTEST_PARALLELISM=3
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.5 test ./internal/service/ecs/... -v -count 1 -parallel 3  -run=TestAccECSTaskDefinition_ -timeout 360m
=== RUN   TestAccECSTaskDefinition_basic
=== PAUSE TestAccECSTaskDefinition_basic
=== RUN   TestAccECSTaskDefinition_scratchVolume
=== PAUSE TestAccECSTaskDefinition_scratchVolume
=== RUN   TestAccECSTaskDefinition_configuredAtLaunch
=== PAUSE TestAccECSTaskDefinition_configuredAtLaunch
=== RUN   TestAccECSTaskDefinition_DockerVolume_basic
=== PAUSE TestAccECSTaskDefinition_DockerVolume_basic
=== RUN   TestAccECSTaskDefinition_DockerVolume_minimal
=== PAUSE TestAccECSTaskDefinition_DockerVolume_minimal
=== RUN   TestAccECSTaskDefinition_runtimePlatform
=== PAUSE TestAccECSTaskDefinition_runtimePlatform
=== RUN   TestAccECSTaskDefinition_Fargate_runtimePlatform
=== PAUSE TestAccECSTaskDefinition_Fargate_runtimePlatform
=== RUN   TestAccECSTaskDefinition_Fargate_runtimePlatformWithoutArch
=== PAUSE TestAccECSTaskDefinition_Fargate_runtimePlatformWithoutArch
=== RUN   TestAccECSTaskDefinition_EFSVolume_minimal
=== PAUSE TestAccECSTaskDefinition_EFSVolume_minimal
=== RUN   TestAccECSTaskDefinition_EFSVolume_basic
=== PAUSE TestAccECSTaskDefinition_EFSVolume_basic
=== RUN   TestAccECSTaskDefinition_EFSVolume_transitEncryptionMinimal
=== PAUSE TestAccECSTaskDefinition_EFSVolume_transitEncryptionMinimal
=== RUN   TestAccECSTaskDefinition_EFSVolume_transitEncryption
=== PAUSE TestAccECSTaskDefinition_EFSVolume_transitEncryption
=== RUN   TestAccECSTaskDefinition_EFSVolume_transitEncryptionDisabled
=== PAUSE TestAccECSTaskDefinition_EFSVolume_transitEncryptionDisabled
=== RUN   TestAccECSTaskDefinition_EFSVolume_accessPoint
=== PAUSE TestAccECSTaskDefinition_EFSVolume_accessPoint
=== RUN   TestAccECSTaskDefinition_fsxWinFileSystem
=== PAUSE TestAccECSTaskDefinition_fsxWinFileSystem
=== RUN   TestAccECSTaskDefinition_DockerVolume_taskScoped
=== PAUSE TestAccECSTaskDefinition_DockerVolume_taskScoped
=== RUN   TestAccECSTaskDefinition_service
=== PAUSE TestAccECSTaskDefinition_service
=== RUN   TestAccECSTaskDefinition_taskRoleARN
=== PAUSE TestAccECSTaskDefinition_taskRoleARN
=== RUN   TestAccECSTaskDefinition_networkMode
=== PAUSE TestAccECSTaskDefinition_networkMode
=== RUN   TestAccECSTaskDefinition_ipcMode
=== PAUSE TestAccECSTaskDefinition_ipcMode
=== RUN   TestAccECSTaskDefinition_pidMode
=== PAUSE TestAccECSTaskDefinition_pidMode
=== RUN   TestAccECSTaskDefinition_constraint
=== PAUSE TestAccECSTaskDefinition_constraint
=== RUN   TestAccECSTaskDefinition_changeVolumesForcesNewResource
=== PAUSE TestAccECSTaskDefinition_changeVolumesForcesNewResource
=== RUN   TestAccECSTaskDefinition_arrays
=== PAUSE TestAccECSTaskDefinition_arrays
=== RUN   TestAccECSTaskDefinition_Fargate_basic
=== PAUSE TestAccECSTaskDefinition_Fargate_basic
=== RUN   TestAccECSTaskDefinition_Fargate_ephemeralStorage
=== PAUSE TestAccECSTaskDefinition_Fargate_ephemeralStorage
=== RUN   TestAccECSTaskDefinition_executionRole
=== PAUSE TestAccECSTaskDefinition_executionRole
=== RUN   TestAccECSTaskDefinition_disappears
=== PAUSE TestAccECSTaskDefinition_disappears
=== RUN   TestAccECSTaskDefinition_tags
=== PAUSE TestAccECSTaskDefinition_tags
=== RUN   TestAccECSTaskDefinition_proxy
=== PAUSE TestAccECSTaskDefinition_proxy
=== RUN   TestAccECSTaskDefinition_inferenceAccelerator
=== PAUSE TestAccECSTaskDefinition_inferenceAccelerator
=== RUN   TestAccECSTaskDefinition_invalidContainerDefinition
=== PAUSE TestAccECSTaskDefinition_invalidContainerDefinition
=== RUN   TestAccECSTaskDefinition_trackLatest
=== PAUSE TestAccECSTaskDefinition_trackLatest
=== RUN   TestAccECSTaskDefinition_unknownContainerDefinitions
=== PAUSE TestAccECSTaskDefinition_unknownContainerDefinitions
=== CONT  TestAccECSTaskDefinition_basic
=== CONT  TestAccECSTaskDefinition_taskRoleARN
=== CONT  TestAccECSTaskDefinition_EFSVolume_basic
--- PASS: TestAccECSTaskDefinition_taskRoleARN (11.89s)
=== CONT  TestAccECSTaskDefinition_EFSVolume_accessPoint
--- PASS: TestAccECSTaskDefinition_basic (17.60s)
=== CONT  TestAccECSTaskDefinition_service
--- PASS: TestAccECSTaskDefinition_EFSVolume_basic (20.10s)
=== CONT  TestAccECSTaskDefinition_DockerVolume_taskScoped
--- PASS: TestAccECSTaskDefinition_DockerVolume_taskScoped (8.46s)
=== CONT  TestAccECSTaskDefinition_fsxWinFileSystem
--- PASS: TestAccECSTaskDefinition_EFSVolume_accessPoint (23.86s)
=== CONT  TestAccECSTaskDefinition_executionRole
--- PASS: TestAccECSTaskDefinition_executionRole (11.55s)
=== CONT  TestAccECSTaskDefinition_unknownContainerDefinitions
--- PASS: TestAccECSTaskDefinition_unknownContainerDefinitions (10.17s)
=== CONT  TestAccECSTaskDefinition_trackLatest
--- PASS: TestAccECSTaskDefinition_trackLatest (10.60s)
=== CONT  TestAccECSTaskDefinition_invalidContainerDefinition
--- PASS: TestAccECSTaskDefinition_invalidContainerDefinition (0.70s)
=== CONT  TestAccECSTaskDefinition_inferenceAccelerator
--- PASS: TestAccECSTaskDefinition_inferenceAccelerator (10.85s)
=== CONT  TestAccECSTaskDefinition_proxy
--- PASS: TestAccECSTaskDefinition_proxy (21.78s)
=== CONT  TestAccECSTaskDefinition_tags
--- PASS: TestAccECSTaskDefinition_service (98.67s)
=== CONT  TestAccECSTaskDefinition_disappears
--- PASS: TestAccECSTaskDefinition_disappears (14.95s)
=== CONT  TestAccECSTaskDefinition_runtimePlatform
--- PASS: TestAccECSTaskDefinition_tags (34.35s)
=== CONT  TestAccECSTaskDefinition_EFSVolume_minimal
--- PASS: TestAccECSTaskDefinition_runtimePlatform (10.33s)
=== CONT  TestAccECSTaskDefinition_Fargate_runtimePlatformWithoutArch
--- PASS: TestAccECSTaskDefinition_Fargate_runtimePlatformWithoutArch (10.53s)
=== CONT  TestAccECSTaskDefinition_Fargate_runtimePlatform
--- PASS: TestAccECSTaskDefinition_EFSVolume_minimal (19.46s)
=== CONT  TestAccECSTaskDefinition_DockerVolume_basic
--- PASS: TestAccECSTaskDefinition_Fargate_runtimePlatform (10.66s)
=== CONT  TestAccECSTaskDefinition_DockerVolume_minimal
--- PASS: TestAccECSTaskDefinition_DockerVolume_basic (11.57s)
=== CONT  TestAccECSTaskDefinition_configuredAtLaunch
--- PASS: TestAccECSTaskDefinition_DockerVolume_minimal (11.75s)
=== CONT  TestAccECSTaskDefinition_scratchVolume
--- PASS: TestAccECSTaskDefinition_configuredAtLaunch (10.50s)
=== CONT  TestAccECSTaskDefinition_EFSVolume_transitEncryption
--- PASS: TestAccECSTaskDefinition_scratchVolume (10.89s)
=== CONT  TestAccECSTaskDefinition_EFSVolume_transitEncryptionDisabled
--- PASS: TestAccECSTaskDefinition_EFSVolume_transitEncryption (19.40s)
=== CONT  TestAccECSTaskDefinition_changeVolumesForcesNewResource
--- PASS: TestAccECSTaskDefinition_EFSVolume_transitEncryptionDisabled (20.52s)
=== CONT  TestAccECSTaskDefinition_Fargate_ephemeralStorage
--- PASS: TestAccECSTaskDefinition_changeVolumesForcesNewResource (16.92s)
=== CONT  TestAccECSTaskDefinition_Fargate_basic
--- PASS: TestAccECSTaskDefinition_Fargate_ephemeralStorage (10.86s)
=== CONT  TestAccECSTaskDefinition_arrays
--- PASS: TestAccECSTaskDefinition_Fargate_basic (14.14s)
=== CONT  TestAccECSTaskDefinition_pidMode
--- PASS: TestAccECSTaskDefinition_arrays (11.00s)
=== CONT  TestAccECSTaskDefinition_constraint
--- PASS: TestAccECSTaskDefinition_pidMode (11.86s)
=== CONT  TestAccECSTaskDefinition_ipcMode
--- PASS: TestAccECSTaskDefinition_constraint (12.12s)
=== CONT  TestAccECSTaskDefinition_EFSVolume_transitEncryptionMinimal
--- PASS: TestAccECSTaskDefinition_ipcMode (11.51s)
=== CONT  TestAccECSTaskDefinition_networkMode
--- PASS: TestAccECSTaskDefinition_EFSVolume_transitEncryptionMinimal (19.66s)
--- PASS: TestAccECSTaskDefinition_networkMode (11.71s)
--- PASS: TestAccECSTaskDefinition_fsxWinFileSystem (3004.89s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecs	3037.985s

Before the fix

% make testacc TESTARGS='-run=TestAccECSTaskDefinition_unknownContainerDefinitions' PKG=ecs
make: Verifying source code with gofmt...
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go1.22.5 test ./internal/service/ecs/... -v -count 1 -parallel 20  -run=TestAccECSTaskDefinition_unknownContainerDefinitions -timeout 360m
=== RUN   TestAccECSTaskDefinition_unknownContainerDefinitions
=== PAUSE TestAccECSTaskDefinition_unknownContainerDefinitions
=== CONT  TestAccECSTaskDefinition_unknownContainerDefinitions
    task_definition_test.go:1231: Step 1/1 error: Error running apply: exit status 1
        
        Error: Provider produced inconsistent final plan
        
        When expanding the plan for aws_ecs_task_definition.test to include new
        values learned so far during apply, provider
        "registry.terraform.io/hashicorp/aws" produced an invalid new value for
        .container_definitions: was cty.StringVal(""), but now
        cty.StringVal("[{\"Command\":null,\"Cpu\":0,\"CredentialSpecs\":null,\"DependsOn\":null,\"DisableNetworking\":null,\"DnsSearchDomains\":null,\"DnsServers\":null,\"DockerLabels\":null,\"DockerSecurityOptions\":null,\"EntryPoint\":null,\"Environment\":[{\"Name\":\"example1\",\"Value\":\"123\"},{\"Name\":\"example2\",\"Value\":\"456\"},{\"Name\":\"example3\",\"Value\":\"789\"}],\"EnvironmentFiles\":null,\"Essential\":null,\"ExtraHosts\":null,\"FirelensConfiguration\":null,\"HealthCheck\":null,\"Hostname\":null,\"Image\":\"jenkins/jenkins\",\"Interactive\":null,\"Links\":null,\"LinuxParameters\":null,\"LogConfiguration\":{\"LogDriver\":\"awslogs\",\"Options\":{\"awslogs-group\":\"tf-acc-test-7020277511731307967\",\"awslogs-region\":\"us-west-2\",\"awslogs-stream-prefix\":\"ecs\"},\"SecretOptions\":null},\"Memory\":null,\"MemoryReservation\":null,\"MountPoints\":null,\"Name\":\"jenkins\",\"PortMappings\":[{\"AppProtocol\":\"\",\"ContainerPort\":1234,\"ContainerPortRange\":null,\"HostPort\":1234,\"Name\":null,\"Protocol\":\"\"}],\"Privileged\":null,\"PseudoTerminal\":null,\"ReadonlyRootFilesystem\":null,\"RepositoryCredentials\":null,\"ResourceRequirements\":null,\"Secrets\":[{\"Name\":\"example4\",\"ValueFrom\":\"arn:aws:ssm:us-west-2:123456789012:parameter/tf-acc-test-7020277511731307967\"}],\"StartTimeout\":null,\"StopTimeout\":null,\"SystemControls\":null,\"Ulimits\":null,\"User\":null,\"VolumesFrom\":null,\"WorkingDirectory\":null}]").
        
        This is a bug in the provider, which should be reported in the provider's own
        issue tracker.
--- FAIL: TestAccECSTaskDefinition_unknownContainerDefinitions (6.04s)
FAIL
FAIL	github.com/hashicorp/terraform-provider-aws/internal/service/ecs	10.822s
FAIL
make: *** [testacc] Error 1

@ewbankkit ewbankkit requested a review from a team as a code owner July 22, 2024 17:19
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@terraform-aws-provider terraform-aws-provider bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/ecs Issues and PRs that pertain to the ecs service. size/S Managed by automation to categorize the size of a PR. labels Jul 22, 2024
Copy link

Thank you for your contribution! 🚀

A new usage of AWS SDK for Go V1 was detected. Please prefer AWS SDK for Go V2 for all net-new services. If this is an enhancement or bug fix to an existing AWS SDK Go V1 based resource, this comment can be safely ignored.

For additional information refer to the AWS SDK for Go Versions page in the contributor guide.

@ewbankkit ewbankkit added the bug Addresses a defect in current functionality. label Jul 23, 2024
@terraform-aws-provider terraform-aws-provider bot added size/XL Managed by automation to categorize the size of a PR. and removed size/S Managed by automation to categorize the size of a PR. labels Jul 23, 2024
@ewbankkit ewbankkit changed the title [WIP] r/aws_ecs_task_definition: Provider produced inconsistent final plan for container_definitions after v5.59.0 r/aws_ecs_task_definition: Provider produced inconsistent final plan for container_definitions after v5.59.0 Jul 23, 2024
Copy link
Member

@jar-b jar-b left a comment

Choose a reason for hiding this comment

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

LGTM 🚀

@ewbankkit ewbankkit merged commit 4cfe386 into main Jul 23, 2024
72 checks passed
@ewbankkit ewbankkit deleted the b-aws_ecs_task_definition.taskDefinition-regression branch July 23, 2024 21:05
@github-actions github-actions bot added this to the v5.60.0 milestone Jul 23, 2024
terraform-aws-provider bot pushed a commit that referenced this pull request Jul 23, 2024
Copy link

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service. size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
2 participants