Skip to content

Commit

Permalink
Merge pull request aws#1176 from awsdocs/ssm-examples
Browse files Browse the repository at this point in the history
SSM examples & some EC2 updates
  • Loading branch information
kyleknap committed Feb 24, 2015
2 parents a54c0c3 + 63bf08a commit 9c4d977
Show file tree
Hide file tree
Showing 16 changed files with 369 additions and 5 deletions.
19 changes: 19 additions & 0 deletions awscli/examples/ec2/describe-images.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,22 @@ This example describes Windows AMIs provided by Amazon that are backed by Amazon
Command::

aws ec2 describe-images --owners amazon --filters "Name=platform,Values=windows" "Name=root-device-type,Values=ebs"

**To describe tagged AMIs**

This example describes all AMIs that have the tag ``Custom=Linux1`` or ``Custom=Ubuntu1``. The output is filtered to display only the AMI IDs.

Command::

aws ec2 describe-images --filters Name=tag-key,Values=Custom Name=tag-value,Values=Linux1,Ubuntu1 --query 'Images[*].{ID:ImageId}'

Output::

[
{
"ID": "ami-1a2b3c4d"
},
{
"ID": "ami-ab12cd34"
}
]
2 changes: 1 addition & 1 deletion awscli/examples/ec2/describe-instances.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Command::

aws ec2 describe-instances --filters "Name=tag-key,Values=Owner"

**To describe all EC2 that have an instance type of m1.small or m1.medium that are also in the us-west-2c Availability Zone**
**To describe all EC2 instances that have an instance type of m1.small or m1.medium that are also in the us-west-2c Availability Zone**

Command::

Expand Down
47 changes: 45 additions & 2 deletions awscli/examples/ec2/describe-security-groups.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**To display information about a security group for EC2-Classic**
**To describe a security group for EC2-Classic**

This example displays information about the security group named ``MySecurityGroup``.

Expand Down Expand Up @@ -33,7 +33,7 @@ Output::
]
}

**To display information about a security group for EC2-VPC**
**To describe a security group for EC2-VPC**

This example displays information about the security group with the ID sg-903004f8. Note that you can't reference a security group for EC2-VPC by name.

Expand Down Expand Up @@ -79,6 +79,49 @@ Output::
]
}

**To describe security groups that have a specific rule**

(EC2-VPC only) This example uses filters to describe security groups that have a rule that allows SSH traffic (port 22) from all IP addresses (``0.0.0.0/0``). The output is filtered to display only the names of the security groups.

Command::

aws ec2 describe-security-groups --filters Name=ip-permission.from-port,Values=22 Name=ip-permission.to-port,Values=22 Name=ip-permission.cidr,Values='0.0.0.0/0' --query 'SecurityGroups[*].{Name:GroupName}'

Output::

[
{
"Name": "default"
},
{
"Name": "Test SG"
},
{
"Name": "SSH-Access-Group"
}
]

**To describe tagged security groups**

This example describes all security groups that include ``test`` in the security group name, and that have the tag ``Test=To-delete``. The output is filtered to display only the names and IDs of the security groups.

Command::

aws ec2 describe-security-groups --filters Name=group-name,Values='*test*' Name=tag-key,Values=Test Name=tag-value,Values=To-delete --query 'SecurityGroups[*].{Name:GroupName,ID:GroupId}'
Output::

[
{
"Name": "testfornewinstance",
"ID": "sg-33bb22aa"
},
{
"Name": "newgrouptest",
"ID": "sg-1a2b3c4d"
}
]

For more information, see `Using Security Groups`_ in the *AWS Command Line Interface User Guide*.

.. _`Using Security Groups`: http://docs.aws.amazon.com/cli/latest/userguide/cli-ec2-sg.html
Expand Down
17 changes: 17 additions & 0 deletions awscli/examples/ec2/describe-snapshots.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,20 @@ Output::
}
]
}

