@@ -130,7 +130,7 @@ Metadata:
130
130
enableCloudFront :
131
131
default : " Create Amazon CloudFront distribution"
132
132
originType :
133
- default : " Orign type"
133
+ default : " CloudFront origin type"
134
134
135
135
Parameters :
136
136
processorArchitecture :
@@ -147,16 +147,18 @@ Parameters:
147
147
Default : Amazon Linux 2023
148
148
ec2KeyPair :
149
149
Type : AWS::EC2::KeyPair::KeyName
150
- Description : " https://console.aws.amazon.com/ec2/#KeyPairs"
150
+ Description : https://console.aws.amazon.com/ec2/#KeyPairs
151
151
ConstraintDescription : Specify a key pair
152
152
AllowedPattern : " .+"
153
153
instanceType :
154
154
Type : String
155
- Description : " https://console.aws.amazon.com/ec2/#InstanceTypes"
155
+ Description : https://console.aws.amazon.com/ec2/#InstanceTypes
156
+ AllowedPattern : " ^[a-z\\ -\\ d\\ .]+$"
157
+ ConstraintDescription : Specify valid EC2 instance type
156
158
Default : t4g.xlarge
157
159
ec2TerminationProtection :
158
160
Type : String
159
- Description : " https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_ChangingDisableAPITermination.html"
161
+ Description : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Using_ChangingDisableAPITermination.html
160
162
Default : " Yes"
161
163
AllowedValues :
162
164
- " Yes"
@@ -165,13 +167,13 @@ Parameters:
165
167
vpcID :
166
168
Type : AWS::EC2::VPC::Id
167
169
Description : " https://console.aws.amazon.com/vpcconsole/home#vpcs:"
168
- ConstraintDescription : Specify a valid value
169
- AllowedPattern : " .+ "
170
+ AllowedPattern : .+
171
+ ConstraintDescription : Select a VPC
170
172
subnetID :
171
173
Type : AWS::EC2::Subnet::Id
172
174
Description : " https://console.aws.amazon.com/vpcconsole/home#subnets:"
173
- ConstraintDescription : Specify a valid value
174
- AllowedPattern : " .+ "
175
+ AllowedPattern : .+
176
+ ConstraintDescription : Select a Subnet
175
177
assignStaticIP :
176
178
Type : String
177
179
Description : " https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/elastic-ip-addresses-eip.html"
@@ -181,23 +183,27 @@ Parameters:
181
183
Default : " Yes"
182
184
displayPublicIP :
183
185
Type : String
184
- Description : " https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#concepts- public-addresses "
186
+ Description : Select No if EC2 has no public IP
185
187
AllowedValues :
186
188
- " Yes"
187
189
- " No"
188
190
Default : " Yes"
189
191
190
192
ingressIPv4 :
191
193
Type : String
192
- Description : " e.g. 1.2.3.4/32, get your source IP from https://checkip.amazonaws.com "
194
+ Description : e.g. 1.2.3.4/32, get your source IP from https://checkip.amazonaws.com
195
+ AllowedPattern : " ^\\ d+\\ .\\ d+\\ .\\ d+\\ .\\ d+\\ /\\ d+$"
196
+ ConstraintDescription : Specify valid IPv4 prefix
193
197
Default : 0.0.0.0/0
194
198
ingressIPv6 :
195
199
Type : String
196
- Description : " https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-instance-addressing.html#ipv6-addressing"
200
+ Description : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/working-with-ipv6-addresses.html
201
+ AllowedPattern : .+
202
+ ConstraintDescription : Specify valid IPv6 prefix
197
203
Default : ::/0
198
204
allowSSHport :
199
205
Type : String
200
- # Description: Allow SSH from internet
206
+ Description : https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/connect-linux-inst-ssh.html
201
207
AllowedValues :
202
208
- " Yes"
203
209
- " No"
@@ -242,7 +248,7 @@ Parameters:
242
248
Default : " "
243
249
r53ZoneID :
244
250
Type : String
245
- Description : " https://console.aws.amazon.com/route53/v2/ hostedzones"
251
+ Description : https://console.aws.amazon.com/route53/hostedzones https://certbot-dns-route53.readthedocs.io/
246
252
Default : " "
247
253
248
254
volumeSize :
@@ -261,17 +267,19 @@ Parameters:
261
267
262
268
enableBackup :
263
269
Type : String
270
+ Description : https://docs.aws.amazon.com/aws-backup/
264
271
AllowedValues :
265
272
- " Yes"
266
273
- " No"
267
274
Default : " Yes"
268
275
scheduleExpression :
269
276
Type : String
270
- Description : https://en.wikipedia.org/wiki/Cron#CRON_expression
271
- AllowedPattern : " .+ "
277
+ Description : https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html
278
+ AllowedPattern : .+
272
279
Default : " cron(0 1 ? * * *)"
273
280
scheduleExpressionTimezone : # https://nodatime.org/TimeZones?version=2024a&format=json
274
281
Type : String
282
+ Description : https://docs.aws.amazon.com/scheduler/latest/UserGuide/schedule-types.html#time-zones
275
283
AllowedValues :
276
284
- Africa/Abidjan
277
285
- Africa/Algiers
@@ -631,7 +639,7 @@ Parameters:
631
639
632
640
installDocker :
633
641
Type : String
634
- # Description: Install Docker
642
+ Description : https://docs.docker.com/engine/
635
643
AllowedValues :
636
644
- " Yes"
637
645
- " No"
@@ -1187,16 +1195,22 @@ Resources:
1187
1195
" /opt/dcv-post-reboot.sh " :
1188
1196
content : !Sub |
1189
1197
#!/bin/bash
1190
- sysctl -w net.ipv6.conf.all.disable_ipv6=1
1191
- sysctl -w net.ipv6.conf.default.disable_ipv6=1
1198
+ # sysctl -w net.ipv6.conf.all.disable_ipv6=1
1199
+ # sysctl -w net.ipv6.conf.default.disable_ipv6=1
1192
1200
1193
1201
/opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource ec2Instance --region ${AWS::Region}
1194
1202
1195
1203
dnf update -q -y
1196
1204
1197
- sysctl -w net.ipv6.conf.all.disable_ipv6=0
1198
- sysctl -w net.ipv6.conf.default.disable_ipv6=0
1205
+ # https://docs.aws.amazon.com/linux/al2023/ug/managing-repos-os-updates.html#automatic-restart-services
1206
+ dnf install -q -y smart-restart
1207
+ touch /etc/smart-restart-conf.d/0-pre-restart
1208
+ chmod +x /etc/smart-restart-conf.d/0-pre-restart
1209
+ touch /etc/smart-restart-conf.d/0-post-restart
1210
+ chmod +x /etc/smart-restart-conf.d/0-post-restart
1199
1211
1212
+ #sysctl -w net.ipv6.conf.all.disable_ipv6=0
1213
+ #sysctl -w net.ipv6.conf.default.disable_ipv6=0
1200
1214
1201
1215
rm -f /etc/systemd/system/dcv-post-reboot.service
1202
1216
rm -f ${!0}
@@ -1253,7 +1267,7 @@ Resources:
1253
1267
1254
1268
# Update OS
1255
1269
dnf update -q -y
1256
- sleep 15
1270
+ sleep 10
1257
1271
1258
1272
# AWS CLI
1259
1273
echo "export AWS_CLI_AUTO_PROMPT=on-partial" >> /home/ec2-user/.bashrc
@@ -1266,8 +1280,6 @@ Resources:
1266
1280
1267
1281
# https://docs.aws.amazon.com/linux/al2023/ug/deterministic-upgrades-usage.html#deterministic-upgrade-override-persist
1268
1282
echo latest | sudo tee /etc/dnf/vars/releasever
1269
- # https://docs.aws.amazon.com/linux/al2023/ug/managing-repos-os-updates.html#automatic-restart-services
1270
- dnf install -q -y smart-restart
1271
1283
1272
1284
# CloudWatch agent: https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/install-CloudWatch-Agent-on-EC2-Instance.html
1273
1285
dnf install -q -y amazon-cloudwatch-agent
@@ -1769,8 +1781,8 @@ Resources:
1769
1781
cd /tmp/cfn
1770
1782
1771
1783
# disable IPv6 during setup
1772
- sysctl -w net.ipv6.conf.all.disable_ipv6=1
1773
- sysctl -w net.ipv6.conf.default.disable_ipv6=1
1784
+ # sysctl -w net.ipv6.conf.all.disable_ipv6=1
1785
+ # sysctl -w net.ipv6.conf.default.disable_ipv6=1
1774
1786
1775
1787
dnf clean all
1776
1788
dnf install -q -y wget tmux unzip tar curl-minimal sed
@@ -1793,8 +1805,8 @@ Resources:
1793
1805
systemctl enable dcv-post-reboot
1794
1806
1795
1807
# enable back IPv6
1796
- sysctl -w net.ipv6.conf.all.disable_ipv6=0
1797
- sysctl -w net.ipv6.conf.default.disable_ipv6=0
1808
+ # sysctl -w net.ipv6.conf.all.disable_ipv6=0
1809
+ # sysctl -w net.ipv6.conf.default.disable_ipv6=0
1798
1810
1799
1811
sleep 1 && reboot
1800
1812
Tags :
@@ -2004,6 +2016,12 @@ Outputs:
2004
2016
Description : EC2 Serial Console
2005
2017
Value : !Sub "https://${AWS::Region}.console.aws.amazon.com/ec2-instance-connect/ssh?&connType=serial&instanceId=${ec2Instance}&serialPort=0#/"
2006
2018
2019
+ EC2iamRole :
2020
+ Description : EC2 IAM role
2021
+ Value : !Sub
2022
+ - " https://console.aws.amazon.com/iam/home#/roles/details/${role}"
2023
+ - role : !Select [1, !Split ["/", !GetAtt instanceIamRole.Arn]]
2024
+
2007
2025
SSMsessionManager :
2008
2026
Description : SSM Session Manager
2009
2027
Value : !Sub "https://${AWS::Region}.console.aws.amazon.com/systems-manager/session-manager/${ec2Instance}"
0 commit comments