Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upCheck to see if a Project exists globally before creating it #815
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Problem
Right now project configuration is mastered in a particular region - whichever region the default profile is configured with.
Project names, however, have to be unique within the account, across regions - mostly to reduce the confusion of working on two projects named the same thing, in different regions.
In order to enforce this restriction right now - we create the project admin role as the name of the project.
https://github.com/aws/amazon-ecs-cli-v2/blob/master/templates/project/project.yml#L29
So for example, if you run
ecs-preview project init my-projinus-east-1, then runecs-preview project init my-projinus-west-2- the second init should fail.That currently happens - but the error you get is pretty gross:
This happens because CloudFormation can't create two roles with the same name since roles are global.
Fix
To fix this, we should check to see if the admin role exists already (which is of the form
{project-name}-adminrole).In the project deploy code:
https://github.com/aws/amazon-ecs-cli-v2/blob/master/internal/pkg/deploy/cloudformation/project.go#L30
We can add a check which calls fetches
StackSetAdminRoleARN()from the stack object, calls IAM (via GetRole) to see if it exists, and if it does returns an error.