Instance Launch failure through Cloud Formation Template

0

Hello Team, I'm trying to launch an instance through CF template. However, I'm getting below error while launching: "Value of property SubnetId must be of type String" Steps Followed:

  1. Created a VPC CF template and defined "Outputs" in the template section as below:

Outputs:

PublicSubnet1: Description: Public Subnet 1 ID Export: Name: !Sub ${AWS::StackName}-PublicSubnet1 Value: !Ref PublicSubnet1

  1. Created an EC2 launch template and in "Resources" section , defined Subnet properties as follows: Properties: SubnetId: - Fn::ImportValue: !Sub ${ExportVpcStackName}-PublicSubnet1

Can anyone please advise what the reason for failure?

Thanks, Abhishek

質問済み 1年前260ビュー
1回答
0

Here is the example from the documentation:

Resources:
  WebServerInstance:
    Type: 'AWS::EC2::Instance'
    Properties:
      InstanceType: t2.micro
      ImageId: ami-a1b23456
      NetworkInterfaces:
        - GroupSet:
            - Fn::ImportValue: 
              'Fn::Sub': '${NetworkStackNameParameter}-SecurityGroupID'
          AssociatePublicIpAddress: 'true'
          DeviceIndex: '0'
          DeleteOnTermination: 'true'
          SubnetId: Fn::ImportValue 
            'Fn::Sub': '${NetworkStackNameParameter}-SubnetID'

It looks like you are presenting an array, '-', as the value to SubnetId.

profile pictureAWS
エキスパート
kentrad
回答済み 1年前

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

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

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

関連するコンテンツ