Sitelet https://github.com/tycho/aws-cli/commit/aa890a3f374086d09629a4b5eb44b20c1edf1595
Skip to content

Commit aa890a3

Browse files
Nordlund, Ericjamesls
authored andcommitted
Adding Amazon ECS examples.
1 parent 906a234 commit aa890a3

12 files changed

Lines changed: 431 additions & 0 deletions
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**To create a new cluster**
2+
3+
This example command creates a cluster in your default region.
4+
5+
Command::
6+
7+
aws ecs create-cluster --cluster-name "dev_preview"
8+
9+
Output::
10+
11+
{
12+
"cluster": {
13+
"clusterName": "dev_preview",
14+
"status": "ACTIVE",
15+
"clusterArn": "arn:aws:ecs:us-west-2:<aws_account_id>:cluster/dev_preview"
16+
}
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
**To deregister a container instance from a cluster**
2+
3+
This example deregisters a container instance from the specified cluster in your default region. If there are still tasks running on the container instance, you must either stop those tasks before deregistering, or use the force option.
4+
5+
Command::
6+
7+
aws ecs deregister-container-instance --cluster default --container-instance <container_instance_UUID> --force
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
**To describe a cluster**
2+
3+
This example command provides a description of the specified cluster in your default region.
4+
5+
Command::
6+
7+
aws ecs describe-cluster --cluster default
8+
9+
Output::
10+
11+
{
12+
"clusters": [
13+
{
14+
"clusterName": "default",
15+
"status": "ACTIVE",
16+
"clusterArn": "arn:aws:ecs:us-west-2:<aws_account_id>:cluster/default"
17+
}
18+
],
19+
"failures": []
20+
}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
**To describe container instance**
2+
3+
This example command provides a description of the specified container instance in your default region, using the container instance UUID as an identifier.
4+
5+
Command::
6+
7+
aws ecs describe-container-instance --cluster default --container-instance f6bbb147-5370-4ace-8c73-c7181ded911f
8+
9+
Output::
10+
11+
{
12+
"failures": [],
13+
"containerInstances": [
14+
{
15+
"status": "ACTIVE",
16+
"remainingResources": [
17+
{
18+
"integerValue": 32748,
19+
"longValue": 0,
20+
"type": "INTEGER",
21+
"name": "CPU",
22+
"doubleValue": 0.0
23+
},
24+
{
25+
"integerValue": 60377,
26+
"longValue": 0,
27+
"type": "INTEGER",
28+
"name": "MEMORY",
29+
"doubleValue": 0.0
30+
}
31+
],
32+
"registeredResources": [
33+
{
34+
"integerValue": 32768,
35+
"longValue": 0,
36+
"type": "INTEGER",
37+
"name": "CPU",
38+
"doubleValue": 0.0
39+
},
40+
{
41+
"integerValue": 60397,
42+
"longValue": 0,
43+
"type": "INTEGER",
44+
"name": "MEMORY",
45+
"doubleValue": 0.0
46+
}
47+
],
48+
"containerInstanceArn": "arn:aws:ecs:us-west-2:<aws_account_id>:container-instance/f6bbb147-5370-4ace-8c73-c7181ded911f",
49+
"ec2InstanceId": "i-0f51df05"
50+
}
51+
]
52+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
**To describe a task definition**
2+
3+
This example command provides a description of the specified task definition.
4+
5+
Command::
6+
7+
aws ecs describe-task-definition --task-definition wordpress:6
8+
9+
Output::
10+
11+
{
12+
"taskDefinition": {
13+
"taskDefinitionArn": "arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:6",
14+
"containerDefinitions": [
15+
{
16+
"environment": [
17+
{
18+
"name": "DB_USER",
19+
"value": "root"
20+
},
21+
{
22+
"name": "DB_PASS",
23+
"value": "pass"
24+
}
25+
],
26+
"name": "wordpress",
27+
"links": [
28+
"db"
29+
],
30+
"image": "tutum/wordpress-stackable",
31+
"essential": true,
32+
"portMappings": [
33+
{
34+
"containerPort": 80,
35+
"hostPort": 80
36+
}
37+
],
38+
"entryPoint": [
39+
"/bin/sh",
40+
"-c"
41+
],
42+
"memory": 500,
43+
"cpu": 10
44+
},
45+
{
46+
"environment": [
47+
{
48+
"name": "MYSQL_ROOT_PASSWORD",
49+
"value": "pass"
50+
}
51+
],
52+
"name": "db",
53+
"image": "mysql",
54+
"cpu": 10,
55+
"portMappings": [],
56+
"entryPoint": [
57+
"/entrypoint.sh"
58+
],
59+
"memory": 500,
60+
"essential": true
61+
}
62+
],
63+
"family": "wordpress",
64+
"revision": 6
65+
}
66+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
**To describe a task**
2+
3+
This example command provides a description of the specified task, using the task UUID as an identifier.
4+
5+
Command::
6+
7+
aws ecs describe-task --cluster default --task 0cc43cdb-3bee-4407-9c26-c0e6ea5bee84
8+
9+
Output::
10+
11+
{
12+
"failures": [],
13+
"tasks": [
14+
{
15+
"taskArn": "arn:aws:ecs:us-west-2:<aws_account_id>:task/0cc43cdb-3bee-4407-9c26-c0e6ea5bee84",
16+
"overrides": {
17+
"containerOverrides": [
18+
{
19+
"name": "sleep"
20+
}
21+
]
22+
},
23+
"lastStatus": "PENDING",
24+
"containerInstanceArn": "arn:aws:ecs:us-west-2:<aws_account_id>:container-instance/f6bbb147-5370-4ace-8c73-c7181ded911f",
25+
"desiredStatus": "RUNNING",
26+
"taskDefinitionArn": "arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/sleep360:1",
27+
"containers": [
28+
{
29+
"containerArn": "arn:aws:ecs:us-west-2:<aws_account_id>:container/291bb057-f49c-4bd7-9b50-9c891359083b",
30+
"taskArn": "arn:aws:ecs:us-west-2:<aws_account_id>:task/0cc43cdb-3bee-4407-9c26-c0e6ea5bee84",
31+
"lastStatus": "PENDING",
32+
"name": "sleep"
33+
}
34+
]
35+
}
36+
]
37+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
**To list your available clusters**
2+
3+
This example command lists all of your available clusters in your default region.
4+
5+
Command::
6+
7+
aws ecs list-clusters
8+
9+
Output::
10+
11+
{
12+
"clusterArns": [
13+
"arn:aws:ecs:us-west-2:<aws_account_id>:cluster/test",
14+
"arn:aws:ecs:us-west-2:<aws_account_id>:cluster/default",
15+
"arn:aws:ecs:us-west-2:<aws_account_id>:cluster/My test cluster"
16+
]
17+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
**To list your available container instances in a cluster**
2+
3+
This example command lists all of your available container instances in the specified cluster in your default region.
4+
5+
Command::
6+
7+
aws ecs list-container-instances --cluster default
8+
9+
Output::
10+
11+
{
12+
"containerInstanceArns": [
13+
"arn:aws:ecs:us-west-2:<aws_account_id>:container-instance/f6bbb147-5370-4ace-8c73-c7181ded911f",
14+
"arn:aws:ecs:us-west-2:<aws_account_id>:container-instance/ffe3d344-77e2-476c-a4d0-bf560ad50acb"
15+
]
16+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
**To list your registered task definitions**
2+
3+
This example command lists all of your registered task definitions.
4+
5+
Command::
6+
7+
aws ecs list-task-definitions
8+
9+
Output::
10+
11+
{
12+
"taskDefinitionArns": [
13+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/sleep300:2",
14+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/sleep360:1",
15+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:3",
16+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:4",
17+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:5",
18+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:6"
19+
]
20+
}
21+
22+
**To list the registered task definitions in a family**
23+
24+
This example command lists the task definition revisions of a specified family.
25+
26+
Command::
27+
28+
aws ecs list-task-definitions --family-prefix wordpress
29+
30+
Output::
31+
32+
{
33+
"taskDefinitionArns": [
34+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:3",
35+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:4",
36+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:5",
37+
"arn:aws:ecs:us-west-2:<aws_account_id>:task-definition/wordpress:6"
38+
]
39+
}

‎awscli/examples/ecs/list-tasks.rst‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
**To list the tasks in a cluster**
2+
3+
This example command lists all of the tasks in a cluster.
4+
5+
Command::
6+
7+
aws ecs list-tasks --cluster default
8+
9+
Output::
10+
11+
{
12+
"taskArns": [
13+
"arn:aws:ecs:us-west-2:<aws_account_id>:task/0cc43cdb-3bee-4407-9c26-c0e6ea5bee84",
14+
"arn:aws:ecs:us-west-2:<aws_account_id>:task/6b809ef6-c67e-4467-921f-ee261c15a0a1"
15+
]
16+
}
17+
18+
**To list the tasks on a particular container instance**
19+
20+
This example command lists the tasks of a specified container instance, using the container instance UUID as a filter.
21+
22+
Command::
23+
24+
aws ecs list-tasks --cluster default --container-instance f6bbb147-5370-4ace-8c73-c7181ded911f
25+
26+
Output::
27+
28+
{
29+
"taskArns": [
30+
"arn:aws:ecs:us-west-2:<aws_account_id>:task/0cc43cdb-3bee-4407-9c26-c0e6ea5bee84"
31+
]
32+
}

0 commit comments

Comments
 (0)