@@ -56,6 +56,14 @@ Parameters:
5656 Type : Number
5757 Default : 32
5858
59+ AllowedIpAddress :
60+ Description : The IP address range that can be used to SSH to instance and Connect to DCV
61+ Type : String
62+ MinLength : " 9"
63+ MaxLength : " 18"
64+ Default : 0.0.0.0/0
65+ AllowedPattern : (\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})/(\d{1,2})
66+ ConstraintDescription : must be a valid IP CIDR range of the form x.x.x.x/x.
5967
6068Conditions :
6169 IamPolicyEmpty : !Equals [!Ref IamPolicyDocument, "{}"]
@@ -126,6 +134,9 @@ Resources:
126134 ManagedPolicyArns :
127135 - Ref : SSMPolicy
128136 PermissionsBoundary : !Ref InstanceRolePermissionBoundary
137+
138+
139+
129140 InstanceProfile :
130141 Type : " AWS::IAM::InstanceProfile"
131142 Properties :
@@ -153,7 +164,7 @@ Resources:
153164 Type : AWS::EC2::Instance
154165 CreationPolicy :
155166 ResourceSignal :
156- Timeout : PT20M
167+ Timeout : PT15M
157168 Metadata :
158169 AWS::CloudFormation::Init :
159170 configSets :
@@ -255,10 +266,10 @@ Resources:
255266 content : !Sub |
256267 #!/bin/sh
257268 set -x
258- sleep 120
269+ sleep 25
259270 export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$(pgrep mate-session)/environ|cut -d= -f2- | tr -d '\0')
260271 gsettings set org.mate.interface gtk-theme "Graphite-Light"
261- gsettings set org.mate.background picture-filename "/home/ec2-user/Graphite-gtk-theme-main/wallpaper/Graphite/wave-color.png"
272+ gsettings set org.mate.background picture-filename "/home/ec2-user/Graphite-gtk-theme-main/wallpaper/Graphite/wave-color.png"
262273 config2 :
263274 commands :
264275 01_start_ext_auth :
@@ -267,7 +278,6 @@ Resources:
267278 02_set_user_token :
268279 cwd : " /home/ec2-user"
269280 command : " /home/ec2-user/set_user_token.sh"
270-
271281 Properties :
272282 UserData :
273283 Fn::Base64 : !Sub |
@@ -277,11 +287,12 @@ Resources:
277287
278288 # Copy environment instance files needed for the workspace
279289 aws s3 cp --region "${AWS::Region}" "${EnvironmentInstanceFiles}/secure_desktop/secure_desktop.perm" "/etc/dcv/"
280-
281- # Download and execute bootstrap script
282290 aws s3 cp --region "${AWS::Region}" "${EnvironmentInstanceFiles}/get_bootstrap.sh" "/tmp"
283291 chmod 500 "/tmp/get_bootstrap.sh"
284- /tmp/get_bootstrap.sh "${EnvironmentInstanceFiles}" '${S3Mounts}' "${AWS::Region}"
292+ /tmp/get_bootstrap.sh "${EnvironmentInstanceFiles}" '${S3Mounts}' "" "${AWS::Region}"
293+
294+ # Install supervisor and start on boot
295+ # pip3 install supervisor crudini
285296
286297 # Route auth request to external authenticator and restart dcv
287298 /usr/local/bin/crudini --set /etc/dcv/dcv.conf security auth-token-verifier \"http://127.0.0.1:8445\"
@@ -290,7 +301,6 @@ Resources:
290301
291302 # Create dcv session start script
292303 cat << EOF > /usr/local/bin/start-dcv-session
293- sleep 15
294304 dcv create-session rg-session --name rg-session --user ec2-user --owner ec2-user --permissions-file /etc/dcv/secure_desktop.perm
295305 EOF
296306
@@ -299,6 +309,8 @@ Resources:
299309 chmod 775 "/usr/local/bin/start-dcv-session"
300310 sh "/usr/local/bin/start-dcv-session"
301311
312+ sleep 5
313+
302314 # Run init script to create files
303315 /opt/aws/bin/cfn-init --verbose --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
304316
@@ -309,17 +321,17 @@ Resources:
309321 echo '@reboot /usr/local/bin/start-dcv-session 2>&1 >> /var/log/start-dcv-session.log' >> "/tmp/crontab"
310322 echo '@reboot /home/ec2-user/set_user_token.sh 2>&1 >> /var/log/set_user_token.log' >> "/tmp/crontab"
311323 crontab "/tmp/crontab"
312-
313324 # Restart DCV session to start dcv-session
314325 dcv close-session rg-session
315326 sh "/usr/local/bin/start-dcv-session"
316327
317328 # Remove password and lock for ec2-user
318329 passwd -l ec2-user
319330 dcv create-session lock-session --name lock-session --user ec2-user --owner ec2-user --init /home/ec2-user/disable_lock.sh
320-
321331 sudo -u ec2-user /home/ec2-user/themes.sh
322332
333+
334+
323335 /opt/aws/bin/cfn-signal -e $? --stack ${AWS::StackName} --resource EC2Instance --region ${AWS::Region}
324336
325337 InstanceType : !Ref "InstanceType"
@@ -370,6 +382,7 @@ Outputs:
370382 InstanceId :
371383 Description : InstanceId of the newly created EC2 instance
372384 Value : !Ref "EC2Instance"
385+
373386 ApplicationPort :
374387 Description : The Port in which the application is running
375388 Value : " 8443"
0 commit comments