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

Check to see if a Project exists globally before creating it #815

Open
kohidave opened this issue Apr 6, 2020 · 0 comments
Open

Check to see if a Project exists globally before creating it #815

kohidave opened this issue Apr 6, 2020 · 0 comments

Comments

@kohidave
Copy link
Contributor

@kohidave kohidave commented Apr 6, 2020

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-proj in us-east-1, then run ecs-preview project init my-proj in us-west-2 - the second init should fail.

That currently happens - but the error you get is pretty gross:

Error: execute project init: describe change set ecscli-d2d6af69-9a90-4269-bbaa-204f6e7638b9 for stack codenames-infrastructure-roles: ChangeSetNotFound: ChangeSet [ecscli-d2d6af69-9a90-4269-bbaa-204f6e7638b9] does not exist
	status code: 404, request id: ca14ed0a-aa2d-4d7b-bc54-1a20626d8b06

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.

Follow Lee on X/Twitter - Father, Husband, Serial builder creating AI, crypto, games & web tools. We are friends :) AI Will Come To Life!

Check out: eBank.nz (Art Generator) | Netwrck.com (AI Tools) | Text-Generator.io (AI API) | BitBank.nz (Crypto AI) | ReadingTime (Kids Reading) | RewordGame | BigMultiplayerChess | WebFiddle | How.nz | Helix AI Assistant