How to correcly name resources to avoid Custom Named Resource already exists in stack error for global resources

Viewed 41

I've created a CloudFormation template using Former2 and now I was trying to restore it. In my template I've defined some S3bucket, some Roles and lambda function.

I was wondering what's the correct practice to name resources.. I mean in my idea having a different account from the main one would lead the cloudformation to create the reources without any problem (as it happens with subscription in Azure), but in this case it's not..

Should I add a suffix as guid to every resource I use? what if after some period I had 30 different instances under the same main account? have each global one to have a uniquename?

I mean for example just if I have test/prod under the same account have I to postfix the resource with _test/_prod

1 Answers

Generally speaking, AWS does not provide isolation (or tenancy) like how Azure provides in Azure subscriptions. A detailed comparison of the same can be found here - Microsoft Doc.

As a best practice, AWS strongly recommends that you maintain different environments/workloads (dev, pre-prod, prod) of your application using separate accounts and manage them under one AWS Organisations account. [References - 1 & 2]

If for some reason you are unable to or do not want to manage different accounts for different environments/workloads, you will need to add proper prefixes or suffixes identifying the AWS resources as per the environment they belong to for Cloudformation to work!

Related