Terraform-provider-aws: Error creating Capacity Providers on ECS Cluster

Created on 18 Dec 2019  ยท  8Comments  ยท  Source: hashicorp/terraform-provider-aws

getting these errors with this push
using latest terraform and latest aws provider

$ terraform --version
Terraform v0.12.18
+ provider.aws v2.42.0
+ provider.template v2.1.2
Error: error creating capacity provider: ClientException: The managed termination protection setting for the capacity provider is invalid. To enable managed termination protection for a capacity provider, the Auto Scaling group must have instance protection from scale in enabled.

i have enabled protect_from_scale_in = true for the autoscaling group so not sure what the issue is

References

11151

documentation servicecs

Most helpful comment

final update!

when i used name of capacity provider instead of the arn then it works
this is a bug!

works now when i referenced the capacity provider by the name
did not work when i referenced by the arn

All 8 comments

ok this works now

i think was issue with my autoscaling group not able to update when launch configuration changes so i fixed that and now i am able to create capacity provider

BUT when the capacity provider was created after a successful terraform apply, i am not able to see it under the "capacity providers" tab of the ECS cluster

am i missing anything? where do i see the capacity provider created by terraform?

here is latest when trying to attach the capacity provider created to the ECS cluster
capacity provider arn:aws:ecs:abc123 and was able to even reference it in my terraform which is why it can even have a capacity provider to search..but now can't find it

Error: error changing ECS cluster capacity provider settings (arn:aws:ecs:abc123): InvalidParameterException: The specified capacity provider 'arn:aws:ecs:abc123' was not found. Specify a valid capacity provider and try again.

final update!

when i used name of capacity provider instead of the arn then it works
this is a bug!

works now when i referenced the capacity provider by the name
did not work when i referenced by the arn

@encryptblockr : Can you share the syntax you've used, and did you hardcode the value?

It works fine when I hard code the name of the capacity provider
capacity_providers = ["mytest"] ---- This works

But it throws an error when i try to refer it like
capacity_providers = ["${aws_ecs_capacity_provider.capacityProvider.name}"] ----This does not work

The error doesn't give any details, and just names some resources in my project.
Cycle: module.ecs_cluster.aws_launch_template.launchTemplate, module.ecs_cluster.aws_autoscaling_group.asg, module.ecs_cluster.aws_ecs_capacity_provider.capacityProvider, module.ecs_cluster.aws_ecs_cluster.ecsCluster, module.ecs_cluster.data.template_file.user_data

I'm seeing the same as @encryptblockr where name of capacity provider works but arn doesn't, yet the provider docs for ecs_cluster state:

capacity_providers - (Optional) List of short names or full Amazon Resource Names (ARNs) of one or more capacity providers to associate with the cluster. Valid values also include FARGATE and FARGATE_SPOT.

I was also able to confirm using the name instead of the arn worked for both capacity_providers and default_capacity_provider_strategy{capacity_provider}.

This appears to only be an issue with the Terraform documentation. The aws cli docs do not indicate the full arn can be used, but only the name of the capacity provider(s).

--capacity-providers (list)
The name of one or more capacity providers to associate with the cluster.

EDIT: I have found the source markdown and am working on a pull request to update the documentation.

This has been released in version 2.44.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks!

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!

Was this page helpful?
0 / 5 - 0 ratings