{
"schemaVersion": "2.2",
"description": "Check and update Apache to latest version",
"mainSteps": [
{
"action": "aws:runShellScript",
"name": "checkAndUpdateApache",
"inputs": {
"runCommand": [
"#!/bin/bash",
"CURRENT_VERSION=$(httpd -v | grep -oP 'Apache/\\\\K[0-9.]+')",
"yum check-update httpd -q | grep -q httpd",
"if [ $? -eq 0 ]; then",
" yum update httpd -y",
" systemctl restart httpd",
"fi"
]
}
}
]
}
aws ssm create-document \\
--name "UpdateApache" \\
--content file://update-apache.json \\
--document-type "Command"
aws ssm delete-document --name UpdateApache --region ap-northeast-2