**To describe tagged snapshots and filter the output**

This example command describes all snapshots that have the tag ``Group=Prod``. The output is filtered to display only the snapshot IDs and the time the snapshot was started.

Command::

aws ec2 describe-snapshots --filters Name=tag-key,Values="Group" Name=tag-value,Values="Prod" --query 'Snapshots[*].{ID:SnapshotId,Time:StartTime}'

Output::

[
{
"ID": "snap-12345abc",
"Time": "2014-08-04T12:48:18.000Z"
}
]
36 changes: 34 additions & 2 deletions awscli/examples/ec2/describe-volumes.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
**To view information on all volumes**
**To describe all volumes**

This example command describes all of your volumes in the default region.

Expand Down Expand Up @@ -43,7 +43,7 @@ Output::
]
}

**To view filtered information on all volumes**
**To describe volumes that are attached to a specific instance**

This example command describes all volumes that are both attached to the instance with the ID i-abe041d4 and set to delete when the instance terminates.

Expand Down Expand Up @@ -76,3 +76,35 @@ Output::
}
]
}
**To describe tagged volumes and filter the output **

This example command describes all volumes that have the tag key ``Name`` and a value that begins with ``Test``. The output is filtered to display only the tags and IDs of the volumes.

Command::

aws ec2 describe-volumes --filters Name=tag-key,Values="Name" Name=tag-value,Values="Test*" --query 'Volumes[*].{ID:VolumeId,Tag:Tags}'

Output::

[
{
"Tag": [
{
"Value": "Test2",
"Key": "Name"
}
],
"ID": "vol-9de9e9d9"
},
{
"Tag": [
{
"Value": "Test1",
"Key": "Name"
}
],
"ID": "vol-b2242df9"
}
]

35 changes: 35 additions & 0 deletions awscli/examples/ssm/create-association-batch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
**To create multiple associations**

This example associates the configuration document ``My_Config_1`` with instance ``i-aabb2233``, and associates the configuration document ``My_Config_2`` with instance ``i-cdcd2233``. The output returns a list of successful and unsuccessful operations, if applicable.

Command::

aws ssm create-association-batch --entries Name=My_Config_1,InstanceId=i-aabb2233 Name=My_Config_2,InstanceId=1-cdcd2233

Output::


{
"Successful": [
{
"InstanceId": "i-aabb2233",
"Date": 1424421071.939,
"Name": My_Config_1",
"Status": {
"Date": 1424421071.939,
"Message": "Associated with My_Config_1",
"Name": "Associated"
}
}
],
"Failed": [
{
"Entry": {
"InstanceId": "i-cdcd2233",
"Name": "My_Config_2"
},
"Message": "Association Already Exists",
"Fault": "Client"
}
]
}
23 changes: 23 additions & 0 deletions awscli/examples/ssm/create-association.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**To associate a configuration document**

This example associates configuration document ``My_Config_File`` with instance ``i-1a2b3c4d``.

Command::

aws ssm create-association --instance-id i-1a2b3c4d --name "My_Config_File"

Output::

{
"AssociationDescription": {
"InstanceId": "i-1a2b3c4d",
"Date": 1424354424.842,
"Name": "My_Config_File",
"Status": {
"Date": 1424354424.842,
"Message": "Associated with My_Config_File",
"Name": "Associated"
}
}
}

22 changes: 22 additions & 0 deletions awscli/examples/ssm/create-document.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
**To create a configuration document**

This example creates a configuration document called ``My_Document`` in your account. The document must be in JSON format. For more information about writing a configuration document, see `Configuration Document`_ in the *SSM API Reference*.

.. _`Configuration Document`: http://docs.aws.amazon.com/ssm/latest/APIReference/aws-ssm-document.html

Command::

aws ssm create-document --content file://myconfigfile.json --name "My_Config_Document"

Output::

