Reputation: 109
I'm just starting with CloudFormation. I'm trying to create 2 Windows EC2 instances with custom properties (VPCs, Security Groups, Subnet and tags. ), but I don't know how to set this up, I started with the standard AWS template and modified it but it fails.
{
"cxawsprodnew01": {
"Type": "AWS::EC2::Instance",
"DeletionPolicy": "Retain",
"Tags": [{ "tag": "" }],
"Properties": {
"ImageId": {
"Fn::FindInMap": ["WindowsRegionMap", { "Ref": "AWS::Region" }, "AMI"]
},
"InstanceType": "r4.large",
"InstanceInitiatedShutdownBehavior": "stop",
"DisableApiTermination": "true",
"VPCId": { "Type": "AWS::EC2::VPC::Id", "Ref": "vpc-9b34b5fd" },
"SubnetId": { "Ref": "VpcSubnet1" },
"SGUtilized": {
"Type": "AWS::EC2::SecurityGroup::Id",
"Ref": "ProdOctopusSG"
},
"BlockDeviceMappings": {
"DeviceName": "/dev/sda1",
"Ebs": {
"VolumeType": "standard",
"DeleteOnTermination": "false",
"VolumeSize": "50"
}
}
}
}
}
How can I modify this to allow me to add the properties that I need, no I have to set them first as parameters to invoke them?
Upvotes: 0
Views: 439
Reputation: 8583
yes you can declare the properties in the properties section and reference it.
{
"Properties": {
"VpcId": {
"Type": "WS::EC2::VPC::Id"
}
},
"Resources":
{
"cxawsprodnew01":
{
"Type": "AWS::EC2::Instance",
"DeletionPolicy": "Retain",
"Tags": [{ "" }],
"Properties":
{
...
"VPCId": { "Ref": "VpcId" },
....
},
},
},
}
Upvotes: 1