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

Can't ignore changes for aws_ecs_service load_balancer.0.target_group_arn (for CodeDeploy blue-green deploys) #13192

Closed
jfirebaugh opened this issue May 6, 2020 · 12 comments
Assignees
Labels
bug Addresses a defect in current functionality. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/ecs Issues and PRs that pertain to the ecs service.

Comments

@jfirebaugh
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue 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 issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform Version

Terraform v0.12.24
+ provider.aws v2.54.0

Affected Resource(s)

  • aws_ecs_service

Terraform Configuration Files

resource "aws_ecs_service" "service" {
  # ...

  load_balancer {
    target_group_arn = var.target_group_a_arn
    container_name   = var.load_balancer_container_name
    container_port   = 80
  }

  lifecycle {
    ignore_changes = [load_balancer.0.target_group_arn]
  }
}

Expected Behavior

The target_group_arn key of the first load_balancer set should be ignored. This is necessary for using CodeDeploy blue-green deployments, which modify this property outside of terraform's control.

Actual Behavior

When running terraform plan, the following error is output:

Error: Cannot index a set value

  on deploy/ecs_web_service/main.tf line 52, in resource "aws_ecs_service" "service":
  52:     ignore_changes = [desired_count, task_definition, load_balancer.0.target_group_arn]

Block type "load_balancer" is represented by a set of objects, and set
elements do not have addressable keys. To find elements matching specific
criteria, use a "for" expression with an "if" clause.

References

This was previously reported in #9776. @bflad said there to open an issue in terraform core repository. @ryzr did so: hashicorp/terraform#22504. Then that issue was closed by @ryzr saying to open an issue here again. So that's what I'm doing. Please consider @jbardin's suggestion of using a TypeList rather than a Set.

@ghost ghost added the service/ecs Issues and PRs that pertain to the ecs service. label May 6, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label May 6, 2020
@chrysalis69
Copy link

I've just ignored the complete load_balancer block, because all 3 values (target_group_arn, container_name, container_port) are managed by the appspec in code-deploy.

In other words, my lifecycle looks like this:

  lifecycle {
    ignore_changes = [
      desired_count,   # Updated possibly by auto scaling
      task_definition, # Updated by deployments
      load_balancer,
    ]
  }

@fugitive90
Copy link

@chrysalis69 For task_definition , you could use this snippet:
task_definition = "${aws_ecs_task_definition.this.family}:${max(aws_ecs_task_definition.this.revision, data.aws_ecs_task_definition.latest.revision)}"

Just find with data resource current task definition revision and revision from your TF definition, this would be a way to get latest one.

I also experience this bug with CodeDeploy B/G deployments

@justinretzolk
Copy link
Member

Hey @jfirebaugh 👋 Thank you for taking the time to submit this issue. Given that there's been a few AWS Provider releases since you initially filed it, can you confirm whether you're still experiencing this behavior?

@justinretzolk justinretzolk added waiting-response Maintainers are waiting on response from community or contributor. and removed needs-triage Waiting for first response or review from a maintainer. labels Sep 27, 2021
@github-actions github-actions bot removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 27, 2021
@jfirebaugh
Copy link
Author

It's still a provider issue, albeit one that has viable workarounds as others have noted.

@justinretzolk justinretzolk added the bug Addresses a defect in current functionality. label Sep 28, 2021
@sitole
Copy link

sitole commented Jan 25, 2022

Any progress?

@aholthagerty
Copy link

this is an issue with more than just aws_ecs_service load_balancer.0.target_group_arn

this is an issue with any resource currently using a Set rather than a TypeList, correct?

@dtfiedler
Copy link

any changes here?

@quinn
Copy link

quinn commented Jun 15, 2023

any update here?

@d11-jwaring
Copy link

Still occurring in version 5.4 of the AWS provider.

@gdavison gdavison self-assigned this Apr 18, 2024
@terraform-aws-provider terraform-aws-provider bot added the prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. label Apr 18, 2024
@gdavison
Copy link
Contributor

Thanks all for reporting the issue and participating in the discussion. The lifecycle.ignore_changes directive is managed by Terraform itself while generating a plan, and the provider is never aware of it. This means that any fixes to the general behaviour of lifecycle.ignore_changes need to be implemented in the Terraform project.

For this specific case, load_balancer is a Set because it can have multiple values and the order is not significant. Using the List type would not be appropriate for this parameter.

To ignore changes, you could ignore changes to the whole Set, using

lifecycle {
  ignore_changes = [load_balancer]
}

as suggested above.

If the other values should not be ignored, I suggest requesting the feature from the Terraform project. In a previous report (hashicorp/terraform#22504 (comment)) they suggested that ignoring individual parameters of set members would be "a very limited use case". You could open a new issue with them and indicate how it is useful.

@gdavison gdavison closed this as not planned Won't fix, can't repro, duplicate, stale Apr 18, 2024
Copy link

Warning

This issue has been closed, meaning that any additional comments are hard for our team to see. Please assume that the maintainers will not see them.

Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed.

Copy link

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 have found a problem that seems similar to this, 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 18, 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. prioritized Part of the maintainer teams immediate focus. To be addressed within the current quarter. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
Development

No branches or pull requests

10 participants