AWS cli documentation change
Summary
Restructured load balancer example and fixed clusterArn format in output
Security assessment
Formatting changes and example reorganization without security impact
Diff
diff --git a/cli/v1/userguide/cli_ecs_code_examples.md b/cli/v1/userguide/cli_ecs_code_examples.md index 42df298ce..6dd006a50 100644 --- a/cli/v1/userguide/cli_ecs_code_examples.md +++ b/cli/v1/userguide/cli_ecs_code_examples.md @@ -301 +301 @@ The following `create-service` example shows how to create a service using a Far - --network-configuration 'awsvpcConfiguration={subnets=[subnet-12344321],securityGroups=[sg-12344321],assignPublicIp=ENABLED}' \ + --network-configuration "awsvpcConfiguration={subnets=[subnet-12344321],securityGroups=[sg-12344321],assignPublicIp=ENABLED}" \ @@ -387,2 +386,0 @@ Output: -For more information, see [Creating a Service](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service-console-v2.html) in the _Amazon ECS Developer Guide_. - @@ -444,2 +441,0 @@ Output: -For more information, see [Creating a Service](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service-console-v2.html) in the _Amazon ECS Developer Guide_. - @@ -493,2 +488,0 @@ Output: -For more information, see [Creating a Service](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service-console-v2.html) in the _Amazon ECS Developer Guide_. - @@ -497,10 +491 @@ For more information, see [Creating a Service](https://docs.aws.amazon.com/Amazo -The following `create-service` example shows how to create a service that is behind a load balancer. You must have a load balancer configured in the same Region as your container instance. This example uses the `--cli-input-json` option and a JSON input file called `ecs-simple-service-elb.json` with the following content. - - - aws ecs create-service \ - --cluster MyCluster \ - --service-name ecs-simple-service-elb \ - --cli-input-json file://ecs-simple-service-elb.json - - -Contents of `ecs-simple-service-elb.json`: +The following `create-service` example shows how to create a service that is behind a load balancer. You must have a load balancer configured in the same Region as your container instance. This example uses the `--cli-input-json` option and a JSON input file called `ecs-simple-service-elb.json` with the following content: @@ -522,0 +508,9 @@ Contents of `ecs-simple-service-elb.json`: +Command: + + + aws ecs create-service \ + --cluster MyCluster \ + --service-name ecs-simple-service-elb \ + --cli-input-json file://ecs-simple-service-elb.json + + @@ -541 +535 @@ Output: - "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/MyCluster", + "clusterArn": "arn:aws:ecs:<us-west-2:123456789012:cluster/MyCluster", @@ -560,136 +554 @@ Output: -For more information, see [Use load balancing to distribute Amazon ECS service traffic](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-load-balancing.html) in the _Amazon ECS Developer Guide_. - -**Example 5: To configure Amazon EBS volumes at service creation** - -The following `create-service` example shows how to configure Amazon EBS volumes for each task managed by the service. You must have an Amazon ECS infrastructure role configured with the `AmazonECSInfrastructureRolePolicyForVolumes` managed policy attached. You must specify a task definition with the same volume name as in the `create-service` request. This example uses the `--cli-input-json` option and a JSON input file called `ecs-simple-service-ebs.json` with the following content. - - - aws ecs create-service \ - --cli-input-json file://ecs-simple-service-ebs.json - - -Contents of `ecs-simple-service-ebs.json`: - - - { - "cluster": "mycluster", - "taskDefinition": "mytaskdef", - "serviceName": "ecs-simple-service-ebs", - "desiredCount": 2, - "launchType": "FARGATE", - "networkConfiguration":{ - "awsvpcConfiguration":{ - "assignPublicIp": "ENABLED", - "securityGroups": ["sg-12344321"], - "subnets":["subnet-12344321"] - } - }, - "volumeConfigurations": [ - { - "name": "myEbsVolume", - "managedEBSVolume": { - "roleArn":"arn:aws:iam::123456789012:role/ecsInfrastructureRole", - "volumeType": "gp3", - "sizeInGiB": 100, - "iops": 3000, - "throughput": 125, - "filesystemType": "ext4" - } - } - ] - } - -Output: - - - { - "service": { - "serviceArn": "arn:aws:ecs:us-west-2:123456789012:service/mycluster/ecs-simple-service-ebs", - "serviceName": "ecs-simple-service-ebs", - "clusterArn": "arn:aws:ecs:us-west-2:123456789012:cluster/mycluster", - "loadBalancers": [], - "serviceRegistries": [], - "status": "ACTIVE", - "desiredCount": 2, - "runningCount": 0, - "pendingCount": 0, - "launchType": "EC2", - "taskDefinition": "arn:aws:ecs:us-west-2:123456789012:task-definition/mytaskdef:3", - "deploymentConfiguration": { - "deploymentCircuitBreaker": { - "enable": false, - "rollback": false - }, - "maximumPercent": 200, - "minimumHealthyPercent": 100 - }, - "deployments": [ - { - "id": "ecs-svc/7851020056849183687", - "status": "PRIMARY", - "taskDefinition": "arn:aws:ecs:us-west-2:123456789012:task-definition/mytaskdef:3", - "desiredCount": 0, - "pendingCount": 0, - "runningCount": 0, - "failedTasks": 0, - "createdAt": "2025-01-21T11:32:38.034000-06:00", - "updatedAt": "2025-01-21T11:32:38.034000-06:00", - "launchType": "EC2", - "networkConfiguration": { - "awsvpcConfiguration": { - "subnets": [ - "subnet-12344321" - ], - "securityGroups": [ - "sg-12344321" - ], - "assignPublicIp": "DISABLED" - } - }, - "rolloutState": "IN_PROGRESS", - "rolloutStateReason": "ECS deployment ecs-svc/7851020056849183687 in progress.", - "volumeConfigurations": [ - { - "name": "myEBSVolume", - "managedEBSVolume": { - "volumeType": "gp3", - "sizeInGiB": 100, - "iops": 3000, - "throughput": 125, - "roleArn": "arn:aws:iam::123456789012:role/ecsInfrastructureRole", - "filesystemType": "ext4" - } - } - ] - } - ], - "roleArn": "arn:aws:iam::123456789012:role/aws-service-role/ecs.amazonaws.com/AWSServiceRoleForECS", - "events": [], - "createdAt": "2025-01-21T11:32:38.034000-06:00", - "placementConstraints": [], - "placementStrategy": [], - "networkConfiguration": { - "awsvpcConfiguration": { - "subnets": [ - "subnet-12344321" - ], - "securityGroups": [ - "sg-12344321" - ], - "assignPublicIp": "DISABLED" - } - }, - "healthCheckGracePeriodSeconds": 0, - "schedulingStrategy": "REPLICA", - "deploymentController": { - "type": "ECS" - }, - "createdBy": "arn:aws:iam::123456789012:user/AIDACKCEVSQ6C2EXAMPLE", - "enableECSManagedTags": false, - "propagateTags": "NONE", - "enableExecuteCommand": false, - "availabilityZoneRebalancing": "DISABLED" - } - } - -For more information, see [Use Amazon EBS volumes with Amazon ECS](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ebs-volumes.html) in the _Amazon ECS Developer Guide_. +For more information, see [Creating a Service](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/create-service.html) in the _Amazon ECS Developer Guide_. @@ -3335 +3194 @@ The following code example shows how to use `run-task`. -**Example 1: To run a task on your default cluster** +**To run a task on your default cluster** @@ -3400,130 +3259 @@ Output: -For more information, see [Running an application as a standalone task](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/standalone-task-create.html) in the _Amazon ECS Developer Guide_. - -**Example 2: To configure an Amazon EBS volume for a standalone task** - -The following `run-task` example configures an encrypted Amazon EBS volume for a Fargate task on the default cluster. You must have an Amazon ECS infrastructure role configured with the `AmazonECSInfrastructureRolePolicyForVolumes` managed policy attached. You must specify a task definition with the same volume name as in the `run-task` request. This example uses the `--cli-input-json` option and a JSON input file called `ebs.json`. - - - aws ecs run-task \ - --cli-input-json file://ebs.json - - -Contents of `ebs.json`: - - - { - "cluster": "default", - "taskDefinition": "mytaskdef",