'Getting cloud formation error Value of property InstanceId must be of type String while attaching eip with ec2
AWSTemplateFormatVersion: '2010-09-09'
Resources:
DevEC2Instance:
Type: AWS::EC2::Instance
Properties:
InstanceType: t2.micro
ImageId: ami-0e322da50e0e90e21
KeyName: "cnf-key-1"
SecurityGroups:
- default
- Ref: SSHSecurityGroup
SSHSecurityGroup:
Type: AWS::EC2::SecurityGroup
Properties:
GroupDescription: my new SSH SG
SecurityGroupIngress:
- IpProtocol: tcp
FromPort: '22'
ToPort: '22'
CidrIp: 0.0.0.0/0
- IpProtocol: tcp
FromPort: '8080'
ToPort: '8080'
CidrIp: 0.0.0.0/0
MyElasticIP:
Type: AWS::EC2::EIP
Properties:
InstanceId:
- Ref: 'DevEC2Instance'
Solution 1:[1]
Due to - you are creating a list. Instead it should be:
MyElasticIP:
Type: AWS::EC2::EIP
Properties:
InstanceId: !Ref DevEC2Instance
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Marcin |
