

Doc AWS SDK Examples GitHub リポジトリには、他にも SDK の例があります。 [AWS](https://github.com/awsdocs/aws-doc-sdk-examples)

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# を使用した CloudWatch Synthetics の例 AWS CLI
<a name="cli_2_synthetics_code_examples"></a>

次のコード例は、CloudWatch Synthetics AWS Command Line Interface で を使用してアクションを実行し、一般的なシナリオを実装する方法を示しています。

*アクション*はより大きなプログラムからのコードの抜粋であり、コンテキスト内で実行する必要があります。アクションは個々のサービス機能を呼び出す方法を示していますが、コンテキスト内のアクションは、関連するシナリオで確認できます。

各例には完全なソースコードへのリンクが含まれており、コードの設定方法と実行方法に関する手順を確認できます。

**Topics**
+ [アクション](#actions)

## アクション
<a name="actions"></a>

### `associate-resource`
<a name="synthetics_AssociateResource_cli_2_topic"></a>

次のコード例は、`associate-resource` を使用する方法を示しています。

**AWS CLI**  
**Canary をグループに関連付けるには**  
次の `associate-resource` の例では、Canary を `demo_group` という名前のグループに関連付けます。  

```
aws synthetics associate-resource \
    --group-identifier demo_group \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[AssociateResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/associate-resource.html)」を参照してください。

### `create-canary`
<a name="synthetics_CreateCanary_cli_2_topic"></a>

次のコード例は、`create-canary` を使用する方法を示しています。

**AWS CLI**  
**Canary を作成するには**  
次の `create-canary` の例では、`demo_canary` という名前の 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
```
出力:  

```
{
    "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": {}
    }
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[CreateCanary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/create-canary.html)」を参照してください。

### `create-group`
<a name="synthetics_CreateGroup_cli_2_topic"></a>

次のコード例は、`create-group` を使用する方法を示しています。

**AWS CLI**  
**グループを作成するには**  
次の `create-group` の例では、`demo_group` という名前のグループが作成されます。  

```
aws synthetics create-group \
    --name demo_group
```
出力:  

```
{
    "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"
    }
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[CreateGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/create-group.html)」を参照してください。

### `delete-canary`
<a name="synthetics_DeleteCanary_cli_2_topic"></a>

次のコード例は、`delete-canary` を使用する方法を示しています。

**AWS CLI**  
**Canary を完全に削除するには**  
次の `delete-canary` の例では、`demo_canary` という名前の Canary を削除します。  

```
aws synthetics delete-canary \
    --name demo_canary
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[DeleteCanary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/delete-canary.html)」を参照してください。

### `delete-group`
<a name="synthetics_DeleteGroup_cli_2_topic"></a>

次のコード例は、`delete-group` を使用する方法を示しています。

**AWS CLI**  
**グループを削除するには**  
次の `delete-group` の例では、`demo_group` という名前のグループを削除します。  

```
aws synthetics delete-group \
    --group-identifier demo_group
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[DeleteGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/delete-group.html)」を参照してください。

### `describe-canaries-last-run`
<a name="synthetics_DescribeCanariesLastRun_cli_2_topic"></a>

次のコード例は、`describe-canaries-last-run` を使用する方法を示しています。

**AWS CLI**  
**各 Canary の最新の実行からの情報を表示するには**  
次の `describe-canaries-last-run` の例では、作成した各 Canary の最新の実行を返します。  

```
aws synthetics describe-canaries-last-run
```
出力:  

```
{
    "CanariesLastRun": [
        {
            "CanaryName": "demo_canary",
            "LastRun": {
                "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
                "Name": "demo_canary",
                "Status": {
                    "State": "PASSED",
                    "StateReason": "",
                    "StateReasonCode": ""
                },
                "Timeline": {
                    "Started": "2024-10-15T19:20:39.691000+05:30",
                    "Completed": "2024-10-15T19:20:58.211000+05:30"
                },
                "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-abc-example1234/2024/10/15/13/50-39-690"
            }
        }
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[DescribeCanariesLastRun](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/describe-canaries-last-run.html)」を参照してください。

### `describe-canaries`
<a name="synthetics_DescribeCanaries_cli_2_topic"></a>

次のコード例は、`describe-canaries` を使用する方法を示しています。

**AWS CLI**  
**アカウントの Canary を一覧表示するには**  
次の `describe-canaries` の例では、アカウントの Canary の詳細を一覧表示します。  

```
aws synthetics describe-canaries
```
出力:  

```
{
    "Canaries": [
        {
            "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
            "Name": "demo_canary",
            "Code": {
                "SourceLocationArn": "arn:aws:lambda:us-east-1:123456789012:layer:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example11111b8:1",
                "Handler": "pageLoadBlueprint.handler"
            },
            "ExecutionRoleArn": "arn:aws:iam::123456789012:role/service-role/CloudWatchSyntheticsRole-demo_canary-a12-a123bc456789",
            "Schedule": {
                "Expression": "rate(5 minutes)",
                "DurationInSeconds": 0
            },
            "RunConfig": {
                "TimeoutInSeconds": 300,
                "MemoryInMB": 1000,
                "ActiveTracing": false
            },
            "SuccessRetentionPeriodInDays": 31,
            "FailureRetentionPeriodInDays": 31,
            "Status": {
            "State": "RUNNING"
            },
            "Timeline": {
                "Created": "2024-10-15T18:55:15.168000+05:30",
                "LastModified": "2024-10-15T18:55:40.540000+05:30",
                "LastStarted": "2024-10-15T18:55:40.540000+05:30"
            },
            "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-a12-a123bc456789",
            "EngineArn": "arn:aws:lambda:us-east-1:123456789012:function:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example111118:1",
            "RuntimeVersion": "syn-nodejs-puppeteer-9.1",
            "Tags": {
                "blueprint": "heartbeat"
            }
        }
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[DescribeCanaries](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/describe-canaries.html)」を参照してください。

### `describe-runtime-versions`
<a name="synthetics_DescribeRuntimeVersions_cli_2_topic"></a>

次のコード例は、`describe-runtime-versions` を使用する方法を示しています。

**AWS CLI**  
**Synthetics Canary ランタイムバージョンのリストを返すには**  
次の `describe-runtime-versions` の例では、Synthetics Canary ランタイムバージョンのリストを返します。  

```
aws synthetics describe-runtime-versions
```
出力:  

```
{
    "RuntimeVersions": [
        {
            "VersionName": "syn-nodejs-puppeteer-9.1",
            "Description": "Security fixes and bug fix for date range error in har. Dependencies: Node JS 20.x, Puppeteer-core 22.12.1, Chromium 126.0.6478.126",
            "ReleaseDate": "2024-10-02T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-9.0",
            "Description": "Upgraded Chromium and Puppeteer. Dependencies: Node JS 20.x, Puppeteer-core 22.12.1, Chromium 126.0.6478.126",
            "ReleaseDate": "2024-07-22T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-8.0",
            "Description": "Upgraded Chromium and Puppeteer. Dependencies: Node JS 20.x, Puppeteer-core 22.10.0, Chromium 125.0.6422.112",
            "ReleaseDate": "2024-06-21T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-7.0",
            "Description": "Upgraded Chromium and Puppeteer. Dependencies: Node JS 18.x, Puppeteer-core 21.9.0, Chromium 121.0.6167.139",
            "ReleaseDate": "2024-03-08T05:30:00+05:30"
            },
        {
            "VersionName": "syn-nodejs-puppeteer-6.2",
            "Description": "Updated shared libraries for Chromium and added ephemeral storage monitoring. Dependencies: Node JS 18.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2024-02-02T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-6.1",
            "Description": "Added puppeteer launch retry. Dependencies: Node JS 18.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-11-13T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-6.0",
            "Description": "Reduced X-Ray traces of a canary run, improved duration metric and upgraded to NodeJS 18.x. Dependencies: Node JS 18.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-09-15T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-5.2",
            "Description": "Updated shared libraries for Chromium. Dependencies: Node JS 16.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2024-02-01T05:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-5.1",
            "Description": "Fixes a bug about missing request headers in har. Dependencies: Node JS 16.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-08-09T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-5.0",
            "Description": "Upgraded Puppeteer and Chromium. Dependencies: Node JS 16.x, Puppeteer-core 19.7.0, Chromium 111.0.5563.146",
            "ReleaseDate": "2023-07-21T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        },
        {
            "VersionName": "syn-nodejs-puppeteer-4.0",
            "Description": "Upgraded to NodeJS 16.x. Dependencies: Node JS 16.x, Puppeteer-core 5.5.0, Chromium 92.0.4512.0",
            "ReleaseDate": "2023-05-01T05:30:00+05:30",
            "DeprecationDate": "2024-03-08T13:30:00+05:30"
        }
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[DescribeRuntimeVersions](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/describe-runtime-versions.html)」を参照してください。

### `disassociate-resource`
<a name="synthetics_DisassociateResource_cli_2_topic"></a>

次のコード例は、`disassociate-resource` を使用する方法を示しています。

**AWS CLI**  
**グループから Canary を削除するには**  
次の `disassociate-resource` の例では、`demo_group` という名前のグループから Canary を削除します。  

```
aws synthetics disassociate-resource \
    --group-identifier demo_group \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[DisassociateResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/disassociate-resource.html)」を参照してください。

### `get-canary-runs`
<a name="synthetics_GetCanaryRuns_cli_2_topic"></a>

次のコード例は、`get-canary-runs` を使用する方法を示しています。

**AWS CLI**  
**指定した Canary の実行リストを取得するには**  
次の `get-canary-runs` の例では、`demo_canary` という名前の Canary の実行リストを取得します。  

```
aws synthetics get-canary-runs \
    --name demo_canary
```
出力:  

```
{
    "CanaryRuns": [
        {
            "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
            "Name": "demo_canary",
            "Status": {
                "State": "PASSED",
                "StateReason": "",
                "StateReasonCode": ""
            },
            "Timeline": {
                "Started": "2024-10-16T10:38:57.013000+05:30",
                "Completed": "2024-10-16T10:39:25.793000+05:30"
            },
            "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-abc-example1234/2024/10/15/13/50-39-690"
        }
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[GetCanaryRuns](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/get-canary-runs.html)」を参照してください。

### `get-canary`
<a name="synthetics_GetCanary_cli_2_topic"></a>

次のコード例は、`get-canary` を使用する方法を示しています。

**AWS CLI**  
**1 つの Canary に関する完全な情報を取得するには**  
次の `get-canary` の例では、`demo_canary` という名前の Canary に関する完全な情報を取得します。  

```
aws synthetics get-canary \
    --name demo_canary
```
出力:  

```
{
    "Canary": {
        "Id": "a1b2c3d4-5678-90ab-cdef-example11111",
        "Name": "demo_canary",
        "Code": {
            "SourceLocationArn": "arn:aws:lambda:us-east-1:123456789012:layer:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example111118:1",
            "Handler": "pageLoadBlueprint.handler"
        },
        "ExecutionRoleArn": "arn:aws:iam::123456789012:role/demo_canary_role",
        "Schedule": {
            "Expression": "rate(10 minutes)",
            "DurationInSeconds": 0
        },
        "RunConfig": {
            "TimeoutInSeconds": 300,
            "MemoryInMB": 1000,
            "ActiveTracing": false
        },
        "SuccessRetentionPeriodInDays": 31,
        "FailureRetentionPeriodInDays": 31,
        "Status": {
            "State": "RUNNING"
        },
        "Timeline": {
            "Created": "2024-10-15T18:55:15.168000+05:30",
            "LastModified": "2024-10-15T18:55:40.540000+05:30",
            "LastStarted": "2024-10-15T18:55:40.540000+05:30"
        },
        "ArtifactS3Location": "cw-syn-results-123456789012-us-east-1/canary/us-east-1/demo_canary-a12-a123bc456789",
        "EngineArn": "arn:aws:lambda:us-east-1:123456789012:function:cwsyn-demo_canary-a1b2c3d4-5678-90ab-cdef-example111118:1",
        "RuntimeVersion": "syn-nodejs-puppeteer-9.1",
        "Tags": {
            "blueprint": "heartbeat"
        }
    }
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[GetCanary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/get-canary.html)」を参照してください。

### `get-group`
<a name="synthetics_GetGroup_cli_2_topic"></a>

次のコード例は、`get-group` を使用する方法を示しています。

**AWS CLI**  
**1 つのグループに関する情報を返すには**  
次の `get-group` の例では、`demo_group` という名前のグループに関する情報を返します。  

```
aws synthetics get-group \
    --group-identifier demo_group
```
出力:  

```
{
    "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"
    }
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[GetGroup](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/get-group.html)」を参照してください。

### `list-associated-groups`
<a name="synthetics_ListAssociatedGroups_cli_2_topic"></a>

次のコード例は、`list-associated-groups` を使用する方法を示しています。

**AWS CLI**  
**グループのリストを返すには**  
次の `list-associated-groups` の例では、`demo_canary` という名前の Canary に関連付けられているグループのリストを返します。  

```
aws synthetics list-associated-groups \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
出力:  

```
{
    "Groups": [
        {
            "Id": "example123",
            "Name": "demo_group",
            "Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123"
        }
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[ListAssociatedGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-associated-groups.html)」を参照してください。

### `list-group-resources`
<a name="synthetics_ListGroupResources_cli_2_topic"></a>

次のコード例は、`list-group-resources` を使用する方法を示しています。

**AWS CLI**  
**指定したグループに関連付けられている Canary の ARN のリストを返すには**  
次の `list-group-resources` の例では、`demo_group` という名前のグループに関連付けられている Canary の ARN のリストを返します。  

```
aws synthetics list-group-resources \
    --group-identifier demo_group
```
出力:  

```
{
    "Resources": [
        "arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary"
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListGroupResources](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-group-resources.html)」を参照してください。

### `list-groups`
<a name="synthetics_ListGroups_cli_2_topic"></a>

次のコード例は、`list-groups` を使用する方法を示しています。

**AWS CLI**  
**アカウントのすべてのグループのリストを返すには**  
次の `list-groups` の例では、アカウントのすべてのグループのリストを返します。  

```
aws synthetics list-groups
```
出力:  

```
{
    "Groups": [
        {
            "Id": "example123",
            "Name": "demo_group",
            "Arn": "arn:aws:synthetics:us-east-1:123456789012:group:example123"
        }
    ]
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListGroups](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-groups.html)」を参照してください。

### `list-tags-for-resource`
<a name="synthetics_ListTagsForResource_cli_2_topic"></a>

次のコード例は、`list-tags-for-resource` を使用する方法を示しています。

**AWS CLI**  
**例 1: Canary に関連付けられているタグを表示するには**  
次の `list-tags-for-resource` の例では、`demo_canary` という名前の Canary に関連付けられているタグを返します。  

```
aws synthetics list-tags-for-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary
```
出力:  

```
{
    "Tags": {
        "blueprint": "heartbeat"
    }
}
```
**例 2: グループに関連付けられているタグを表示するには**  
次の `list-tags-for-resource` の例では、`demo_group` という名前のグループに関連付けられているタグを返します。  

```
aws  synthetics list-tags-for-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:group:example123
```
出力:  

```
{
    "Tags": {
        "team": "Devops"
    }
}
```
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[ListTagsForResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/list-tags-for-resource.html)」を参照してください。

### `start-canary`
<a name="synthetics_StartCanary_cli_2_topic"></a>

次のコード例は、`start-canary` を使用する方法を示しています。

**AWS CLI**  
**Canary を実行するには**  
次の `start-canary` の例では、`demo_canary` という名前の Canary を実行します。  

```
aws synthetics start-canary \
    --name demo_canary
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[StartCanary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/start-canary.html)」を参照してください。

### `stop-canary`
<a name="synthetics_StopCanary_cli_2_topic"></a>

次のコード例は、`stop-canary` を使用する方法を示しています。

**AWS CLI**  
**Canary を停止するには**  
次の `stop-canary` の例では、`demo_canary` という名前の Canary を停止します。  

```
aws synthetics stop-canary \
    --name demo_canary
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[StopCanary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/stop-canary.html)」を参照してください。

### `tag-resource`
<a name="synthetics_TagResource_cli_2_topic"></a>

次のコード例は、`tag-resource` を使用する方法を示しています。

**AWS CLI**  
**例 1: Canary にタグを割り当てるには**  
次の `tag-resource` の例では、`demo_canary` という名前の Canary にタグを割り当てます。  

```
aws synthetics tag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary \
    --tags blueprint=heartbeat
```
このコマンドでは何も出力されません。  
**例 2: グループにタグを割り当てるには**  
次の `tag-resource` の例では、`demo_group` という名前のグループにタグを割り当てます。  

```
aws synthetics tag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:group:example123 \
    --tags team=Devops
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「*AWS CLI コマンドリファレンス*」の「[TagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/tag-resource.html)」を参照してください。

### `untag-resource`
<a name="synthetics_UntagResource_cli_2_topic"></a>

次のコード例は、`untag-resource` を使用する方法を示しています。

**AWS CLI**  
**例 1: Canary からタグを削除するには**  
次の `untag-resource` の例では、`demo_canary` という名前の Canary からタグを削除します。  

```
aws synthetics untag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:canary:demo_canary \
    --tag-keys blueprint
```
このコマンドでは何も出力されません。  
**例 2: グループからタグを削除するには**  
次の `untag-resource` の例では、`demo_group` という名前のグループからタグを削除します。  

```
aws synthetics untag-resource \
    --resource-arn arn:aws:synthetics:us-east-1:123456789012:group:example123 \
    --tag-keys team
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、「AWS CLI コマンドリファレンス」の「[UntagResource](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/untag-resource.html)」を参照してください。

### `update-canary`
<a name="synthetics_UpdateCanary_cli_2_topic"></a>

次のコード例は、`update-canary` を使用する方法を示しています。

**AWS CLI**  
**Canary を更新するには**  
次の `update-canary` の例では、`demo_canary` という名前の Canary の設定を更新します。  

```
aws synthetics update-canary \
    --name demo_canary \
    --schedule Expression="rate(15 minutes)"
```
このコマンドでは何も出力されません。  
詳細については、*Amazon CloudWatch ユーザーガイド*の「[合成モニタリング (Canary)](https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch_Synthetics_Canaries.html)」を参照してください。  
+  API の詳細については、*AWS CLI コマンドリファレンス*の「[UpdateCanary](https://awscli.amazonaws.com/v2/documentation/api/latest/reference/synthetics/update-canary.html)」を参照してください。