terraform-provider-aws icon indicating copy to clipboard operation
terraform-provider-aws copied to clipboard

Support for aws_ecs_service updates with CODE_DEPLOY deployment controller

Open carcher5432 opened this issue 2 years ago • 1 comments

Description

Adds support to aws_ecs_service for updates using the CODE_DEPLOY deployment controller. Previously, using the CODE_DEPLOY deployment controller will lead to errors in updating a number of attributes.

The following block is added to aws_ecs_service:

code_deploy {
  application_name = aws_codedeploy_app.main.name // Required
  deployment_group_name = aws_codedeploy_deployment_group.main.deployment_group_name // Required
  hooks { // Optional
    before_install = aws_lambda_function.before_install.arn
    after_install = aws_lambda_function.after_install.arn
    after_allow_test_traffic = aws_lambda_function.after_allow_test_traffic.arn
    before_allow_traffic = aws_lambda_function.before_allow_traffic.arn
    after_allow_traffic = aws_lambda_function.after_allow_traffic.arn
  }
}

This is a preview of the way I believe the workflow should happen, consolidated into one file for easy personal maintenance if this is not accepted for the provider. If this workflow is acceptable, I will spread it out to have better separation of concerns, add documentation, and figure out acceptance tests.

Questions

  • Should the service only wait for the deployment to complete if wait_for_steady_state is set, or do so by default?
  • What mechanisms should be used to detect a failed deployment that CodeDeploy has not marked as failed? (Current implementation has 3 failed tasks in the new task set -> failed deployment)
  • What should the timeout be determined by for a deployment? Currently set to 20 minutes. Should it use the reference to optional timeouts block? If so, should it be a different key or use the "update" key?

Relations

Closes #20850 Closes #12703

References

ECS UpdateService: https://docs.aws.amazon.com/AmazonECS/latest/APIReference/API_UpdateService.html The API does not allow this action on ECS services with the CODE_DEPLOY deployment controller except for certain fields. Code Deploy CreateDeployment must be used. Code Deploy CreateDeployment: https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeployment.html

Output from Acceptance Testing

Not done yet

$ make testacc TESTS=TestAccXXX PKG=ec2

...

carcher5432 avatar Nov 23 '22 01:11 carcher5432

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.

github-actions[bot] avatar Nov 23 '22 01:11 github-actions[bot]

This is a critical feature for our application teams as there is currently no seamless way to implement B/G deployments using ECS outside of native AWS Tools (CodeCommit/CodeDeploy etc) with a Git repo and Gitlab pipelines.

sg4j avatar Nov 30 '22 19:11 sg4j

Very useful feature, is there any plans to merge that? Meanwhile it seems that the most "terraformish" way to implement that separately is to create a separate provider. I've created https://registry.terraform.io/providers/ikorchynskyi/codedeploy/latest for that purposes (very basic and only to trigger deployment / wait for its completion)

ikorchynskyi avatar Jun 27 '23 14:06 ikorchynskyi

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[bot] avatar Nov 24 '23 02:11 github-actions[bot]