navapbc / wic-participant-recertification-portal

https://navapbc.github.io/wic-participant-recertification-portal/
Apache License 2.0
0 stars 1 forks source link

[PRP-268] Correctly allow Github and Terraform to manage ECS task definitions #53

Closed rocketnova closed 1 year ago

rocketnova commented 1 year ago

Ticket

https://wicmtdp.atlassian.net/browse/PRP-268

Changes

What was added, updated, or removed in this PR.

Context for reviewers

Testing instructions, background context, more in-depth details of the implementation, and anything else you'd like to call out or ask reviewers. Explain how the changes were verified.

We have a confluence of factors that makes CD a little challenging:

To accomplish this, we have:

# in aws_ecs_service
  lifecycle {
    ignore_changes = [
      desired_count,
      task_definition,
    ]
  }

However, if this is the only change we ignore, the aws_ecs_task_definition will try to update the container definitions to the default image tag if we have previously set it to something else.

This PR adds the following:

# in aws_ecs_task_definition
  lifecycle {
    ignore_changes = [
      container_definitions
    ]
  }

This change will by default make NO changes to the task container definition when running terraform apply.

If you DO need to make changes to the task container definition for some reason, you need to manually and TEMPORARILY uncomment both of these ignore_changes lines and pass in -var="image_tag=<correct_image_tag>". This has been documented inline.

Note: It would be ideal to control this behavior with a variable that you can pass into terraform plan/terraform apply. However, lifecycle cannot handle expression evaluation or variable interpolation. 😞 See https://github.com/hashicorp/terraform/issues/3116

Testing

Screenshots, GIF demos, code examples or output to help show the changes working as expected. ProTip: you can drag and drop or paste images into this textbox.

  1. terraform plan with the default should return no changes for the ECS services and ECS task definitions
  2. terraform plan with only the task_definition line commented out should show that the task definitions want to update the image tags
  3. terraform plan with both the task_definition and container_definitions lines commented out should show that the task definitions want to update the image tags AND the services want to point to the new task definitions