> ## Documentation Index
> Fetch the complete documentation index at: https://docs.struct.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS CloudWatch

> CloudWatch logs and metrics.

Connect AWS so Struct Agent can query CloudWatch logs and metrics and inspect the permitted infrastructure context. Use the workspace-specific grant instructions and verify the intended account and role.

## Inspect access and existing connections

Use a claimed workspace with permission to configure connections.

```bash theme={null}
struct whoami --json
struct connections catalog aws --json
struct connections list --json
```

Use the catalog's current fields, choices and permission requirements. Reuse an existing healthy connection instead of creating a duplicate.

## Connect with the CLI

Print the setup material first:

```bash theme={null}
struct connect aws --print-commands
```

An authorized operator runs the generated provider commands after checking the account and scope. Printing them does not apply grants. Preserve generated identifiers (such as an AWS External ID or Snowflake key-pair ID), then run the returned connection command with the real values.

## Verify and recover

Use the returned connection ID:

```bash theme={null}
struct connections show CONNECTION_ID --json
struct connections test CONNECTION_ID --json
```

Inspect `ok`, `health` and missing permissions, not only the exit code. `struct connections grant-command CONNECTION_ID` prints repair instructions where supported; have an authorized operator apply them. For expired OAuth links, start the connection command again and use the new link. Do not reconnect to a different account silently.

Verify a bounded operation for the requested job. Connection health proves checked access; it does not prove telemetry arrival, an investigation or alert delivery.

## What Struct reads

Log groups and streams, CloudWatch Logs Insights queries, metrics, and existing alarms.

## Amazon Managed Service for Prometheus

Struct can discover AMP workspaces and query PromQL through the same assumed-role
connection. Keep the workspace ARN when reusing a query as evidence or a watch.
AMP permissions are optional and do not replace CloudWatch permissions. Query
access needs AMP workspace discovery plus query/label/series permissions; native
alert management additionally needs rule namespace, Alertmanager, and SNS delivery
permissions. The connection permission report shows the required actions.

Existing alert and recording rules remain separate. Struct preserves neighboring
rules and customer notification routes when changing an individual alert, and
reports incomplete inventories or configuration drift explicitly.

## Permissions

The IAM role Struct assumes needs the AWS managed policies CloudWatchReadOnlyAccess and ViewOnlyAccess, plus the `struct-coverage-access` inline policy (89 actions) for Auto Monitors, infrastructure checks and AMP. AMP access is optional for connection readiness; setup includes it.

### Verify permissions

Check the role's own permissions without creating anything.

Granted by: `struct-coverage-access`.

| Permission | Used for |
| - | - |
| `iam:SimulatePrincipalPolicy` | Without it every other check is reported as unverified. |

### Infrastructure inventory

List the account's resources in every enabled region.

Granted by: `ViewOnlyAccess`, `struct-coverage-access`.

Permissions Struct uses: `resource-explorer-2:Search`, `resource-explorer-2:ListResources`, `resource-explorer-2:GetIndex`, `resource-explorer-2:GetView`, `resource-explorer-2:GetDefaultView`, `ec2:DescribeRegions`.

### Resource configuration

Read control-plane configuration without application data or secret values.

Granted by: `struct-coverage-access`.

> [accordion] Permissions Struct uses (51)
>
> ```text theme={null}
> sts:GetCallerIdentity
> ec2:DescribeRegions
> ec2:DescribeInstances
> ec2:DescribeSecurityGroups
> cloudtrail:LookupEvents
> eks:DescribeCluster
> dynamodb:DescribeTable
> s3:GetBucketVersioning
> resource-explorer-2:Search
> resource-explorer-2:ListResources
> resource-explorer-2:ListIndexes
> resource-explorer-2:GetIndex
> resource-explorer-2:GetView
> resource-explorer-2:GetDefaultView
> resource-explorer-2:ListSupportedResourceTypes
> cloudformation:ListTypes
> cloudformation:DescribeType
> cloudformation:ListResources
> cloudformation:GetResource
> iam:SimulatePrincipalPolicy
> iam:GetRole
> iam:ListAttachedRolePolicies
> iam:ListRolePolicies
> iam:GetRolePolicy
> iam:GetPolicy
> iam:GetPolicyVersion
> lambda:GetFunctionConfiguration
> lambda:GetPolicy
> lambda:ListFunctions
> ecs:DescribeServices
> ecs:DescribeTaskDefinition
> ecs:ListServices
> ecs:ListClusters
> ecs:DescribeClusters
> rds:DescribeDBInstances
> rds:DescribeDBClusters
> rds:DescribeDBParameters
> elasticache:DescribeCacheClusters
> elasticache:DescribeReplicationGroups
> elasticloadbalancing:DescribeLoadBalancers
> elasticloadbalancing:DescribeTargetGroups
> elasticloadbalancing:DescribeTargetHealth
> sqs:ListQueues
> sqs:GetQueueUrl
> sqs:GetQueueAttributes
> sqs:ListQueueTags
> sns:GetTopicAttributes
> s3:GetBucketLocation
> s3:GetBucketTagging
> s3:GetBucketNotification
> s3:GetBucketPolicyStatus
> ```

