AWS code-library documentation change
Summary
Added resource tagging commands throughout code examples for S3 buckets, EC2 key pairs, IAM roles, SNS topics, and AWS Config resources using consistent 'project=doc-smith' and tutorial-related tags
Security assessment
The changes exclusively add resource tagging for organizational/tutorial purposes. Tagging improves resource management but doesn't address vulnerabilities, security configurations, or security features. No security implications are mentioned in the changes.
Diff
diff --git a/code-library/latest/ug/bash_2_s3_code_examples.md b/code-library/latest/ug/bash_2_s3_code_examples.md index b72f52c02..f87e399cb 100644 --- a//code-library/latest/ug/bash_2_s3_code_examples.md +++ b//code-library/latest/ug/bash_2_s3_code_examples.md @@ -1203,0 +1204,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws s3api put-bucket-tagging \ + --bucket "$S3_BUCKET" \ + --tagging 'TagSet=[{Key=project,Value=doc-smith},{Key=tutorial,Value=amazon-athena-gs}]' + @@ -1793,0 +1798,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + # Tag the bucket + aws s3api put-bucket-tagging --bucket "$BUCKET_NAME" \ + --tagging 'TagSet=[{Key=project,Value=doc-smith},{Key=tutorial,Value=emr-gs}]' + @@ -1902 +1910,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - aws ec2 create-key-pair --key-name "$KEY_NAME" --query "KeyMaterial" --output text > "$KEY_NAME_FILE" + aws ec2 create-key-pair --key-name "$KEY_NAME" \ + --tag-specifications 'ResourceType=key-pair,Tags=[{Key=project,Value=doc-smith},{Key=tutorial,Value=emr-gs}]' \ + --query "KeyMaterial" --output text > "$KEY_NAME_FILE" @@ -1922,0 +1933 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + --tags Key=project,Value=doc-smith Key=tutorial,Value=emr-gs \ @@ -2287,0 +2299,17 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + + if ! aws s3api put-bucket-tagging \ + --bucket "$BUCKET_NAME" \ + --tagging '{ + "TagSet": [ + { + "Key": "project", + "Value": "doc-smith" + }, + { + "Key": "tutorial", + "Value": "s3-gettingstarted" + } + ] + }' >/dev/null 2>&1; then + echo "WARNING: Failed to tag bucket" + fi @@ -2436 +2464 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - aws s3api create-bucket --bucket "$LOG_TARGET_BUCKET" 2>/dev/null || true + aws s3api create-bucket --bucket "$LOG_TARGET_BUCKET" >/dev/null 2>&1 || true @@ -2441 +2469,18 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - --create-bucket-configuration LocationConstraint="$REGION" 2>/dev/null || true + --create-bucket-configuration LocationConstraint="$REGION" >/dev/null 2>&1 || true + fi + + if ! aws s3api put-bucket-tagging \ + --bucket "$LOG_TARGET_BUCKET" \ + --tagging '{ + "TagSet": [ + { + "Key": "project", + "Value": "doc-smith" + }, + { + "Key": "tutorial", + "Value": "s3-gettingstarted" + } + ] + }' >/dev/null 2>&1; then + echo "WARNING: Failed to tag log bucket" @@ -2472,0 +2518,8 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + { + "Key": "project", + "Value": "doc-smith" + }, + { + "Key": "tutorial", + "Value": "s3-gettingstarted" + }, @@ -2718,0 +2772,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + # Tag the role + echo "Tagging IAM role..." >&2 + aws iam tag-role --role-name "$role_name" --tags Key=project,Value=doc-smith Key=tutorial,Value=sagemaker-featurestore 2>&1 + @@ -2832,0 +2890,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + # Tag the S3 bucket + echo "Tagging S3 bucket: $S3_BUCKET_NAME" + aws s3api put-bucket-tagging --bucket "$S3_BUCKET_NAME" --tagging 'TagSet=[{Key=project,Value=doc-smith},{Key=tutorial,Value=sagemaker-featurestore}]' 2>&1 + @@ -2873 +2934,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - --role-arn "$ROLE_ARN" 2>&1) + --role-arn "$ROLE_ARN" \ + --tags Key=project,Value=doc-smith Key=tutorial,Value=sagemaker-featurestore 2>&1) @@ -2908 +2970,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - --role-arn "$ROLE_ARN" 2>&1) + --role-arn "$ROLE_ARN" \ + --tags Key=project,Value=doc-smith Key=tutorial,Value=sagemaker-featurestore 2>&1) @@ -3281,0 +3344,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws s3api put-bucket-tagging \ + --bucket "$BUCKET_NAME" \ + --tagging 'TagSet=[{Key=project,Value=doc-smith},{Key=tutorial,Value=amazon-textract-gs}]' + @@ -3624,0 +3691,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + + aws s3api put-bucket-tagging --bucket "$S3_BUCKET_NAME" --tagging 'TagSet=[{Key=project,Value=doc-smith},{Key=tutorial,Value=aws-config-gs}]' + echo "Tags applied to S3 bucket" @@ -3638 +3707 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - SNS_RESULT=$(aws sns create-topic --name "$TOPIC_NAME") + SNS_RESULT=$(aws sns create-topic --name "$TOPIC_NAME" --tags Key=project,Value=doc-smith Key=tutorial,Value=aws-config-gs) @@ -3669,0 +3739,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws iam tag-role --role-name "$ROLE_NAME" --tags Key=project,Value=doc-smith Key=tutorial,Value=aws-config-gs + echo "Tags applied to IAM role" + @@ -3758,0 +3831,5 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + if [ "$CREATED_NEW_CONFIG_RECORDER" = "true" ]; then + aws configservice tag-resource --resource-arn "arn:aws:config:${AWS_REGION}:${ACCOUNT_ID}:config-recorder/${CONFIG_RECORDER_NAME}" --tags Key=project,Value=doc-smith Key=tutorial,Value=aws-config-gs + echo "Tags applied to configuration recorder" + fi + @@ -3807,0 +3885,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + + aws configservice tag-resource --resource-arn "arn:aws:config:${AWS_REGION}:${ACCOUNT_ID}:delivery-channel/${DELIVERY_CHANNEL_NAME}" --tags Key=project,Value=doc-smith Key=tutorial,Value=aws-config-gs + echo "Tags applied to delivery channel"