hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.76k stars 9.12k forks source link

[Bug]: Getting invalid value for capacity_provider_strategy while trying to create an ECS #37865

Closed Prabhanjali closed 1 month ago

Prabhanjali commented 3 months ago

Terraform Core Version

0.15.4

AWS Provider Version

3.68.0

Affected Resource(s)

aws_ecs_service, aws_ecs_cluster

Expected Behavior

to avoid this error and this service to be worked without any errors

Actual Behavior

I've previously used AWS provider version of 3.57.0. Recently, I changed the version to 3.68.0, from then, I'm encountering this issue.

Error:

'Error: Provider produced inconsistent final plan'
When expanding the plan for aws_ecs_service.task_service[0] to include new values learned so far during apply, provider '"registry.terraform.io/hashicorp/aws" produced an invalid new value for' '.capacity_provider_strategy: planned set element'
cty.ObjectVal(map[string]cty.Value{"base":cty.NullVal(cty.Number), '"capacity_provider":cty.StringVal(""), "weight":cty.NullVal(cty.Number)})' does not correlate with any element in actual.

Relevant Error/Panic Output Snippet

'Error: Provider produced inconsistent final plan'
When expanding the plan for aws_ecs_service.task_service[0] to include new values learned so far during apply, provider '"registry.terraform.io/hashicorp/aws" produced an invalid new value for' '.capacity_provider_strategy: planned set element'
cty.ObjectVal(map[string]cty.Value{"base":cty.NullVal(cty.Number), '"capacity_provider":cty.StringVal(""), "weight":cty.NullVal(cty.Number)})' does not correlate with any element in actual.

Terraform Configuration Files

resource "aws_autoscaling_group" "test" {
  # ... other configuration, including potentially other tags ...

  tag {
    key                 = "AmazonECSManaged"
    value               = true
    propagate_at_launch = true
  }
}

resource "aws_ecs_capacity_provider" "test" {
  name = "test"

  auto_scaling_group_provider {
    auto_scaling_group_arn         = aws_autoscaling_group.test.arn
    managed_termination_protection = "ENABLED"

    managed_scaling {
      maximum_scaling_step_size = 1000
      minimum_scaling_step_size = 1
      status                    = "ENABLED"
      target_capacity           = 10
    }
  }
}

Steps to Reproduce

  1. terraform init
  2. terraform plan
  3. terraform apply

Debug Output

No response

Panic Output

No response

Important Factoids

No response

References

No response

Would you like to implement a fix?

None

github-actions[bot] commented 3 months ago

Community Note

Voting for Prioritization

Volunteering to Work on This Issue

Prabhanjali commented 3 months ago

Hey, Can anyone check this issue and let me know how to fix this?

justinretzolk commented 3 months ago

Hey @Prabhanjali πŸ‘‹ Thank you for taking the time to raise this! The version of Terraform and the AWS Provider that you're using are both quite old at this point. Can you test with more recent versions to see if the issue persists?

Prabhanjali commented 3 months ago

sure, if I change the version of terraform/ aws provider, are there any changes that I need to change for the existing configurations of my ECS and it's supporting services?

justinretzolk commented 3 months ago

@Prabhanjali There likely will be, but it's hard for me to say for certain. You'll likely at least need to reference the Version 4 Upgrade Guide and Version 5 Upgrade Guide to see if there are aspects of your configuration that need updating.

Prabhanjali commented 3 months ago

@justinretzolk, do we have any restrictions to use the terraform version with aws provider version?? What is the maximum aws provider version that 0.15.4 terraform version accepts? Is there any documentation for this?

justinretzolk commented 3 months ago

Hey @Prabhanjali πŸ‘‹ To my knowledge, 0.15 should still work with largely every provider, but that'll begin to change as providers adopt later revisions of Terraform's underlying framework, the AWS provider included. For now, even the most recent versions work with that version of Terraform:

$ terraform -v
Terraform v0.15.4
on darwin_amd64
+ provider registry.terraform.io/hashicorp/aws v5.54.1
Prabhanjali commented 3 months ago

Hey @justinretzolk, thanks for your reply. Let me check and get back to you

Prabhanjali commented 3 months ago

@justinretzolk, Can you let me know in which version of aws provider the below issue is resolved?

'Error: Provider produced inconsistent final plan'
When expanding the plan for aws_ecs_service.task_service[0] to include new values learned so far during apply, provider '"registry.terraform.io/hashicorp/aws" produced an invalid new value for' '.capacity_provider_strategy: planned set element'
cty.ObjectVal(map[string]cty.Value{"base":cty.NullVal(cty.Number), '"capacity_provider":cty.StringVal(""), "weight":cty.NullVal(cty.Number)})' does not correlate with any element in actual.

It's hard to trail all the provider versions and there are changes to the resources like capacity_provider in the terraform major version 4 when compared to version 3.

I'm using terraform version 0.15.4 and I tried till 3.76.1 aws provider version i.e, till the version where the capacity_provider is accepted as a varaible in ecs_cluster resource.

Any help here is appreciated!! Thanks.

justinretzolk commented 3 months ago

Hey @Prabhanjali πŸ‘‹ That's a fairly generic error, so we unfortunately wouldn't be able to deduce that kind of information from that alone. If it's at all possible, it may be worth creating a small reproduction that you can test against later versions, so as to not impact your other workloads. Given that we don't backport fixes as far back as the version you're currently using, we'll need confirmation that this impacts more recent versions to ensure that this gets prioritized in a timely manner.

Prabhanjali commented 3 months ago

@justinretzolk, can you please let me know in which terraform and aws provider version this issue is resolved?

Also, ECS needs too many things to be configured, to reproduce the capacity_provider issue

justinretzolk commented 2 months ago

Hey @Prabhanjali πŸ‘‹ It would be difficult for us to determine exactly which versions experience this behavior without manually stepping through each one. It could be that the issue occurs even with more recent versions of Terraform and the AWS provider, however, without a configuration that can be used to reproduce the issue, we're not able to verify that. If you're able to reproduce with recent versions of Terraform and the AWS provider and then provide us a sample configuration and/or debug logging (redacted as needed), we'd be happy to look at this more. Unfortunately, without that information, we'll need to close this issue as unreproducible.

justinretzolk commented 1 month ago

Since we haven't heard back, and with my previous comment in mind, I'm going to close this issue. If you experience unexpected behavior with the provider in the future, please do let us know!

github-actions[bot] commented 1 month ago

[!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.

github-actions[bot] commented 2 days ago

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.