### Metrics

Discover and query CloudWatch metrics.

Granted by: `CloudWatchReadOnlyAccess`.

Permissions Struct uses: `cloudwatch:ListMetrics`, `cloudwatch:GetMetricData`, `cloudwatch:GetMetricStatistics`.

### Logs

Read existing logs and run read-only log queries.

Granted by: `CloudWatchReadOnlyAccess`.

Permissions Struct uses: `logs:DescribeLogGroups`, `logs:FilterLogEvents`, `logs:StartQuery`, `logs:GetQueryResults`, `logs:StopQuery`.

### Infrastructure change history

Read management events to refresh resources that changed.

Granted by: `ViewOnlyAccess`, `struct-coverage-access`.

Permissions Struct uses: `cloudtrail:LookupEvents`.

### Managed Prometheus metrics

Only needed for AMP: discover workspaces and query PromQL using the existing role.

Granted by: `struct-coverage-access`.

Permissions Struct uses: `aps:ListWorkspaces`, `aps:DescribeWorkspace`, `aps:QueryMetrics`, `aps:GetLabels`, `aps:GetSeries`, `aps:GetMetricMetadata`.

### Managed Prometheus rule inventory

Only needed for AMP: inspect existing alerts, recording rules and delivery.

Granted by: `struct-coverage-access`.

Permissions Struct uses: `aps:ListRuleGroupsNamespaces`, `aps:DescribeRuleGroupsNamespace`, `aps:DescribeAlertManagerDefinition`.

### Manage Prometheus alerts

Only needed for AMP: manage native rules, Alertmanager and SNS delivery.

Granted by: `struct-coverage-access`.

> [accordion] Permissions Struct uses (16)
>
> ```text theme={null}
> aps:ListRuleGroupsNamespaces
> aps:DescribeRuleGroupsNamespace
> aps:DescribeAlertManagerDefinition
> aps:CreateRuleGroupsNamespace
> aps:PutRuleGroupsNamespace
> aps:DeleteRuleGroupsNamespace
> aps:CreateAlertManagerDefinition
> aps:PutAlertManagerDefinition
> aps:TagResource
> sns:CreateTopic
> sns:TagResource
> sns:ListTagsForResource
> sns:GetTopicAttributes
> sns:SetTopicAttributes
> sns:ListSubscriptionsByTopic
> sns:Subscribe
> ```

### Manage monitoring

Create, tag, inspect and remove the alarms and metric filters Struct manages, and the SNS topic that delivers alarms to Struct.

Granted by: `struct-coverage-access`.

| Permission | Used for |
| - | - |
| `cloudwatch:DescribeAlarms` | |
| `cloudwatch:ListMetrics` | |
| `cloudwatch:GetMetricData` | |
| `cloudwatch:PutMetricAlarm` | |
| `cloudwatch:DeleteAlarms` | |
| `cloudwatch:ListTagsForResource` | |
| `cloudwatch:TagResource` | Alarms are created with tags, so this is needed alongside cloudwatch:PutMetricAlarm. |
| `cloudwatch:UntagResource` | |
| `logs:DescribeLogGroups` | |
| `logs:DescribeMetricFilters` | Finding the metric filters Struct created. |
| `logs:FilterLogEvents` | |
| `logs:GetLogEvents` | |
| `logs:StartQuery` | |
| `logs:GetQueryResults` | |
| `logs:StopQuery` | |
| `logs:PutMetricFilter` | |
| `logs:DeleteMetricFilter` | |
| `sns:CreateTopic` | |
| `sns:TagResource` | |
| `sns:Subscribe` | |
| `sns:ListSubscriptionsByTopic` | |

