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ヶ月前1148ビュー
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ヶ月前

ログインしていません。 ログイン 回答を投稿する。

優れた回答とは、質問に明確に答え、建設的なフィードバックを提供し、質問者の専門分野におけるスキルの向上を促すものです。

質問に答えるためのガイドライン

関連するコンテンツ