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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