Created
April 22, 2020 09:43
-
-
Save tatat/ad313d82c8200b889ce86f70abd25283 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
_puts() { | |
echo "$1" >&2 | |
} | |
# NOTE: https://docs.aws.amazon.com/ja_jp/systems-manager/latest/userguide/getting-started-configure-preferences-cli.html | |
ssm_configuration="$( | |
cat <<EOS | sed "s/__SESSION_LOGS_BUCKET__/$SESSION_LOGS_BUCKET/g" | |
{ | |
"schemaVersion": "1.0", | |
"description": "Document to hold regional settings for Session Manager", | |
"sessionType": "Standard_Stream", | |
"inputs": { | |
"s3BucketName": "__SESSION_LOGS_BUCKET__", | |
"s3KeyPrefix": "ssm/", | |
"s3EncryptionEnabled": true, | |
"cloudWatchLogGroupName": "", | |
"cloudWatchEncryptionEnabled": false | |
} | |
} | |
EOS | |
)" | |
_puts "info: update ssm configuration." | |
aws ssm update-document \ | |
--name "SSM-SessionManagerRunShell" \ | |
--content "$ssm_configuration" \ | |
--document-version "\$LATEST" | |
if [[ $? != 0 ]]; then | |
_puts "error: failed to update ssm configuration." | |
exit 1 | |
else | |
_puts "info: updated ssm configuration." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment