{ "Description": "This stack automates the creation of an EC2 Elastic IP\nand associates it to an EC2 instance\n", "Parameters": { "LatestAmiId": { "Description": "Region specific image from the Parameter Store", "Type": "AWS::SSM::Parameter::Value", "Default": "/aws/service/ami-amazon-linux-latest/amzn2-ami-hvm-x86_64-gp2" }, "Subnet": { "Description": "The subnet to put the instance into", "Type": "AWS::EC2::Subnet::Id" } }, "Resources": { "IamRole": { "Type": "AWS::IAM::Role", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Effect": "Allow", "Principal": { "Service": [ "ec2.amazonaws.com" ] }, "Actions": [ "sts:AssumeRole" ] } ] }, "Path": "/" } }, "IamProfile": { "Type": "AWS::IAM::InstanceProfile", "Properties": { "Roles": [ { "Ref": "IamRole" } ], "Path": "/" } }, "Instance": { "Type": "AWS::EC2::Instance", "Properties": { "ImageId": { "Ref": "LatestAmiId" }, "SubnetId": { "Ref": "Subnet" }, "Monitoring": true, "IamInstanceProfile": { "Ref": "IamProfile" }, "EbsOptimized": true } }, "Eip": { "Type": "AWS::EC2::EIP", "Properties": { "InstanceId": { "Ref": "Instance" } } } } }