AWS code-library documentation change
Summary
Updated create-cluster example to enable CloudWatch Container Insights with enhanced observability
Security assessment
Change adds enhanced monitoring capabilities but does not address security vulnerabilities or document security-specific features
Diff
diff --git a/code-library/latest/ug/cli_2_ecs_code_examples.md index 6cdd13382..238f1142e 100644 --- a/code-library/latest/ug/cli_2_ecs_code_examples.md +++ b/code-library/latest/ug/cli_2_ecs_code_examples.md @@ -123 +123 @@ The following code example shows how to use `create-cluster`. -The following `create-cluster` example creates a cluster. +The following `create-cluster` example creates a cluster named `MyCluster` and enables CloudWatch Container Insights with enhanced observability. @@ -127 +127,2 @@ The following `create-cluster` example creates a cluster. - --cluster-name MyCluster + --cluster-name MyCluster \ + --settings name=containerInsights,value=enhanced @@ -142,0 +144,6 @@ Output: + "settings": [ + { + "name": "containerInsights", + "value": "enhanced" + } + ], @@ -153 +160,6 @@ The following `create-cluster` example creates a cluster and associates two exis -aws ecs create-cluster --cluster-name MyCluster --capacity-providers MyCapacityProvider1 MyCapacityProvider2 --default-capacity-provider-strategy capacityProvider=MyCapacityProvider1,weight=1 capacityProvider=MyCapacityProvider2,weight=1 + + aws ecs create-cluster \ + --cluster-name MyCluster \ + --capacity-providers MyCapacityProvider1 MyCapacityProvider2 \ + --default-capacity-provider-strategy capacityProvider=MyCapacityProvider1,weight=1 capacityProvider=MyCapacityProvider2,weight=1 + @@ -235 +247 @@ The following `create-cluster` example creates a cluster with multiple tags. For - --tags key=key1,value=value1 key=key2,value=value2 key=key3,value=value3 + --tags key=key1,value=value1 key=key2,value=value2 @@ -259,4 +270,0 @@ Output: - }, - { - "key": "key3", - "value": "value3" @@ -2756 +2764 @@ The following code example shows how to use `put-account-setting`. -The following `put-account-setting` example enables the `serviceLongArnFormat` account setting for your IAM user account. +The following `put-account-setting` example sets the `containerInsights` account setting to `enhanced` for your IAM user account. This turns on Container Insights with enhanced observability. @@ -2759 +2767,3 @@ The following `put-account-setting` example enables the `serviceLongArnFormat` a - aws ecs put-account-setting --name serviceLongArnFormat --value enabled + aws ecs put-account-setting \ + --name containerInsights \ + --value enhanced @@ -2767,3 +2777,4 @@ Output: - "name": "serviceLongArnFormat", - "value": "enabled", - "principalArn": "arn:aws:iam::130757420319:user/your_username" + "name": "containerInsights", + "value": "enhanced", + "principalArn": "arn:aws:iam::123456789012:user/johndoe", + "type": "user" @@ -3434 +3445 @@ The following code example shows how to use `update-cluster-settings`. -The following `update-cluster-settings` example enables CloudWatch Container Insights for the `default` cluster. +The following `update-cluster-settings` example enables CloudWatch Container Insights with enhanced observability for the `MyCluster` cluster. @@ -3438,2 +3449,2 @@ The following `update-cluster-settings` example enables CloudWatch Container Ins - --cluster default \ - --settings name=containerInsights,value=enabled + --cluster MyCluster \ + --settings name=containerInsights,value=enhanced @@ -3447 +3458 @@ Output: - "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster", + "clusterArn": "arn:aws:ecs:us-esat-1:123456789012:cluster/MyCluster", @@ -3459 +3470 @@ Output: - "value": "enabled" + "value": "enhanced" @@ -4046 +4057 @@ The following code example shows how to use `update-service`. -**Example 1: To change the task definition used in a service** +**Example 1: To change the number of instantiations in a service** @@ -4048 +4059 @@ The following code example shows how to use `update-service`. -The following `update-service` example updates the `my-http-service` service to use the `amazon-ecs-sample` task definition. +The following `update-service` example updates the desired task count of the service `my-http-service` to 2. @@ -4051 +4062,4 @@ The following `update-service` example updates the `my-http-service` service to - aws ecs update-service --service my-http-service --task-definition amazon-ecs-sample + aws ecs update-service \ + --cluster MyCluster + --service my-http-service \ + --desired-count 2 @@ -4054 +4068 @@ The following `update-service` example updates the `my-http-service` service to -**Example 2: To change the number of tasks in a service** +Output: @@ -4056 +4069,0 @@ The following `update-service` example updates the `my-http-service` service to -The following `update-service` example updates the desired task count of the service `my-http-service` to 3. @@ -4057,0 +4071,117 @@ The following `update-service` example updates the desired task count of the ser + { + "service": { + "serviceArn": "arn:aws:ecs:us-east-1:123456789012:service/MyCluster/my-http-service", + "serviceName": "my-http-service", + "clusterArn": "arn:aws:ecs:us-east-1:123456789012:cluster/MyCluster", + "loadBalancers": [], + "serviceRegistries": [], + "status": "ACTIVE", + "desiredCount": 2, + "runningCount": 1, + "pendingCount": 0, + "capacityProviderStrategy": [ + { + "capacityProvider": "FARGATE", + "weight": 1, + "base": 0 + } + ], + "platformVersion": "LATEST", + "platformFamily": "Linux", + "taskDefinition": "arn:aws:ecs:us-east-1:123456789012:task-definition/MyTaskDefinition", + "deploymentConfiguration": { + "deploymentCircuitBreaker": { + "enable": true, + "rollback": true + }, + "maximumPercent": 200, + "minimumHealthyPercent": 100, + "alarms": { + "alarmNames": [], + "rollback": false, + "enable": false + } + }, + "deployments": [ + { + "id": "ecs-svc/1976744184940610707", + "status": "PRIMARY", + "taskkDefinition": "arn:aws:ecs:us-east-1:123456789012:task-definition/MyTaskDefinition", + "desiredCount": 1, + "pendingCount": 0, + "runningCount": 1, + "failedTasks": 0, + "createdAt": "2024-12-03T16:24:25.225000-05:00", + "updatedAt": "2024-12-03T16:25:15.837000-05:00", + "capacityProviderStrategy": [ + { + "capacityProvider": "FARGATE", + "weight": 1, + "base": 0 + } + ], + "platformVersion": "1.4.0", + "platformFamily": "Linux", + "networkConfiguration": { + "awsvpcConfiguration": { + "subnets": [ + "subnet-0d0eab1bb38d5ca64", + "subnet-0db5010045995c2d5" + ], + "securityGroups": [ + "sg-02556bf85a191f59a" + ], + "assignPublicIp": "ENABLED" + } + }, + "rolloutState": "COMPLETED", + "rolloutStateReason": "ECS deployment ecs-svc/1976744184940610707 completed." + } + ], + "roleArn": "arn:aws:iam::123456789012:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS", + "events": [ + { + "id": "f27350b9-4b2a-4e2e-b72e-a4b68380de45", + "createdAt": "2024-12-30T13:24:07.345000-05:00", + "message": "(service my-http-service) has reached a steady state." + }, + { + "id": "e764ec63-f53f-45e3-9af2-d99f922d2957", + "createdAt": "2024-12-30T12:32:21.600000-05:00", + "message": "(service my-http-service) has reached a steady state." + }, + { + "id": "28444756-c2fa-47f8-bd60-93a8e05f3991", + "createdAt": "2024-12-08T19:26:10.367000-05:00", + "message": "(service my-http-service) has reached a steady state." + } + ], + "createdAt": "2024-12-03T16:24:25.225000-05:00", + "placementConstraints": [], + "placementStrategy": [], + "networkConfiguration": { + "awsvpcConfiguration": { + "subnets": [ + "subnet-0d0eab1bb38d5ca64", + "subnet-0db5010045995c2d5" + ], + "securityGroups": [ + "sg-02556bf85a191f59a" + ], + "assignPublicIp": "ENABLED" + } + }, + "healthCheckGracePeriodSeconds": 0, + "schedulingStrategy": "REPLICA", + "deploymentController": { + "type": "ECS" + }, + "createdBy": "arn:aws:iam::123456789012:role/Admin", + "enableECSManagedTags": true, + "propagateTags": "NONE", + "enableExecuteCommand": false, + "availabilityZoneRebalancing": "ENABLED" + } + } + +For more information, see [Updating an Amazon ECS service using the console](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/update-service-console-v2.html) in the _Amazon ECS Developer Guide_. @@ -4059 +4189 @@ The following `update-service` example updates the desired task count of the ser