Skip to content

Commit

Permalink
Add CLI examples for CloudWatch OAM and Synthetics
Browse files Browse the repository at this point in the history
  • Loading branch information
ashishbharadwajm committed Dec 27, 2024
1 parent 42b25f0 commit 6e559e7
Show file tree
Hide file tree
Showing 36 changed files with 778 additions and 0 deletions.
24 changes: 24 additions & 0 deletions awscli/examples/oam/create-link.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**To create a link**

The following ``create-link`` example creates a link between a source account and a sink that you have created in a monitoring account. ::

aws oam create-link \
--label-template sourceAccount \
--resource-types AWS::CloudWatch::Metric \
--sink-identifier arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

Output::

{
"Arn": "arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111",
"Id": "a1b2c3d4-5678-90ab-cdef-example11111",
"Label": "sourceAccount",
"LabelTemplate": "sourceAccount",
"ResourceTypes": [
"AWS::CloudWatch::Metric"
],
"SinkArn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"Tags": {}
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
17 changes: 17 additions & 0 deletions awscli/examples/oam/create-sink.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**To create a sink**

The following ``create-sink`` example creates a sink in the current account, so that it can be used as a monitoring account in CloudWatch cross-account observability. ::

aws oam create-sink \
--name DemoSink

Output::

{
"Arn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"Id": "a1b2c3d4-5678-90ab-cdef-example12345",
"Name": "DemoSink",
"Tags": {}
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/oam/delete-link.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a link**

The following ``delete-link`` example deletes a link between a monitoring account sink and a source account. ::

aws oam delete-link \
--identifier arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111

This command produces no output.

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/oam/delete-sink.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a sink**

The following ``delete-sink`` example deletes a sink. You must delete all links to a sink before you can delete that sink. ::

aws oam delete-sink \
--identifier arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

This command produces no output.

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
22 changes: 22 additions & 0 deletions awscli/examples/oam/get-link.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
**To return complete information about one link**

The following ``get-link`` example returns complete information about a link. ::

aws oam get-link \
--identifier arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111

Output::

{
"Arn": "arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111",
"Id": "a1b2c3d4-5678-90ab-cdef-example11111",
"Label": "sourceAccount",
"LabelTemplate": "sourceAccount",
"ResourceTypes": [
"AWS::CloudWatch::Metric"
],
"SinkArn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"Tags": {}
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
16 changes: 16 additions & 0 deletions awscli/examples/oam/get-sink-policy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To return the current sink policy attached to the sink**

The following ``get-sink-policy`` example returns the current sink policy attached to the sink. ::

aws oam get-sink-policy \
--sink-identifier arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

Output::

{
"SinkArn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"SinkId": "a1b2c3d4-5678-90ab-cdef-example12345",
"Policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789111:root\"},\"Action\":[\"oam:CreateLink\",\"oam:UpdateLink\"],\"Resource\":\"*\",\"Condition\":{\"ForAllValues:StringEquals\":{\"oam:ResourceTypes\":[\"AWS::Logs::LogGroup\",\"AWS::CloudWatch::Metric\",\"AWS::XRay::Trace\",\"AWS::ApplicationInsights::Application\"]}}}]}"
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
17 changes: 17 additions & 0 deletions awscli/examples/oam/get-sink.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**To return complete information about one monitoring account sink**

The following ``get-sink`` example returns complete information about a monitoring account sink. ::

aws oam get-sink \
--identifier arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

Output::

{
"Arn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"Id": "a1b2c3d4-5678-90ab-cdef-example12345",
"Name": "DemoSink",
"Tags": {}
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
23 changes: 23 additions & 0 deletions awscli/examples/oam/list-attached-links.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**To return a list of source account links that are linked to this monitoring account sink**

The following ``list-attached-links`` example returns a list of source account links that are linked to this monitoring account sink. ::

aws oam list-attached-links \
--sink-identifier arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

Output::

{
"Items": [{
"Label": "Monitoring account",
"LinkArn": "arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111",
"ResourceTypes": [
"AWS::ApplicationInsights::Application",
"AWS::Logs::LogGroup",
"AWS::CloudWatch::Metric",
"AWS::XRay::Trace"
]
}]
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
21 changes: 21 additions & 0 deletions awscli/examples/oam/list-links.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**To return a list of links for one monitoring account sink**

The following ``list-links`` example returns a list of links for one monitoring account sink. Run this operation in a source account to return a list of links to monitoring account sinks that this source account has. ::

aws oam list-links

Output::

{
"Items": [{
"Arn": "arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111",
"Id": "a1b2c3d4-5678-90ab-cdef-example11111",
"Label": "sourceAccount",
"ResourceTypes": [
"AWS::CloudWatch::Metric"
],
"SinkArn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345"
}]
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
19 changes: 19 additions & 0 deletions awscli/examples/oam/list-sinks.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
**To return the list of sinks created in the monitoring account**

The following ``list-sinks`` example returns a list of sinks created in the monitoring account. Run this operation in a monitoring account. ::

aws oam list-sinks

Output::

{
"Items": [
{
"Arn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"Id": "a1b2c3d4-5678-90ab-cdef-example12345",
"Name": "DemoSink"
}
]
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
16 changes: 16 additions & 0 deletions awscli/examples/oam/list-tags-for-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
**To display the tags associated with a resource**

The following ``list-tags-for-resource`` example displays the tags associated with a sink. ::

aws oam list-tags-for-resource \
--resource-arn arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

Output::

{
"Tags": {
"Team": "Devops"
}
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
17 changes: 17 additions & 0 deletions awscli/examples/oam/put-sink-policy.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
**To create or update the resource policy**

The following ``put-sink-policy`` example creates the resource policy that grants permissions to source accounts to link to the monitoring account sink. ::

aws oam put-sink-policy \
--policy '{"Version":"2012-10-17","Statement":[{"Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789111:root"},"Action":["oam:CreateLink","oam:UpdateLink"],"Resource":"*","Condition":{"ForAllValues:StringEquals":{"oam:ResourceTypes":["AWS::Logs::LogGroup","AWS::CloudWatch::Metric","AWS::XRay::Trace","AWS::ApplicationInsights::Application"]}}}]}' \
--sink-identifier arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345

Output::

{
"SinkArn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"SinkId": "a1b2c3d4-5678-90ab-cdef-example12345",
"Policy": "{\"Version\":\"2012-10-17\",\"Statement\":[{\"Effect\":\"Allow\",\"Principal\":{\"AWS\":\"arn:aws:iam::123456789111:root\"},\"Action\":[\"oam:CreateLink\",\"oam:UpdateLink\"],\"Resource\":\"*\",\"Condition\":{\"ForAllValues:StringEquals\":{\"oam:ResourceTypes\":[\"AWS::Logs::LogGroup\",\"AWS::CloudWatch::Metric\",\"AWS::XRay::Trace\",\"AWS::ApplicationInsights::Application\"]}}}]}"
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
11 changes: 11 additions & 0 deletions awscli/examples/oam/tag-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**To assign one or more tags to the specified resource**

The following ``tag-resource`` example tags a sink ``arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345``. ::

aws oam tag-resource \
--resource-arn arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345 \
--tags team=Devops

This command produces no output.

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
11 changes: 11 additions & 0 deletions awscli/examples/oam/untag-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**To remove one or more tags from the specified resource.**

The following ``untag-resource`` example removes a tag with the key ``team`` from sink ``arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345``. ::

aws oam untag-resource \
--resource-arn arn:aws:oam:us-east-2:123456789012:sink/f3f42f60-f0f2-425c-1234-12347bdd821f \
--tag-keys team

This command produces no output.

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
24 changes: 24 additions & 0 deletions awscli/examples/oam/update-link.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
**To change what types of data are shared from a source account to its linked monitoring account sink**

The following ``update-link`` example updates the link ``arn:aws:oam:us-east-2:123456789111:link/0123e691-e7ef-43fa-1234-c57c837fced0`` with resource types ``AWS::CloudWatch::Metric`` and ``AWS::Logs::LogGroup``. ::

aws oam update-link \
--identifier arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111 \
--resource-types "AWS::CloudWatch::Metric" "AWS::Logs::LogGroup"

Output::

{
"Arn": "arn:aws:oam:us-east-2:123456789111:link/a1b2c3d4-5678-90ab-cdef-example11111",
"Id": "a1b2c3d4-5678-90ab-cdef-example11111",
"Label": "sourceAccount",
"LabelTemplate": "sourceAccount",
"ResourceTypes": [
"AWS::CloudWatch::Metric",
"AWS::Logs::LogGroup"
],
"SinkArn": "arn:aws:oam:us-east-2:123456789012:sink/a1b2c3d4-5678-90ab-cdef-example12345",
"Tags": {}
}

For more information, see `CloudWatch cross-account observability <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Unified-Cross-Account.html>`__ in the *Amazon CloudWatch User Guide*.
11 changes: 11 additions & 0 deletions awscli/examples/synthetics/associate-resource.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
**To associate a canary with a group**

The following ``associate-resource`` example associates a canary with a group named ``demo_group``. ::

aws synthetics associate-resource \
--group-identifier demo_group \
--resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary

This command produces no output.

For more information, see `Synthetic monitoring (canaries) <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html>`__ in the *Amazon CloudWatch User Guide*.
48 changes: 48 additions & 0 deletions awscli/examples/synthetics/create-canary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
**To create a canary**

The following ``create-canary`` example creates a canary named ``demo_canary``. ::

aws synthetics create-canary \
--name demo_canary \
--code '{"S3Bucket": "artifacts3bucket", "S3Key":"demo_canary.zip", "Handler": "index.lambda_handler"}' \
--artifact-s3-location s3://amzn-s3-demo-bucket/demo_canary.zip \
--execution-role-arn arn:aws:iam::123456789012:role/demo_canary_role \
--schedule Expression="rate(10 minutes)" \
--runtime-version syn-nodejs-puppeteer-9.1

Output::

{
"Canary": {
"Id": "a1b2c3d4-5678-90ab-cdef-example11111",
"Name": "demo_canary",
"Code": {
"Handler": "index.lambda_handler"
},
"ExecutionRoleArn": "arn:aws:iam::123456789012:role/demo_canary_role",
"Schedule": {
"Expression": "rate(10 minutes)",
"DurationInSeconds": 0
},
"RunConfig": {
"TimeoutInSeconds": 600,
"MemoryInMB": 1000,
"ActiveTracing": false
},
"SuccessRetentionPeriodInDays": 31,
"FailureRetentionPeriodInDays": 31,
"Status": {
"State": "CREATING",
"StateReasonCode": "CREATE_PENDING"
},
"Timeline": {
"Created": "2024-10-15T19:03:08.826000+05:30",
"LastModified": "2024-10-15T19:03:08.826000+05:30"
},
"ArtifactS3Location": "amzn-s3-demo-bucket/demo_canary.zip",
"RuntimeVersion": "syn-nodejs-puppeteer-9.1",
"Tags": {}
}
}

For more information, see `Synthetic monitoring (canaries) <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html>`__ in the *Amazon CloudWatch User Guide*.
21 changes: 21 additions & 0 deletions awscli/examples/synthetics/create-group.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
**To create a group**

The following ``create-group`` example creates a group named ``demo_group``. ::

aws synthetics create-group \
--name demo_group

Output::

{
"Group": {
"Id": "example123",
"Name": "demo_group",
"Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123",
"Tags": {},
"CreatedTime": "2024-10-15T14:47:23.811000+05:30",
"LastModifiedTime": "2024-10-15T14:47:23.811000+05:30"
}
}

For more information, see `Synthetic monitoring (canaries) <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html>`__ in the *Amazon CloudWatch User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/synthetics/delete-canary.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To permanently delete a canary**

The following ``delete-canary`` example deletes a canary named ``demo_canary``. ::

aws synthetics delete-canary \
--name demo_canary

This command produces no output.

For more information, see `Synthetic monitoring (canaries) <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html>`__ in the *Amazon CloudWatch User Guide*.
10 changes: 10 additions & 0 deletions awscli/examples/synthetics/delete-group.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
**To delete a group**

The following ``delete-group`` example deletes a group named ``demo_group``. ::

aws synthetics delete-group \
--group-identifier demo_group

This command produces no output.

For more information, see `Synthetic monitoring (canaries) <https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html>`__ in the *Amazon CloudWatch User Guide*.
Loading

0 comments on commit 6e559e7

Please sign in to comment.