Instantiate multiple EC2 instances using AWS Cloud Formation Template.

1

Hi there, I have a use-case, where I want to instantiate variable number of EC2 instances depending on the input provided by the user. for ex: If user provided 3 as input then 3 Ec2 instances should be instantiated and so on.

Please guide me here, I am stuck with this for few days now.

thanks in advance!

질문됨 9달 전1130회 조회
2개 답변
1

You can try this way, but I think there is more elegant solution:

AWSTemplateFormatVersion: "2010-09-09"
Transform: AWS::LanguageExtensions

Parameters:
    InstanceList:
        Type: CommaDelimitedList

Resources:
  Fn::ForEach::Instances:
    - InstanceLogicalId
    - !Ref InstanceList
    - ${InstanceLogicalId}:
        Type: AWS::EC2::Instance
        Properties:
          ImageId: ami-0ed752ea0f62749af
          InstanceType: t2.micro

Then in a console just type the name of logical id, like:

 instance1 - will create one instance
 instance1, instance2, instance3 - will create three instances
profile picture
답변함 9달 전
profile pictureAWS
전문가
kentrad
검토됨 9달 전
0

You can also do this with Count -macro. There were some issues using parameters with Count attribute but based on comments those shound have been fixed.

profile picture
전문가
Kallu
답변함 9달 전

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

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

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

관련 콘텐츠