AWS code-library documentation change
Summary
Modified AWS CLI examples to generate unique resource names, set default region, and automate cleanup choices
Security assessment
Changes focus on usability improvements: 1) Added unique ID generation prevents naming conflicts but doesn't address security vulnerabilities 2) Default region fallback improves reliability 3) Automated cleanup choice simplifies scripting. No evidence of patching vulnerabilities or addressing security incidents.
Diff
diff --git a/code-library/latest/ug/sts_example_iam_GettingStarted_046_section.md b/code-library/latest/ug/sts_example_iam_GettingStarted_046_section.md index db06863fb..94954cf93 100644 --- a//code-library/latest/ug/sts_example_iam_GettingStarted_046_section.md +++ b//code-library/latest/ug/sts_example_iam_GettingStarted_046_section.md @@ -47,0 +48 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + UNIQUE_ID=$(openssl rand -hex 4) @@ -153 +154 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - read -r CURRENT_REGION + CURRENT_REGION="${AWS_DEFAULT_REGION:-us-west-2}" @@ -408 +409 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - POLICY_OUTPUT=$(log_cmd "aws iam create-policy --policy-name SSMOnboardingPolicy --policy-document file://ssm-onboarding-policy.json --output json") + POLICY_OUTPUT=$(log_cmd "aws iam create-policy --policy-name SSMOnboardingPolicy-$UNIQUE_ID --policy-document file://ssm-onboarding-policy.json --output json") @@ -413 +414 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - POLICY_ARN=$(echo "$POLICY_OUTPUT" | grep -o 'arn:aws:iam::[0-9]*:policy/SSMOnboardingPolicy') + POLICY_ARN=$(echo "$POLICY_OUTPUT" | grep -o 'arn:aws:iam::[0-9]*:policy/SSMOnboardingPolicy-[a-f0-9]*') @@ -566 +567 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - for resource in "${CREATED_RESOURCES[@]}"; do + for resource in "${CREATED_RESOURCES[@]+"${CREATED_RESOURCES[@]}"}"; do @@ -576 +577 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - read -r CLEANUP_CHOICE + CLEANUP_CHOICE="y"