1
1
AWSTemplateFormatVersion : 2010-09-09
2
2
Transform : AWS::Serverless-2016-10-31
3
- Description : Provision an instance of the Javabuilder service. Empty the ContentBucket before deleting this Stack .
3
+ Description : Provision an instance of the AI Proxy service .
4
4
Parameters :
5
5
BaseDomainName :
6
6
Type : String
7
7
Description : Base domain name (e.g. 'code.org' in 'aiproxy.code.org').
8
- # BaseDomainNameHostedZonedID:
9
- # Type: String
10
- # Description: AWS Route53 Hosted Zone ID for base domain name.
11
8
SubdomainName :
12
9
Type : String
13
- Description : Subdomain name for javabuilder service (e.g. 'javabuilder ' in 'javabuilder .code.org').
10
+ Description : Subdomain name for aiproxy service (e.g. 'aiproxy ' in 'aiproxy .code.org').
14
11
AppImageUri :
15
12
Type : String
16
13
Description : URI of the Docker image in ECR.
@@ -20,11 +17,27 @@ Parameters:
20
17
21
18
Resources :
22
19
20
+ # ------------------
21
+ # DNS
22
+ # ------------------
23
+
24
+ # Create a dedicated Hosted Zone for this environment
23
25
HostedZone :
24
26
Type : AWS::Route53::HostedZone
25
27
Properties :
26
28
Name : !Sub "${SubdomainName}.${BaseDomainName}."
27
29
30
+ # Make the Hosted Zone the authoritative DNS server for this subdomain
31
+ NSRecordSet :
32
+ Type : AWS::Route53::RecordSet
33
+ Properties :
34
+ HostedZone : code.org
35
+ Name : !Sub "${SubdomainName}.${BaseDomainName}."
36
+ Type : NS
37
+ TTL : 300
38
+ ResourceRecords :
39
+ - !GetAtt HostedZone.NameServers
40
+
28
41
Domain :
29
42
Type : AWS::Route53::RecordSet
30
43
Properties :
@@ -35,6 +48,10 @@ Resources:
35
48
DNSName : !GetAtt LoadBalancer.DNSName
36
49
HostedZoneId : !GetAtt LoadBalancer.CanonicalHostedZoneID
37
50
51
+ # ------------------
52
+ # Load Balancer
53
+ # ------------------
54
+
38
55
LoadBalancer :
39
56
Type : AWS::ElasticLoadBalancingV2::LoadBalancer
40
57
Properties :
@@ -47,20 +64,19 @@ Resources:
47
64
- !ImportValue VPC-PublicSubnetD
48
65
- !ImportValue VPC-PublicSubnetE
49
66
50
- LoadBalancerListener :
67
+ Listener :
51
68
Type : AWS::ElasticLoadBalancingV2::Listener
52
69
Properties :
53
70
DefaultActions :
54
71
- Type : forward
55
- TargetGroupArn : !Ref ECSTargetGroup
72
+ TargetGroupArn : !Ref TargetGroup
56
73
LoadBalancerArn : !Ref LoadBalancer
57
74
Port : 80
58
75
Protocol : HTTP
59
76
60
- ECSTargetGroup :
77
+ TargetGroup :
61
78
Type : AWS::ElasticLoadBalancingV2::TargetGroup
62
79
Properties :
63
- # TODO: This copies geocoder, but we should probably have a separate VPC for this service.
64
80
VpcId : !ImportValue VPC
65
81
Port : 80
66
82
TargetType : ip
@@ -72,12 +88,16 @@ Resources:
72
88
HealthyThresholdCount : 2
73
89
UnhealthyThresholdCount : 2
74
90
91
+ # ------------------
92
+ # ECS Service
93
+ # ------------------
94
+
75
95
ECSCluster :
76
96
Type : " AWS::ECS::Cluster"
77
97
78
98
ECSService :
79
99
Type : " AWS::ECS::Service"
80
- DependsOn : LoadBalancerListener
100
+ DependsOn : Listener
81
101
Properties :
82
102
Cluster : !Ref ECSCluster
83
103
DesiredCount : 1
@@ -95,7 +115,7 @@ Resources:
95
115
LoadBalancers :
96
116
- ContainerName : aiproxy
97
117
ContainerPort : 80
98
- TargetGroupArn : !Ref ECSTargetGroup
118
+ TargetGroupArn : !Ref TargetGroup
99
119
100
120
ECSSecurityGroup :
101
121
Type : AWS::EC2::SecurityGroup
@@ -134,12 +154,17 @@ Resources:
134
154
awslogs-region : !Ref AWS::Region
135
155
awslogs-stream-prefix : ecs
136
156
157
+ # ------------------
158
+ # Logging & Alerts
159
+ # ------------------
160
+
137
161
LogGroup :
138
162
Type : AWS::Logs::LogGroup
139
163
Properties :
140
164
LogGroupName : !Sub "${AWS::StackName}"
141
165
142
166
Outputs :
143
- AiProxyURL :
144
- Value :
145
- !Ref Domain
167
+ URL :
168
+ Value : !Ref Domain
169
+ Export :
170
+ Name : !Sub "${AWS::StackName}-URL"
0 commit comments