Can I use a Cloud Formation template in stack set which will spin up different resources in different regions?

0

I have created a Cloud formation template in which i am spinning up two ec2 instances, server and client both of these are in the same region for now. But now, my requirement is to host the client in one region and server in other region. What all changes do I need to do in my existing Cloud Formation template to achieve this if it's possible. I tried finding a sample template that I can leverage but unable to find it. To sum up:- Can I create a single template which would go inside the stack set and will deploy my client in one region and server in other region?

Thanks,

已提問 10 個月前檢視次數 775 次
3 個答案
1

Hi, yes, you can. You have a full sample here based on S3 buckets: https://www.cloudxs.ch/2021/02/deploy-into-multiple-aws-regions-with-cloudformation/

You will have to replace the bucket with an EC2 instance in your use case.

This lab may also help: https://www.wellarchitectedlabs.com/reliability/200_labs/200_deploy_and_update_cloudformation/6_multi_region_deploy/

Hope it helps! Didier

profile pictureAWS
專家
已回答 10 個月前
profile picture
專家
已審閱 10 個月前
  • Hi, I think I was unable to elaborate my concern to you. Let's take an example of the template you shared above. So, How can I create 2 s3 bucket, one in us-east-1 and other in us-west-1 with totally different objects inside them using stack set from a single template?

0

Short answer: you can't. I recommend you use two different templates in two regions and update them independently.

As AWS CloudFormation is a regional service, there is no direct way within a template to create AWS resources in different regions than the one you are creating the stack in. There are although alternative workarounds that add complexity to your deployment:

  • You may want to use AWS StackSet and using conditions in order to deploy the same template in two regions and filter based on the region it is deployed in.
  • You may want to use a custom lambda function to create the resources in another region.

Note that updating resources in multiple regions that depend on each other is considered an anti-pattern and cannot properly be orchestrated within AWS.

Baw
已回答 10 個月前
  • This is exactly what I did not want to hear, but anyways thanks for the suggestions.

0

You need to have a more elaborate solution to be able to achieve this combined with CF Stackset. What you are missing is an orchestration pipeline that can deploy stacks in various regions from a central place. these resources can give you an idea about the concept :

AWS
已回答 10 個月前
  • Well, I need to list my template in AWS marketplace, so am not sure how would this CI/CD pipeline would come into picture there. Had it been used by just me, I would have done the CI/CD way but am quite skeptical with AWS Marketplace.

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南