* Inventory reads through AWS Resource Explorer. Turn on Resource Explorer indexing in the account and set an unfiltered default view, or Struct reports inventory as incomplete.
* Do not use CloudWatchLogsReadOnlyAccess alone: it cannot list metrics or describe alarms.
* Some configuration responses can include sensitive values, such as Lambda and ECS environment variables. Struct redacts environment variables and known secret-bearing fields before saving resource snapshots.

### How to grant

> [accordion] Create the role (AWS CloudShell)
>
> ```bash theme={null}
> aws iam create-role --role-name=StructCloudWatchRole --assume-role-policy-document '{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Principal": {"AWS": "<struct-principal-arn>"}, "Action": "sts:AssumeRole", "Condition": {"StringEquals": {"sts:ExternalId": "<external-id>"}}}]}' --query 'Role.Arn' --output text &&
> aws iam attach-role-policy --role-name=StructCloudWatchRole --policy-arn arn:aws:iam::aws:policy/job-function/ViewOnlyAccess &&
> aws iam attach-role-policy --role-name=StructCloudWatchRole --policy-arn arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess &&
> aws iam put-role-policy --role-name=StructCloudWatchRole --policy-name struct-coverage-access --policy-document '{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["cloudwatch:DescribeAlarms", "cloudwatch:ListMetrics", "cloudwatch:GetMetricData", "cloudwatch:PutMetricAlarm", "cloudwatch:DeleteAlarms", "cloudwatch:ListTagsForResource", "cloudwatch:TagResource", "cloudwatch:UntagResource", "logs:DescribeLogGroups", "logs:DescribeMetricFilters", "logs:FilterLogEvents", "logs:GetLogEvents", "logs:StartQuery", "logs:GetQueryResults", "logs:StopQuery", "logs:PutMetricFilter", "logs:DeleteMetricFilter", "sns:CreateTopic", "sns:TagResource", "sns:Subscribe", "sns:ListSubscriptionsByTopic", "sts:GetCallerIdentity", "ec2:DescribeRegions", "ec2:DescribeInstances", "ec2:DescribeSecurityGroups", "cloudtrail:LookupEvents", "eks:DescribeCluster", "dynamodb:DescribeTable", "s3:GetBucketVersioning", "resource-explorer-2:Search", "resource-explorer-2:ListResources", "resource-explorer-2:ListIndexes", "resource-explorer-2:GetIndex", "resource-explorer-2:GetView", "resource-explorer-2:GetDefaultView", "resource-explorer-2:ListSupportedResourceTypes", "cloudformation:ListTypes", "cloudformation:DescribeType", "cloudformation:ListResources", "cloudformation:GetResource", "iam:SimulatePrincipalPolicy", "iam:GetRole", "iam:ListAttachedRolePolicies", "iam:ListRolePolicies", "iam:GetRolePolicy", "iam:GetPolicy", "iam:GetPolicyVersion", "lambda:GetFunctionConfiguration", "lambda:GetPolicy", "lambda:ListFunctions", "ecs:DescribeServices", "ecs:DescribeTaskDefinition", "ecs:ListServices", "ecs:ListClusters", "ecs:DescribeClusters", "rds:DescribeDBInstances", "rds:DescribeDBClusters", "rds:DescribeDBParameters", "elasticache:DescribeCacheClusters", "elasticache:DescribeReplicationGroups", "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:DescribeTargetHealth", "sqs:ListQueues", "sqs:GetQueueUrl", "sqs:GetQueueAttributes", "sqs:ListQueueTags", "sns:GetTopicAttributes", "s3:GetBucketLocation", "s3:GetBucketTagging", "s3:GetBucketNotification", "s3:GetBucketPolicyStatus", "aps:ListWorkspaces", "aps:DescribeWorkspace", "aps:QueryMetrics", "aps:GetLabels", "aps:GetSeries", "aps:GetMetricMetadata", "aps:ListRuleGroupsNamespaces", "aps:DescribeRuleGroupsNamespace", "aps:DescribeAlertManagerDefinition", "aps:CreateRuleGroupsNamespace", "aps:PutRuleGroupsNamespace", "aps:DeleteRuleGroupsNamespace", "aps:CreateAlertManagerDefinition", "aps:PutAlertManagerDefinition", "aps:TagResource", "sns:ListTagsForResource", "sns:SetTopicAttributes"], "Resource": "*"}]}'
> ```

