File tree 1 file changed +36
-0
lines changed
1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ schemaVersion : " 2.2"
3
+ description : " SSM document to update Docker container on EC2"
4
+ parameters :
5
+ ImageParameterName :
6
+ description : " SSM parameter name for Docker image"
7
+ type : " String"
8
+ ConfigParameterName :
9
+ description : " SSM parameter name for app configuration"
10
+ type : " String"
11
+ mainSteps :
12
+ - inputs :
13
+ runCommand :
14
+ - " #!/bin/bash"
15
+ - " set -e"
16
+ - " IMAGE_NAME=$(aws ssm get-parameter --name {{ ImageParameterName }} --query\
17
+ \ \" Parameter.Value\" --output text)"
18
+ - " CONFIG=$(aws ssm get-parameter --name {{ ConfigParameterName }} --with-decryption\
19
+ \ --query \" Parameter.Value\" --output text)"
20
+ - " echo \" $CONFIG\" > /tmp/app_config.json"
21
+ - " docker pull $IMAGE_NAME"
22
+ - " docker stop app_container || true"
23
+ - " docker rm app_container || true"
24
+ - " docker run -d --name app_container -v /tmp/app_config.json:/app/config.json\
25
+ \ $IMAGE_NAME"
26
+ name : " UpdateDockerContainer"
27
+ action : " aws:runShellScript"
28
+ - inputs :
29
+ runCommand :
30
+ - " #!/bin/bash"
31
+ - " if [ $? -ne 0 ]; then"
32
+ - " echo \" Error occurred during container update\" >> /var/log/container_update_errors.log"
33
+ - " docker logs app_container >> /var/log/container_update_errors.log"
34
+ - " fi"
35
+ name : " CaptureErrors"
36
+ action : " aws:runShellScript"
You can’t perform that action at this time.
0 commit comments