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

preguntada hace un año260 visualizaciones
1 Respuesta
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
EXPERTO
kentrad
respondido hace un año

No has iniciado sesión. Iniciar sesión para publicar una respuesta.

Una buena respuesta responde claramente a la pregunta, proporciona comentarios constructivos y fomenta el crecimiento profesional en la persona que hace la pregunta.

Pautas para responder preguntas