#!/bin/bash
set -euo pipefail
# Approved Amazon Linux 2023 x86_64 AMI with SSM Agent and AWS CLI v2.
dnf install -y docker
systemctl enable --now docker amazon-ssm-agent
install -d -m 0700 /opt/three-tier
printf '%s' '${deploy}' | base64 -d > /opt/three-tier/deploy.py
printf '%s' '${config}' | base64 -d > /opt/three-tier/config.json
chmod 0600 /opt/three-tier/config.json
# Runtime deployment is performed after the separate owner-only migration.
printf '%s' '${service}' | base64 -d > /etc/systemd/system/three-tier.service
systemctl daemon-reload
