Skip to content

Commit 3ff0724

Browse files
authored
Create deploy_eliza.yml
1 parent 3a6139d commit 3ff0724

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

aws/ssm/documents/deploy_eliza.yml

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
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"

0 commit comments

Comments
 (0)