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 年前

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

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

回答問題指南