> [accordion] Update an existing role
>
> ```bash theme={null}
> aws iam attach-role-policy --role-name=<role-name> --policy-arn arn:aws:iam::aws:policy/job-function/ViewOnlyAccess &&
> aws iam attach-role-policy --role-name=<role-name> --policy-arn arn:aws:iam::aws:policy/CloudWatchReadOnlyAccess &&
> aws iam put-role-policy --role-name=<role-name> --policy-name struct-coverage-access --policy-document '{"Version": "2012-10-17", "Statement": [{"Effect": "Allow", "Action": ["cloudwatch:DescribeAlarms", "cloudwatch:ListMetrics", "cloudwatch:GetMetricData", "cloudwatch:PutMetricAlarm", "cloudwatch:DeleteAlarms", "cloudwatch:ListTagsForResource", "cloudwatch:TagResource", "cloudwatch:UntagResource", "logs:DescribeLogGroups", "logs:DescribeMetricFilters", "logs:FilterLogEvents", "logs:GetLogEvents", "logs:StartQuery", "logs:GetQueryResults", "logs:StopQuery", "logs:PutMetricFilter", "logs:DeleteMetricFilter", "sns:CreateTopic", "sns:TagResource", "sns:Subscribe", "sns:ListSubscriptionsByTopic", "sts:GetCallerIdentity", "ec2:DescribeRegions", "ec2:DescribeInstances", "ec2:DescribeSecurityGroups", "cloudtrail:LookupEvents", "eks:DescribeCluster", "dynamodb:DescribeTable", "s3:GetBucketVersioning", "resource-explorer-2:Search", "resource-explorer-2:ListResources", "resource-explorer-2:ListIndexes", "resource-explorer-2:GetIndex", "resource-explorer-2:GetView", "resource-explorer-2:GetDefaultView", "resource-explorer-2:ListSupportedResourceTypes", "cloudformation:ListTypes", "cloudformation:DescribeType", "cloudformation:ListResources", "cloudformation:GetResource", "iam:SimulatePrincipalPolicy", "iam:GetRole", "iam:ListAttachedRolePolicies", "iam:ListRolePolicies", "iam:GetRolePolicy", "iam:GetPolicy", "iam:GetPolicyVersion", "lambda:GetFunctionConfiguration", "lambda:GetPolicy", "lambda:ListFunctions", "ecs:DescribeServices", "ecs:DescribeTaskDefinition", "ecs:ListServices", "ecs:ListClusters", "ecs:DescribeClusters", "rds:DescribeDBInstances", "rds:DescribeDBClusters", "rds:DescribeDBParameters", "elasticache:DescribeCacheClusters", "elasticache:DescribeReplicationGroups", "elasticloadbalancing:DescribeLoadBalancers", "elasticloadbalancing:DescribeTargetGroups", "elasticloadbalancing:DescribeTargetHealth", "sqs:ListQueues", "sqs:GetQueueUrl", "sqs:GetQueueAttributes", "sqs:ListQueueTags", "sns:GetTopicAttributes", "s3:GetBucketLocation", "s3:GetBucketTagging", "s3:GetBucketNotification", "s3:GetBucketPolicyStatus", "aps:ListWorkspaces", "aps:DescribeWorkspace", "aps:QueryMetrics", "aps:GetLabels", "aps:GetSeries", "aps:GetMetricMetadata", "aps:ListRuleGroupsNamespaces", "aps:DescribeRuleGroupsNamespace", "aps:DescribeAlertManagerDefinition", "aps:CreateRuleGroupsNamespace", "aps:PutRuleGroupsNamespace", "aps:DeleteRuleGroupsNamespace", "aps:CreateAlertManagerDefinition", "aps:PutAlertManagerDefinition", "aps:TagResource", "sns:ListTagsForResource", "sns:SetTopicAttributes"], "Resource": "*"}]}' && struct_legacy_policies=$(aws iam list-role-policies --role-name=<role-name> --query "PolicyNames[?@ == 'struct-managed-monitors-write' || starts_with(@, 'struct-coverage-infrastructure-') || starts_with(@, 'struct-coverage-monitors-')]" --output text) && (for name in $struct_legacy_policies; do aws iam delete-role-policy --role-name=<role-name> --policy-name "$name" || exit; done)
> ```

