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
# Given environment variables of INSTANCE_PROFILE and INSTANCE_ROLE, this will create the profile, | |
# swap out the role, remove the role, add the role to make sure at the end, INSTANCE_PROFILE contains | |
# one and only one role, INSTANCE_ROLE | |
if aws iam get-instance-profile --instance-profile-name "${INSTANCE_PROFILE}" ; then | |
echo "Profile already exists. Checking instance profile..." | |
OLD_ROLE="$(aws iam get-instance-profile --instance-profile-name $INSTANCE_PROFILE | ./jq.dms -r '.InstanceProfile.Roles[0].RoleName')" | |
if [ "${OLD_ROLE}" = "null" ] || [ -z "${OLD_ROLE}" ] ; then | |
OLD_ROLE=none | |
fi | |
if [ "${INSTANCE_ROLE}" = "${OLD_ROLE}" ] ; then |
NewerOlder