copilot-cli icon indicating copy to clipboard operation
copilot-cli copied to clipboard

Env init fails if cloudformation template already exists with a conflicting name

Open ledburyb opened this issue 4 years ago • 12 comments

copilot env init was failing for me and returning the error:

✘ Failed to link account <account-id> and region eu-west-1 to application <application-name>.

This left the environment in a bad state and copilot env delete would then also not complete with the error:

find service cloudformation stacks: InvalidParameter: 1 validation error(s) found.
- minimum field size of 20, AssumeRoleInput.RoleArn.

I spotted that we already had a stack with the same name as it was trying to create (created by Serverless framework) so I believe this was the cause. I created a new app with a different non-conflicting name and was able to init the environment.

ledburyb avatar Aug 19 '21 11:08 ledburyb

Hi @ledburyb !

Thank you so much for getting to the bottom of this issue! I wonder if we can error out earlier if we detect that there is a stack that's already created but not managed by copilot 💭

efekarakus avatar Aug 20 '21 00:08 efekarakus

A simple error message would certainly have caused less confusion for me. I would probably also consider using namespaces or generated names for anything copilot creates to reduce the chance of collision.

ledburyb avatar Aug 20 '21 06:08 ledburyb

I have this problem

✘ Failed to link account 'myaccount' and region us-west-2 to application 'myapplication'.

✘ deploy env test to application 'myapplication': adding test environment resources to application: operation 70 for stack set cx-infrastructure failed

I don't know to resolve this issue.

grassiricardo avatar Nov 10 '21 00:11 grassiricardo

Hello @grassiricardo. That's probably because you have a stackset instance that's in delete-failed state. Could you go to the CloudFormation console to remove it and try it again? Related comment to recover the app: https://github.com/aws/copilot-cli/issues/2880#issuecomment-930644757

iamhopaul123 avatar Nov 10 '21 00:11 iamhopaul123

Hello @iamhopaul123. I don't understand this comment #2880. Can you help me please?

grassiricardo avatar Nov 10 '21 00:11 grassiricardo

Hello @grassiricardo. Can you go to CFN console to see if you have a stack with the name like StackSet-myapplication-infrastructure-xxxx failed to delete?

iamhopaul123 avatar Nov 10 '21 01:11 iamhopaul123

This? @iamhopaul123 image

grassiricardo avatar Nov 10 '21 01:11 grassiricardo

Yeah that's the stack instance (stack instance is the stack created by stackset and you can take stackset as a template) from the stackset console. Could you go to the stack console to see the current status of the stack? For example:

Screen Shot 2021-11-10 at 12 57 16 PM

iamhopaul123 avatar Nov 10 '21 19:11 iamhopaul123

@iamhopaul123 I have this problem. Can you help me?

image

grassiricardo avatar Feb 21 '22 14:02 grassiricardo

Hello @grassiricardo sorry it seems like we don't emit a very helpful error message here. I asked the ECR team and they wondered if the ecr:CreateRepository is available for creating this repo?

iamhopaul123 avatar Feb 21 '22 18:02 iamhopaul123

I feel that erroring on existing stack name would be a decent enhancement.

Background: I am migrating applications from AWS SAM and encountering name collisions. In the meantime, I'll just prefix the app name.

Thanks!

matthewhembree avatar Apr 04 '22 19:04 matthewhembree

@iamhopaul123 really exists other ECR and my problem is this. For me, closed this issue. Thanks for your support.

grassiricardo avatar May 17 '22 12:05 grassiricardo