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

Allow ECS Service Capacity Provider Updates #20707

Merged
merged 8 commits into from
Nov 25, 2021

Conversation

nitrocode
Copy link
Contributor

@nitrocode nitrocode commented Aug 27, 2021

Community Note

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

Closes #11351

Original PR #16402 thanks to @m13t

Output from acceptance testing:

$ make testacc TESTARGS='-run=TestAccXXX'

...

@github-actions github-actions bot added service/ecs Issues and PRs that pertain to the ecs service. needs-triage Waiting for first response or review from a maintainer. size/XS Managed by automation to categorize the size of a PR. and removed needs-triage Waiting for first response or review from a maintainer. labels Aug 27, 2021
@nitrocode
Copy link
Contributor Author

cc: @breathingdust Friendly ping for this small PR. Could I please get a review or what I can do to get this approved?

@zhelding
Copy link
Contributor

Pull request #21306 has significantly refactored the AWS Provider codebase. As a result, most PRs opened prior to the refactor now have merge conflicts that must be resolved before proceeding.

Specifically, PR #21306 relocated the code for all AWS resources and data sources from a single aws directory to a large number of separate directories in internal/service, each corresponding to a particular AWS service. This separation of code has also allowed for us to simplify the names of underlying functions -- while still avoiding namespace collisions.

We recognize that many pull requests have been open for some time without yet being addressed by our maintainers. Therefore, we want to make it clear that resolving these conflicts in no way affects the prioritization of a particular pull request. Once a pull request has been prioritized for review, the necessary changes will be made by a maintainer -- either directly or in collaboration with the pull request author.

For a more complete description of this refactor, including examples of how old filepaths and function names correspond to their new counterparts: please refer to issue #20000.

For a quick guide on how to amend your pull request to resolve the merge conflicts resulting from this refactor and bring it in line with our new code patterns: please refer to our Service Package Refactor Pull Request Guide.

@nitrocode
Copy link
Contributor Author

@zhelding conflicts resolved :)

@nitrocode
Copy link
Contributor Author

@zhelding @breathingdust hi all, just a friendly bump. is there anything else i can do to get this in the next release?

@zhelding
Copy link
Contributor

Hi @nitrocode!

No further action is required on your part. We will now review your PR as part of our standard triage prioritization process (see here). Unfortunately, we can't guarantee that your PR will get a review in a timely manner, but we will get to it as soon as we have capacity.

Thanks again for your contribution!

@m13t
Copy link

m13t commented Nov 20, 2021

@nitrocode as an enterprise customer, we presented a fork we actively use to correct this issue over a year ago and we’re still yet to see a formal solution.

@TarekAS
Copy link

TarekAS commented Nov 21, 2021

Super interested in seeing this merged. Fixes an issue that caused us downtime where aws_ecs_service was deleted but the replacement had an apply time error so it wasn't recreated.

@YakDriver YakDriver self-assigned this Nov 24, 2021
@YakDriver YakDriver force-pushed the b-ecs-service-capacity-provider branch from 24a4c13 to 4b349e0 Compare November 24, 2021 19:31
@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. size/XL Managed by automation to categorize the size of a PR. and removed size/XS Managed by automation to categorize the size of a PR. labels Nov 25, 2021
@github-actions github-actions bot added the documentation Introduces or discusses updates to documentation. label Nov 25, 2021
Copy link
Member

@YakDriver YakDriver left a comment

Choose a reason for hiding this comment

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

Looks great! 🎉

Output from acceptance tests (us-west-2):