{
"DocumentDescription": {
"Status": "Creating",
"Sha1": "715919de1715exampled803025817856844a5f3",
"Name": "My_Config_Document",
"CreatedDate": 1424351175.521
}
}


8 changes: 8 additions & 0 deletions awscli/examples/ssm/delete-association.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
**To delete an association**

This example deletes the association between instance ``i-bbcc3344`` and the configuration document ``Test_config``. If the command succeeds, no output is returned.

Command::

aws ssm delete-association --instance-id i-bbcc3344 --name Test_config

7 changes: 7 additions & 0 deletions awscli/examples/ssm/delete-document.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
**To delete a configuration document**

This example deletes the configuration document called ``Config_2``. If the command succeeds, no output is returned.

Command::

aws ssm delete-document --name "Config_2"
23 changes: 23 additions & 0 deletions awscli/examples/ssm/describe-association.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**To describe an association**

This example describes the association between instance ``i-1a2b3c4d`` and ``My_Config_File``.

Command::

aws ssm describe-association --instance-id i-1a2b3c4d --name "My_Config_File"

Output::

{
"AssociationDescription": {
"InstanceId": "i-1a2b3c4d",
"Date": 1424419009.036,
"Name": "My_Config_File",
"Status": {
"Date": 1424419196.804,
"AdditionalInfo": "{agent=EC2Config,ver=3.0.54,osver=6.3.9600,os=Windows Server 2012 R2 Standard,lang=en-US}",
"Message": "RunId=0198dadc-aaaa-4150-875f-exampleba3d, status:InProgress, code:0, message:RuntimeStatusCounts=[PassedAndReboot=1], RuntimeStatus=[aws:domainJoin={PassedAndReboot,Domain join Succeeded to domain: test.ssm.com}]",
"Name": "Pending"
}
}
}
20 changes: 20 additions & 0 deletions awscli/examples/ssm/describe-document.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
**To describe a configuration document**

This example returns information about a document called ``My_Config_Doc``.

Command::

aws ssm describe-document --name "My_Config_Doc"
Output::

{
"Document": {
"Status": "Active",
"Sha1": "715919de171exampleb3d803025817856844a5f3",
"Name": "My_Config_Doc",
"CreatedDate": 1424351175.521
}
}


29 changes: 29 additions & 0 deletions awscli/examples/ssm/get-document.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
**To get the contents of a configuration document**

This example gets the contents of the document called ``My_Config_Document``.

Command::

aws ssm get-document --name "My_Config_Document"


Output::

{
"Content": "{\n
\"schemaVersion\": \"1.0\",\n
\"description\": \"Sample configuration to join an instance to a domain\",\n
\"runtimeConfig\": {\n
\"aws:domainJoin\": {\n
\"properties\": [\n
{\n
\"directoryId\": \"d-1234567890\",\n
\"directoryName\": \"test.example.com\",\n
\"dnsIpAddresses\": [\"198.51.100.1\",\"198.51.100.2\"]\n
}\n
]\n
}\n
}\n
}",
"Name": "My_Config_Document"
}
42 changes: 42 additions & 0 deletions awscli/examples/ssm/list-associations.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
**To list your associations for a specific instance**

This example lists all the associations for instance ``i-1a2b3c4d``.

Command::

aws ssm list-associations --association-filter-list key=InstanceId,value=i-1a2b3c4d

Output::

{
"Associations": [
{
"InstanceId": "i-1a2b3c4d",
"Name": "My_Config_File"
}
]
}

**To list your associations for a specific configuration document**

This example lists all associations for the configuration document ``My_Config_File``.

Command::

aws ssm list-associations --association-filter-list key=Name,value=My_Config_File

Output::

{
"Associations": [
{
"InstanceId": "i-1a2b3c4d",
"Name": "My_Config_File"
},
{
"InstanceId": "i-rraa3344",
"Name": "My_Config_File"
}
]
}

Loading

0 comments on commit 9c4d977

Please sign in to comment.