forked from AHinMaine/AWSCloudFormation-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEC2WithMetadata.template
53 lines (49 loc) · 2.47 KB
/
EC2WithMetadata.template
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template EC2WithMetadata: Create an Amazon EC2 instance running the Amazon Linux AMI. The Amazon EC2 instance has metadata attached, illustrating that meta data can be used to tag and instance with additonal information that can be accessed via the AWS CloudFormation command line or API. This example used the default security group, so to SSH to the new instance you will need to have port 22 open in your default security group. **WARNING** This template creates one or more Amazon EC2 instances. You will be billed for the AWS resources used if you create a stack from this template.",
"Mappings" : {
"RegionMap" : {
"us-east-1" : { "AMI" : "ami-7f418316" },
"us-west-1" : { "AMI" : "ami-951945d0" },
"us-west-2" : { "AMI" : "ami-16fd7026" },
"eu-west-1" : { "AMI" : "ami-24506250" },
"sa-east-1" : { "AMI" : "ami-3e3be423" },
"ap-southeast-1" : { "AMI" : "ami-74dda626" },
"ap-southeast-2" : { "AMI" : "ami-b3990e89" },
"ap-northeast-1" : { "AMI" : "ami-dcfa4edd" }
}
},
"Resources" : {
"Ec2Instance" : {
"Type" : "AWS::EC2::Instance",
"Metadata" : {
"Comment" : "This metadata is availabile via the cfn-describe-stack-resource command line tool, the DescribeStackResource API call or the cfn-get-metadata helper",
"MyAMI" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"MyRegion" : { "Ref" : "AWS::Region" },
"MyStack" : { "Ref" : "AWS::StackId" }
},
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "RegionMap", { "Ref" : "AWS::Region" }, "AMI" ]},
"UserData" : { "Fn::Base64" : "80" }
}
}
},
"Outputs" : {
"InstanceId" : {
"Description" : "InstanceId of the newly created EC2 instance",
"Value" : { "Ref" : "Ec2Instance" }
},
"AZ" : {
"Description" : "Availability Zone of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "AvailabilityZone" ] }
},
"PublicIP" : {
"Description" : "Public IP address of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PublicIp" ] }
},
"PrivateIP" : {
"Description" : "Private IP address of the newly created EC2 instance",
"Value" : { "Fn::GetAtt" : [ "Ec2Instance", "PrivateIp" ] }
}
}
}