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

Very first creation of an ECS cluster fails #15452

Closed
vladimirtiukhtin opened this issue Oct 2, 2020 · 5 comments · Fixed by #15457
Closed

Very first creation of an ECS cluster fails #15452

vladimirtiukhtin opened this issue Oct 2, 2020 · 5 comments · Fixed by #15457
Labels
bug Addresses a defect in current functionality. service/ecs Issues and PRs that pertain to the ecs service.
Milestone

Comments

@vladimirtiukhtin
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 CLI and Terraform AWS Provider Version

Terraform v0.13.4
+ provider registry.terraform.io/hashicorp/aws v3.8.0

Affected Resource(s)

  • aws_ecs_cluster

Debug Output

Error: InvalidParameterException: Unable to assume the service linked role. Please verify that the ECS service linked role exists

Expected Behavior

Everything works from the first attempt

Actual Behavior

First attempt fails, further attempts pass

@ghost ghost added the service/ecs Issues and PRs that pertain to the ecs service. label Oct 2, 2020
@github-actions github-actions bot added the needs-triage Waiting for first response or review from a maintainer. label Oct 2, 2020
@bflad bflad added bug Addresses a defect in current functionality. and removed needs-triage Waiting for first response or review from a maintainer. labels Oct 2, 2020
@bflad
Copy link
Contributor

bflad commented Oct 2, 2020

Hi @vladimirtiukhtin 👋 Thank you for raising this. The ECS CreateCluster API reference does denote the IAM Service Linked Role behavior:

When you call the CreateCluster API operation, Amazon ECS attempts to create the Amazon ECS service-linked role for your account so that required resources in other AWS services can be managed on your behalf. However, if the IAM user that makes the call does not have permissions to create the service-linked role, it is not created. For more information, see Using Service-Linked Roles for Amazon ECS in the Amazon Elastic Container Service Developer Guide.

To lessen the occurrence of this issue in AWS accounts that have not provisioned ECS resources, we would recommend provisioning an aws_iam_service_linked_role resource in your Terraform configuration wherever appropriate for account-level resources. e.g.

resource "aws_iam_service_linked_role" "ecs" {
  aws_service_name = "ecs.amazonaws.com"
}

This may not fully mitigate the issue if its in the same configuration as the ECS Cluster provisioning as the new IAM Service Linked Role may not have propagated in time due to IAM's eventual consistency, however many Terraform configurations should already be split up appropriately between account-level and application-level configurations to make this beneficial until the resource can potentially be updated to retry around the CreateCluster call for this specific error.

bflad added a commit that referenced this issue Oct 2, 2020
…Role eventual consistency

Reference: #15452

Output from acceptance testing:

```
--- PASS: TestAccAWSEcsCluster_disappears (22.48s)
--- PASS: TestAccAWSEcsCluster_basic (27.36s)
--- PASS: TestAccAWSEcsCluster_Tags (46.73s)
--- PASS: TestAccAWSEcsCluster_CapacityProviders (49.40s)
--- PASS: TestAccAWSEcsCluster_CapacityProvidersNoStrategy (53.36s)
--- PASS: TestAccAWSEcsCluster_containerInsights (65.48s)
--- PASS: TestAccAWSEcsCluster_CapacityProvidersUpdate (83.87s)
--- PASS: TestAccAWSEcsCluster_SingleCapacityProvider (90.92s)
```
@bflad
Copy link
Contributor

bflad commented Oct 2, 2020

Submitted this PR which should fix the issue by retrying the CreateCluster call for this error: #15457

@bflad bflad added this to the v3.10.0 milestone Oct 7, 2020
bflad added a commit that referenced this issue Oct 7, 2020
…Role eventual consistency (#15457)

Reference: #15452

Output from acceptance testing:

```
--- PASS: TestAccAWSEcsCluster_disappears (22.48s)
--- PASS: TestAccAWSEcsCluster_basic (27.36s)
--- PASS: TestAccAWSEcsCluster_Tags (46.73s)
--- PASS: TestAccAWSEcsCluster_CapacityProviders (49.40s)
--- PASS: TestAccAWSEcsCluster_CapacityProvidersNoStrategy (53.36s)
--- PASS: TestAccAWSEcsCluster_containerInsights (65.48s)
--- PASS: TestAccAWSEcsCluster_CapacityProvidersUpdate (83.87s)
--- PASS: TestAccAWSEcsCluster_SingleCapacityProvider (90.92s)
```
@bflad
Copy link
Contributor

bflad commented Oct 7, 2020

The API retries for this has been merged and will release with version 3.10.0 of the Terraform AWS Provider, likely tomorrow. 👍

@ghost
Copy link

ghost commented Oct 9, 2020

This has been released in version 3.10.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!

@ghost
Copy link

ghost commented Nov 7, 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 Nov 7, 2020
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. service/ecs Issues and PRs that pertain to the ecs service.
Projects
None yet
2 participants