> [accordion] The struct-coverage-access inline policy
>
> ```json theme={null}
> {
>   "Version": "2012-10-17",
>   "Statement": [
>     {
>       "Effect": "Allow",
>       "Action": [
>         "cloudwatch:DescribeAlarms",
>         "cloudwatch:ListMetrics",
>         "cloudwatch:GetMetricData",
>         "cloudwatch:PutMetricAlarm",
>         "cloudwatch:DeleteAlarms",
>         "cloudwatch:ListTagsForResource",
>         "cloudwatch:TagResource",
>         "cloudwatch:UntagResource",
>         "logs:DescribeLogGroups",
>         "logs:DescribeMetricFilters",
>         "logs:FilterLogEvents",
>         "logs:GetLogEvents",
>         "logs:StartQuery",
>         "logs:GetQueryResults",
>         "logs:StopQuery",
>         "logs:PutMetricFilter",
>         "logs:DeleteMetricFilter",
>         "sns:CreateTopic",
>         "sns:TagResource",
>         "sns:Subscribe",
>         "sns:ListSubscriptionsByTopic",
>         "sts:GetCallerIdentity",
>         "ec2:DescribeRegions",
>         "ec2:DescribeInstances",
>         "ec2:DescribeSecurityGroups",
>         "cloudtrail:LookupEvents",
>         "eks:DescribeCluster",
>         "dynamodb:DescribeTable",
>         "s3:GetBucketVersioning",
>         "resource-explorer-2:Search",
>         "resource-explorer-2:ListResources",
>         "resource-explorer-2:ListIndexes",
>         "resource-explorer-2:GetIndex",
>         "resource-explorer-2:GetView",
>         "resource-explorer-2:GetDefaultView",
>         "resource-explorer-2:ListSupportedResourceTypes",
>         "cloudformation:ListTypes",
>         "cloudformation:DescribeType",
>         "cloudformation:ListResources",
>         "cloudformation:GetResource",
>         "iam:SimulatePrincipalPolicy",
>         "iam:GetRole",
>         "iam:ListAttachedRolePolicies",
>         "iam:ListRolePolicies",
>         "iam:GetRolePolicy",
>         "iam:GetPolicy",
>         "iam:GetPolicyVersion",
>         "lambda:GetFunctionConfiguration",
>         "lambda:GetPolicy",
>         "lambda:ListFunctions",
>         "ecs:DescribeServices",
>         "ecs:DescribeTaskDefinition",
>         "ecs:ListServices",
>         "ecs:ListClusters",
>         "ecs:DescribeClusters",
>         "rds:DescribeDBInstances",
>         "rds:DescribeDBClusters",
>         "rds:DescribeDBParameters",
>         "elasticache:DescribeCacheClusters",
>         "elasticache:DescribeReplicationGroups",
>         "elasticloadbalancing:DescribeLoadBalancers",
>         "elasticloadbalancing:DescribeTargetGroups",
>         "elasticloadbalancing:DescribeTargetHealth",
>         "sqs:ListQueues",
>         "sqs:GetQueueUrl",
>         "sqs:GetQueueAttributes",
>         "sqs:ListQueueTags",
>         "sns:GetTopicAttributes",
>         "s3:GetBucketLocation",
>         "s3:GetBucketTagging",
>         "s3:GetBucketNotification",
>         "s3:GetBucketPolicyStatus",
>         "aps:ListWorkspaces",
>         "aps:DescribeWorkspace",
>         "aps:QueryMetrics",
>         "aps:GetLabels",
>         "aps:GetSeries",
>         "aps:GetMetricMetadata",
>         "aps:ListRuleGroupsNamespaces",
>         "aps:DescribeRuleGroupsNamespace",
>         "aps:DescribeAlertManagerDefinition",
>         "aps:CreateRuleGroupsNamespace",
>         "aps:PutRuleGroupsNamespace",
>         "aps:DeleteRuleGroupsNamespace",
>         "aps:CreateAlertManagerDefinition",
>         "aps:PutAlertManagerDefinition",
>         "aps:TagResource",
>         "sns:ListTagsForResource",
>         "sns:SetTopicAttributes"
>       ],
>       "Resource": "*"
>     }
>   ]
> }
> ```

Replace the values in angle brackets.

Permission catalog version `2026-11-04.1`. See [permission changes](https://docs.struct.ai/reference/permission-changes.md).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.