% make testacc TESTS=TestAccECSService PKG=ecs                         
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecs/... -v -count 1 -parallel 20 -run='TestAccECSService' -timeout 180m
--- PASS: TestAccECSService_PlacementStrategy_missing (3.96s)
--- PASS: TestAccECSService_DaemonSchedulingStrategy_basic (50.68s)
--- PASS: TestAccECSService_PlacementConstraints_emptyExpression (81.63s)
--- PASS: TestAccECSService_DaemonSchedulingStrategy_setDeploymentMinimum (40.52s)
--- PASS: TestAccECSService_executeCommand (93.28s)
--- PASS: TestAccECSService_PlacementConstraints_basic (93.93s)
--- PASS: TestAccECSService_forceNewDeployment (94.00s)
--- PASS: TestAccECSService_Tags_managed (95.75s)
--- PASS: TestAccECSService_replicaSchedulingStrategy (97.32s)
--- PASS: TestAccECSServiceDataSource_basic (97.34s)
--- PASS: TestAccECSService_PlacementStrategy_basic (98.25s)
--- PASS: TestAccECSService_Tags_basic (104.73s)
--- PASS: TestAccECSService_LaunchTypeEC2_network (122.27s)
--- PASS: TestAccECSService_DeploymentControllerType_external (58.65s)
--- PASS: TestAccECSService_iamRole (50.11s)
--- PASS: TestAccECSService_LaunchTypeFargate_waitForSteadyState (165.08s)
--- PASS: TestAccECSService_DeploymentValues_minZeroMaxOneHundred (72.20s)
--- PASS: TestAccECSService_clusterName (72.16s)
--- PASS: TestAccECSService_LaunchTypeFargate_platformVersion (172.92s)
--- PASS: TestAccECSService_LaunchTypeFargate_basic (173.31s)
--- PASS: TestAccECSService_ServiceRegistries_container (174.13s)
--- PASS: TestAccECSService_ServiceRegistries_basic (170.46s)
--- PASS: TestAccECSService_LaunchTypeFargate_updateWaitForSteadyState (175.54s)
--- PASS: TestAccECSService_DeploymentValues_basic (87.44s)
--- PASS: TestAccECSService_deploymentCircuitBreaker (87.62s)
--- PASS: TestAccECSService_loadBalancerChanges (111.42s)
--- PASS: TestAccECSService_Tags_propagate (215.96s)
--- PASS: TestAccECSService_CapacityProviderStrategy_multiple (81.98s)
--- PASS: TestAccECSService_renamedCluster (90.92s)
--- PASS: TestAccECSService_basicImport (81.22s)
--- PASS: TestAccECSService_CapacityProviderStrategy_forceNewDeployment (133.56s)
--- PASS: TestAccECSService_disappears (88.99s)
--- PASS: TestAccECSService_multipleTargetGroups (261.24s)
--- PASS: TestAccECSService_basic (89.68s)
--- PASS: TestAccECSService_PlacementStrategy_unnormalized (92.55s)
--- PASS: TestAccECSService_familyAndRevision (101.23s)
--- PASS: TestAccECSService_ServiceRegistries_changes (340.52s)
--- PASS: TestAccECSService_DeploymentControllerType_codeDeploy (248.34s)
--- PASS: TestAccECSService_healthCheckGracePeriodSeconds (260.77s)
--- PASS: TestAccECSService_alb (249.43s)
--- PASS: TestAccECSService_CapacityProviderStrategy_basic (182.06s)
--- PASS: TestAccECSService_CapacityProviderStrategy_update (228.79s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecs	395.248s

Output from acceptance tests (GovCloud):

% make testacc TESTS=TestAccECSService PKG=ecs                                    
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/ecs/... -v -count 1 -parallel 20 -run='TestAccECSService' -timeout 180m
--- PASS: TestAccECSService_PlacementStrategy_missing (4.94s)
--- PASS: TestAccECSService_DaemonSchedulingStrategy_basic (40.12s)
--- PASS: TestAccECSService_DaemonSchedulingStrategy_setDeploymentMinimum (59.07s)
--- PASS: TestAccECSService_ServiceRegistries_basic (80.65s)
--- PASS: TestAccECSService_Tags_managed (89.98s)
--- PASS: TestAccECSService_PlacementConstraints_emptyExpression (90.21s)
--- PASS: TestAccECSService_replicaSchedulingStrategy (90.21s)
--- PASS: TestAccECSServiceDataSource_basic (90.31s)
--- PASS: TestAccECSService_ServiceRegistries_container (114.33s)
--- PASS: TestAccECSService_LaunchTypeEC2_network (119.98s)
--- PASS: TestAccECSService_PlacementConstraints_basic (117.62s)
--- PASS: TestAccECSService_Tags_basic (124.68s)
--- PASS: TestAccECSService_executeCommand (126.84s)
--- PASS: TestAccECSService_PlacementStrategy_basic (103.24s)
--- PASS: TestAccECSService_forceNewDeployment (90.02s)
--- PASS: TestAccECSService_LaunchTypeFargate_basic (157.93s)
--- PASS: TestAccECSService_DeploymentValues_minZeroMaxOneHundred (90.32s)
--- PASS: TestAccECSService_LaunchTypeFargate_platformVersion (173.26s)
--- PASS: TestAccECSService_clusterName (91.24s)
--- PASS: TestAccECSService_LaunchTypeFargate_waitForSteadyState (183.95s)
--- PASS: TestAccECSService_DeploymentControllerType_external (62.89s)
--- PASS: TestAccECSService_ServiceRegistries_changes (198.03s)
--- PASS: TestAccECSService_renamedCluster (86.39s)
--- PASS: TestAccECSService_LaunchTypeFargate_updateWaitForSteadyState (202.46s)
--- PASS: TestAccECSService_DeploymentValues_basic (75.71s)
--- PASS: TestAccECSService_loadBalancerChanges (114.11s)
--- PASS: TestAccECSService_familyAndRevision (87.13s)
--- PASS: TestAccECSService_iamRole (52.54s)
--- PASS: TestAccECSService_deploymentCircuitBreaker (90.73s)
--- PASS: TestAccECSService_Tags_propagate (213.94s)
--- PASS: TestAccECSService_CapacityProviderStrategy_forceNewDeployment (130.75s)
--- PASS: TestAccECSService_multipleTargetGroups (243.00s)
--- PASS: TestAccECSService_basic (72.12s)
--- PASS: TestAccECSService_PlacementStrategy_unnormalized (90.17s)
--- PASS: TestAccECSService_disappears (74.01s)
--- PASS: TestAccECSService_CapacityProviderStrategy_multiple (124.63s)
--- PASS: TestAccECSService_basicImport (94.98s)
--- PASS: TestAccECSService_healthCheckGracePeriodSeconds (294.69s)
--- PASS: TestAccECSService_alb (237.42s)
--- PASS: TestAccECSService_CapacityProviderStrategy_basic (192.52s)
--- PASS: TestAccECSService_CapacityProviderStrategy_update (192.40s)
--- PASS: TestAccECSService_DeploymentControllerType_codeDeploy (234.80s)
PASS
ok  	github.com/hashicorp/terraform-provider-aws/internal/service/ecs	379.491s

@YakDriver YakDriver merged commit 8b30c11 into hashicorp:main Nov 25, 2021
@github-actions github-actions bot added this to the v3.67.0 milestone Nov 25, 2021
@nitrocode nitrocode deleted the b-ecs-service-capacity-provider branch November 25, 2021 20:13
@github-actions
Copy link

github-actions bot commented Dec 1, 2021

This functionality has been released in v3.67.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!

@aksharpanchal
Copy link

Ran into an issue with v3.67 when managing ecs_service resource with capacity_provider. Don't see any other changes to ecs_service resource except this PR. Downgrading to v.3.66 seems to solve the issue.

   Error: Provider produced inconsistent final plan

   When expanding the plan for module.ecs_service.aws_ecs_service.this[0] to
   include new values learned so far during apply, provider
   "registry.terraform.io/hashicorp/aws" produced an invalid new value for
   .capacity_provider_strategy: planned set element
   cty.ObjectVal(map[string]cty.Value{"base":cty.NullVal(cty.Number),
   "capacity_provider":cty.StringVal(""), "weight":cty.NullVal(cty.Number)}) does
   not correlate with any element in actual.

   This is a bug in the provider, which should be reported in the provider's own
   issue tracker.

@spatel96
Copy link

spatel96 commented Jan 26, 2022

I'm also seeing potential issue, running a newer version of the provider hashicorp/aws v3.73.0:

Terraform Plan:

  # module.my_service.aws_ecs_service.ecs_service must be replaced
+/- resource "aws_ecs_service" "ecs_service" {
        cluster                            = "arn:aws:ecs:us-west-1:***:cluster/ecs-related-tapir"
        deployment_maximum_percent         = 200
        deployment_minimum_healthy_percent = 100
        desired_count                      = 2
        enable_ecs_managed_tags            = false
        enable_execute_command             = false
        health_check_grace_period_seconds  = 120
      ~ iam_role                           = "aws-service-role" -> (known after apply)
      ~ id                                 = "arn:aws:ecs:us-west-1:***:service/my-cluster/my-service-5e" -> (known after apply)
      ~ launch_type                        = "EC2" -> (known after apply)
        name                               = "my-service-service-5e"
      + platform_version                   = (known after apply)
      - propagate_tags                     = "NONE" -> null
        scheduling_strategy                = "REPLICA"
      - tags                               = {} -> null
      ~ tags_all                           = {} -> (known after apply)
      ~ task_definition                    = "arn:aws:ecs:us-west-1:***:task-definition/my-service-:23" -> "arn:aws:ecs:us-west-1:***:task-definition/my-service:1"
        wait_for_steady_state              = false

      + capacity_provider_strategy { # forces replacement
          + base              = 0
          + capacity_provider = "ecs-capacity-provider-related-tapir"
          + weight            = 100
        }

        deployment_controller {
            type = "CODE_DEPLOY"
        }

        load_balancer {
            container_name   = "my-service"
            container_port   = 7171
            target_group_arn = "arn:aws:elasticloadbalancing:us-west-1:***:targetgroup/abcdef/abcdef"
        }
    }

Plan: 1 to add, 0 to change, 1 to destroy.

Terraform Apply error:

Error: error creating ECS service (my-service): InvalidParameterException: Creation of service was not idempotent.

@YakDriver
Copy link
Member

@spatel96 Can you right up an issue? It needs to be marked as a regression.

@spatel96
Copy link

I've raised the following issue:
#22823

Will add more context when possible.

@github-actions
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 May 25, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Introduces or discusses updates to documentation. 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
Development

Successfully merging this pull request may close these issues.

Updating ECS service capacity provider strategy replaces resource
8 participants