AWS code-library documentation change
Summary
Added tagging (project=doc-smith, tutorial=...) to ECS resources including security groups, log groups, clusters, IAM roles, tasks, and instances
Security assessment
Changes only add resource tagging for organizational purposes. Tagging helps with resource management but doesn't address vulnerabilities, security configurations, or security features. No security-related changes like policy updates, permission changes, or vulnerability fixes are present.
Diff
diff --git a/code-library/latest/ug/bash_2_ecs_code_examples.md b/code-library/latest/ug/bash_2_ecs_code_examples.md index c05c5c47c..9e10e864b 100644 --- a//code-library/latest/ug/bash_2_ecs_code_examples.md +++ b//code-library/latest/ug/bash_2_ecs_code_examples.md @@ -187 +187,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - --vpc-id "$VPC_ID" 2>&1) + --vpc-id "$VPC_ID" \ + --tag-specifications 'ResourceType=security-group,Tags=[{Key=project,Value=doc-smith},{Key=tutorial,Value=amazon-ecs-service-connect}]' 2>&1) @@ -214 +215 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - aws logs create-log-group --log-group-name "/ecs/service-connect-nginx" 2>&1 | grep -v "ResourceAlreadyExistsException" || { + aws logs create-log-group --log-group-name "/ecs/service-connect-nginx" --tags project=doc-smith,tutorial=amazon-ecs-service-connect 2>&1 | grep -v "ResourceAlreadyExistsException" || { @@ -224 +225 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - aws logs create-log-group --log-group-name "/ecs/service-connect-proxy" 2>&1 | grep -v "ResourceAlreadyExistsException" || { + aws logs create-log-group --log-group-name "/ecs/service-connect-proxy" --tags project=doc-smith,tutorial=amazon-ecs-service-connect 2>&1 | grep -v "ResourceAlreadyExistsException" || { @@ -241 +242 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - --tags key=Environment,value=tutorial 2>&1) + --tags key=Environment,value=tutorial key=project,value=doc-smith key=tutorial,value=amazon-ecs-service-connect 2>&1) @@ -284,0 +286 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws iam tag-role --role-name ecsTaskExecutionRole --tags Key=project,Value=doc-smith Key=tutorial,Value=amazon-ecs-service-connect @@ -315,0 +318 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws iam tag-role --role-name ecsTaskRole --tags Key=project,Value=doc-smith Key=tutorial,Value=amazon-ecs-service-connect @@ -419,0 +423,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": "amazon-ecs-service-connect" @@ -1042,0 +1054,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws iam tag-role --role-name ecsTaskExecutionRole --tags Key=project,Value=doc-smith Key=tutorial,Value=amazon-ecs-fargate-linux + @@ -1057 +1070 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - CLUSTER_OUTPUT=$(execute_command "aws ecs create-cluster --cluster-name '$CLUSTER_NAME'" "Create ECS cluster") + CLUSTER_OUTPUT=$(execute_command "aws ecs create-cluster --cluster-name '$CLUSTER_NAME' --tags key=project,value=doc-smith key=tutorial,value=amazon-ecs-fargate-linux" "Create ECS cluster") @@ -1145 +1158 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - SECURITY_GROUP_OUTPUT=$(execute_command "aws ec2 create-security-group --group-name '$SECURITY_GROUP_NAME' --description 'Security group for ECS Fargate tutorial - HTTP access' --vpc-id '$VPC_ID'" "Create security group") + SECURITY_GROUP_OUTPUT=$(execute_command "aws ec2 create-security-group --group-name '$SECURITY_GROUP_NAME' --description 'Security group for ECS Fargate tutorial - HTTP access' --vpc-id '$VPC_ID' --tag-specifications 'ResourceType=security-group,Tags=[{Key=project,Value=doc-smith},{Key=tutorial,Value=amazon-ecs-fargate-linux}]'" "Create security group") @@ -1193 +1206 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - SERVICE_CMD="aws ecs create-service --cluster '$CLUSTER_NAME' --service-name '$SERVICE_NAME' --task-definition '$TASK_FAMILY' --desired-count 1 --launch-type FARGATE --network-configuration '{\"awsvpcConfiguration\":{\"subnets\":[\"$(echo "$SUBNET_IDS_COMMA" | sed 's/,/","/g')\"],\"securityGroups\":[\"$SECURITY_GROUP_ID\"],\"assignPublicIp\":\"ENABLED\"}}'" + SERVICE_CMD="aws ecs create-service --cluster '$CLUSTER_NAME' --service-name '$SERVICE_NAME' --task-definition '$TASK_FAMILY' --desired-count 1 --launch-type FARGATE --network-configuration '{\"awsvpcConfiguration\":{\"subnets\":[\"$(echo "$SUBNET_IDS_COMMA" | sed 's/,/","/g')\"],\"securityGroups\":[\"$SECURITY_GROUP_ID\"],\"assignPublicIp\":\"ENABLED\"}}' --tags key=project,value=doc-smith key=tutorial,value=amazon-ecs-fargate-linux" @@ -1370,0 +1384,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + # Tags + PROJECT_TAG="doc-smith" + TUTORIAL_TAG="ecs-ec2" + @@ -1560 +1577 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - CLUSTER_ARN=$(aws ecs create-cluster --cluster-name "$CLUSTER_NAME" --query 'cluster.clusterArn' --output text) + CLUSTER_ARN=$(aws ecs create-cluster --cluster-name "$CLUSTER_NAME" --tags key=project,value=$PROJECT_TAG key=tutorial,value=$TUTORIAL_TAG --query 'cluster.clusterArn' --output text) @@ -1582,0 +1600,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + + aws ec2 create-tags --resources "$KEY_PAIR_NAME" --tags Key=project,Value=$PROJECT_TAG Key=tutorial,Value=$TUTORIAL_TAG 2>>"$LOG_FILE" || log "WARNING: Failed to tag key pair" @@ -1592,0 +1612 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + --tag-specifications "ResourceType=security-group,Tags=[{Key=project,Value=$PROJECT_TAG},{Key=tutorial,Value=$TUTORIAL_TAG}]" \ @@ -1664,0 +1685,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + aws iam tag-role --role-name ecsInstanceRole --tags Key=project,Value=$PROJECT_TAG Key=tutorial,Value=$TUTORIAL_TAG + @@ -1716 +1738 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=ecs-tutorial-instance}]" \ + --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=ecs-tutorial-instance},{Key=project,Value=$PROJECT_TAG},{Key=tutorial,Value=$TUTORIAL_TAG}]" \ @@ -1794 +1816,11 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - "networkMode": "bridge" + "networkMode": "bridge", + "tags": [ + { + "key": "project", + "value": "PROJECT_TAG_PLACEHOLDER" + }, + { + "key": "tutorial", + "value": "TUTORIAL_TAG_PLACEHOLDER" + } + ] @@ -1800,0 +1833,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + sed -i "s|PROJECT_TAG_PLACEHOLDER|$PROJECT_TAG|g" task-definition.json + sed -i "s|TUTORIAL_TAG_PLACEHOLDER|$TUTORIAL_TAG|g" task-definition.json @@ -1834,0 +1869 @@ There's more on GitHub. Find the complete example and learn how to set up and ru + --tags key=project,value=$PROJECT_TAG key=tutorial,value=$TUTORIAL_TAG \