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

resource/aws_autoscaling_group: Terraform 0.14 ignore_changes Handling for load_balancers and target_group_arns #15642

Closed
bflad opened this issue Oct 14, 2020 · 2 comments
Labels
documentation Introduces or discusses updates to documentation. service/autoscaling Issues and PRs that pertain to the autoscaling service. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.

Comments

@bflad
Copy link
Contributor

bflad commented Oct 14, 2020

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

Description

Future versions of Terraform CLI, starting with 0.14, are more sensitive to how the lifecycle configuration block ignore_changes argument is applied. Directionally, Terraform's core logic has been moving towards being more explicit about what Terraform Providers can and cannot suggest towards having configurations differ from the final applied state. These differences typically are what cause subtle bugs in core's handling across its whole feature set or represent situations where a generated plan may not exactly match the applied intention of a configuration.

In our Terraform 0.14.0-alpha20201007 testing of the provider, these failures are present:

=== CONT  TestAccAWSAutoscalingAttachment_elb
TestAccAWSAutoscalingAttachment_elb: resource_aws_autoscaling_attachment_test.go:18: Step 1/5 error: Error running pre-apply refresh:
Error: Cannot ignore argument not set in the configuration
on config042213050/terraform_plugin_test.tf line 71, in resource "aws_autoscaling_group" "asg":
71:     ignore_changes = [load_balancers, target_group_arns]
The ignore_changes argument is not set in the configuration.
The ignore_changes mechanism only applies to changes within the configuration,
and must be used with arguments set in the configuration and not computed by
the provider.
--- FAIL: TestAccAWSAutoscalingAttachment_elb (6.53s)

=== CONT  TestAccAWSAutoscalingAttachment_albTargetGroup
TestAccAWSAutoscalingAttachment_albTargetGroup: resource_aws_autoscaling_attachment_test.go:61: Step 1/5 error: Error running pre-apply refresh:
Error: Cannot ignore argument not set in the configuration
on config344130447/terraform_plugin_test.tf line 101, in resource "aws_autoscaling_group" "asg":
101:     ignore_changes = [load_balancers, target_group_arns]
The ignore_changes argument is not set in the configuration.
The ignore_changes mechanism only applies to changes within the configuration,
and must be used with arguments set in the configuration and not computed by
the provider.
--- FAIL: TestAccAWSAutoscalingAttachment_albTargetGroup (7.32s)

Recently in Terraform AWS Provider version 3.0.0, we enabled drift detection of the aws_autoscaling_group resource load_balancers and target_group_arns arguments by removing Computed: true from the schema to help practitioners with the case that wholly removing either of these arguments from their configuration would not physically remove load balancer and target group attachments as might be expected. However, these attachments can also occur via the separate aws_autoscaling_attachment resource as noted in these tests, which is currently documented to work without specifying those arguments in some fashion. The new Terraform errors suggest that we can no longer document or provide the guidance that the arguments can be fully omitted while also suggesting ignore_changes. This may just require documentation and testing updates for now, although reverting back to the more proper Computed: true schema property may also be necessary in the future to match Terraform core's expectations that the provider cannot return a state value different than what is configured.

Affected Resource(s)

  • aws_autoscaling_attachment
  • aws_autoscaling_group

Potential Terraform Configuration

resource "aws_autoscaling_group" "example" {
  # This argument configuration will likely need to exist in Terraform 0.14 and greater
  # configurations using ignore_changes
  load_balancers = []

  # ... other configuration ...

  lifecycle {
    ignore_changes = [load_balancers]
  }
}

resource "aws_autoscaling_attachment" "example" {
  autoscaling_group_name = aws_autoscaling_group.example.id
  elb                    = aws_elb.example.id
}

References

@bflad bflad added service/autoscaling Issues and PRs that pertain to the autoscaling service. technical-debt Addresses areas of the codebase that need refactoring or redesign. terraform-0.14 documentation Introduces or discusses updates to documentation. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Oct 14, 2020
@bflad
Copy link
Contributor Author

bflad commented Nov 30, 2020

The acceptance tests that were previously failing in the early alpha build are passing with rc1, so my hunch here is that nothing will be required to do before the Terraform 0.14 release with the resource.

@bflad bflad closed this as completed Nov 30, 2020
@ghost
Copy link

ghost commented Dec 31, 2020

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 as resolved and limited conversation to collaborators Dec 31, 2020
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/autoscaling Issues and PRs that pertain to the autoscaling service. technical-debt Addresses areas of the codebase that need refactoring or redesign. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

No branches or pull requests

1 participant