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

ignore_changes not working for sets #9776

Closed
ryzr opened this issue Aug 15, 2019 · 5 comments
Closed

ignore_changes not working for sets #9776

ryzr opened this issue Aug 15, 2019 · 5 comments
Labels
service/ecs Issues and PRs that pertain to the ecs service. upstream-terraform Addresses functionality related to the Terraform core binary.

Comments

@ryzr
Copy link

ryzr commented Aug 15, 2019

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 "me too" comments, 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

0.12.6

Affected Resource(s)

  • aws_ecs_service
  • likely many others

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.

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.

Steps to Reproduce

  1. Create a resource similar to the one above
  2. terraform plan

Important Factoids

I have attempted many other variations, including

load_balancer.target_group_arn
load_balancer.0.target_group_arn
load_balancer["*"].target_group_arn
load_balancer["%"].target_group_arn
load_balancer["#"].target_group_arn

These all return the same error.

References

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

outime commented Aug 16, 2019

I could reproduce this issue and under exact same circumstances (ECS service resource).

@bflad bflad added the upstream-terraform Addresses functionality related to the Terraform core binary. label Aug 16, 2019
@bflad
Copy link
Contributor

bflad commented Aug 16, 2019

Hi folks 👋 Thank you for reporting this.

The logic and behavior of the lifecycle configuration block ignore_changes meta-argument is managed upstream in Terraform CLI code and applicable across all Terraform resources. The lifecycle configuration block itself is special in Terraform and is designed to control various aspects of ordering and difference handling without interaction or necessary implementation in Terraform Providers.

The mentioned ignore_changes limitation is unfortunately not something that we can perform any adjustments in the Terraform AWS Provider codebase to fix or workaround, as the provider never actually receives any information from the lifecycle configuration block. Once the feature is implemented in Terraform CLI, it will automatically work with the Terraform AWS Provider after upgrading to the Terraform CLI containing the change. Since there is nothing that can be done in this codebase and GitHub does not support migrating issues across GitHub organizations, we will close this issue but suggest that you re-open a new one upstream: https://github.com/hashicorp/terraform/issues/new/choose

@ryzr
Copy link
Author

ryzr commented Aug 18, 2019

Hey @bflad, thank you for the response.

That makes sense. I got a little confused on where to open it, as the same issue was opened on hashicorp/terraform last year and then migrated to this repo :-P

@outime I've re-opened the issue on hashicorp/terraform here:
hashicorp/terraform#22504

@outime
Copy link

outime commented Aug 18, 2019

@ryzr thanks! Gave my upvote there as well.

@ghost
Copy link

ghost commented Nov 1, 2019

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 feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Nov 1, 2019
@breathingdust breathingdust removed the needs-triage Waiting for first response or review from a maintainer. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/ecs Issues and PRs that pertain to the ecs service. upstream-terraform Addresses functionality related to the Terraform core binary.
Projects
None yet
Development

No branches or pull requests

4 participants