/
ApiServiceDeploy2.json
124 lines (118 loc) · 4.25 KB
/
ApiServiceDeploy2.json
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
{
"Parameters" : {
"KeyName" : {
"Type" : "AWS::EC2::KeyPair::KeyName",
"Description" : "Key used to launch the instance"
},
"AvailabilityZones" : {
"Type" : "AWS::EC2::AvailabilityZone::Name",
"Description" : "Where to launch the instance"
},
"VPC" : {
"Type" : "String",
"Description" : "Which VPC to deploy?",
"Default" : "vpc-663c9c03"
},
"InstanceType" : {
"Type" : "String",
"Description" : "Instance type to use?",
"Default" : "t2.micro",
"AllowedValues" : [ "t2.micro", "m1.small" ]
}
},
"Mappings" : {
"SupportedRegions" : {
"eu-west-1" : {
"AMI" : "ami-751fb006"
}
}
},
"Resources" : {
"S3FullAccessRole" : {
"Type" : "AWS::IAM::Role",
"Properties" : {
"AssumeRolePolicyDocument" : {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [ "sts:AssumeRole" ],
"Principal": {"Service": "ec2.amazonaws.com"}
}
]
},
"Path" : "/",
"Policies" : [{
"PolicyName" : "S3",
"PolicyDocument" : {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:*",
"Resource": "*"
}
]
}
}]
}
},
"InstanceProfileRoleInfo" : {
"Type" : "AWS::IAM::InstanceProfile",
"Properties" : {
"Path" : "/",
"Roles" : [{ "Ref" : "S3FullAccessRole" }]
}
},
"InstanceSecurityGroup" : {
"Type" : "AWS::EC2::SecurityGroup",
"Properties" : {
"GroupDescription" : "Security group for simple api service",
"SecurityGroupIngress" : [{
"CidrIp" : "0.0.0.0/0",
"FromPort" : 3389,
"IpProtocol" : "tcp",
"ToPort" : "3389"
}, {
"CidrIp" : "0.0.0.0/0",
"FromPort" : 88,
"IpProtocol" : "tcp",
"ToPort" : "88"
}],
"VpcId" : { "Ref" : "VPC" }
}
},
"ApiServiceInstance" : {
"Type" : "AWS::EC2::Instance",
"Properties" : {
"ImageId" : { "Fn::FindInMap" : [ "SupportedRegions", { "Ref" : "AWS::Region" }, "AMI" ] },
"InstanceType" : { "Ref" : "InstanceType" },
"KeyName" : { "Ref" : "KeyName" },
"AvailabilityZone" : { "Ref" : "AvailabilityZones" },
"SecurityGroupIds" : [ { "Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ] } ],
"IamInstanceProfile" : { "Ref" : "InstanceProfileRoleInfo" },
"UserData" : { "Fn::Base64" : { "Fn::Join" : [ "", [
"<powershell>\n",
"aws s3 cp s3://simpleapistartup/ c://deployment/ --recursive\n",
"cd c:\\Deployment\n",
".\\ApiService.deploy.cmd /Y -enableRule:DoNotDelete\n",
"</powershell>" ]] } }
}
}
},
"Outputs" : {
"ServiceEndPoint" : {
"Description" : "Service endpoint",
"Value" : { "Fn::Join" : [ "", [
"http://",
{ "Fn::GetAtt" : [ "ApiServiceInstance", "PublicDnsName" ] },
":88",
"/api",
"/products"]] }
},
"SecurityGroupId" : {
"Description" : "Group Id of the security group",
"Value" : { "Fn::GetAtt" : [ "InstanceSecurityGroup", "GroupId" ] }
}
}
}