Grok Bot for read-only AWS operations A developer built a setup giving xAI's Grok Bot read-only access to an AWS account without long-lived access keys, using a single IAM role that trusts short-lived OIDC tokens minted on the agent machine and exchanged via STS AssumeRoleWithWebIdentity. The same role serves chat questions, scheduled cost and quota reports, and CloudWatch alarm investigations routed through an EventBridge webhook, with the role's trust policy pinned to an exact subject and audience. In a test, an alarm on Step Functions ExecutionsFailed correctly identified a state machine whose only state is Fail and suggested removing or excluding it from the alarm query. Grok Bot https://docs.x.ai/grok-bot/overview is an agent with a cloud computer. You ask it in chat, and it can run routines on a schedule or from a webhook. This post gives that Bot read-only access to an AWS account, with no access key. One IAM role trusts an OIDC token, and that role cannot change the account. Three uses share it: a question in chat, a report from a routine, and a written report when a CloudWatch alarm fires. Questions can be raised in chat. Grok Bot assumes the read-only role and can use any read API that role allows. A routine runs on a schedule, uses the same role, and posts the report in chat. The schedule belongs to the routine. It is not an EventBridge rule, and the routine does not get a second role. A report can be current costs, or a specific metric such as API quotas. A CloudWatch alarm that enters ALARM is posted by an EventBridge connection to a Grok Bot webhook. The routine investigates and replies with what fired, the evidence, a likely cause, a suggested fix, and how urgent it is. The webhook body is data, not instructions. SFN-Alarm watches ExecutionsFailed across Step Functions state machines, from One CloudWatch alarm for many resources https://johanneskonings.dev/blog/2025-12-13-cdk-monitor-multiple-resources-using-single-alarm/ . Set to ALARM with no failed executions, the report called it a manual test. A later execution failed because the state machine's only state is Fail. It was started from the console, failed after 38 ms, and the alarm entered ALARM one minute later. The report named that state machine and suggested removing it or excluding it from the alarm query. The original post https://johanneskonings.dev/blog/2026-11-28-aws-ops-grok-bot-cursor-oidc/ has an interactive version of this diagram. The corner mark on each entry opens that path on its own. The bot does not hold an access key. It mints an OIDC token on the agent machine, then passes that token to STS. The mint is a POST to the local socket, with audience sts.amazonaws.com , as documented in OIDC tokens for cloud agents https://cursor.com/docs/cloud-agent/identity : curl --unix-socket "${CURSOR AGENT SOCKET}" \ -H 'Content-Type: application/json' \ -d '{"aud":"sts.amazonaws.com"}' \ http://cursor-agent/v1/tokens/oidc The JWT is valid for about 5 minutes. It is only used at assume time. The bot then calls STS, and the one hour is the STS session maxSessionDuration on the role, --duration-seconds 3600 on the call : aws sts assume-role-with-web-identity \ --role-arn "$GROK BOT OPS READ ONLY ROLE ARN" \ --role-session-name grok-bot-ops \ --web-identity-token "$OIDC TOKEN" \ --duration-seconds 3600 The issuer is https://api.cursor.com . The audience is sts.amazonaws.com . Discovery is https://api.cursor.com/.well-known/openid-configuration . GrokBotOpsReadOnlySetup https://github.com/JohannesKonings/tanstack-aws/blob/main/apps/cdk-account-setup/lib/constructs/GrokBotOpsReadOnlySetup.ts L80-L96 imports that provider and creates GrokBotOpsReadOnlyRole in AccountSetupStack us-east-1 . Trust is sts:AssumeRoleWithWebIdentity with two StringEquals conditions: api.cursor.com:aud is sts.amazonaws.com , and api.cursor.com:sub is one exact subject. A wildcard, a question mark, or whitespace fails synthesis. The tanstack-aws deployment reads that subject from API CURSOR SUB in the envs secret in Secrets Manager us-east-2 , so the value is not in git. this.oidcProvider = OidcProviderNative.fromOidcProviderArn this, "Provider", oidcProviderArn props.config.oidcUrl , ; this.role = new Role this, "Role", { roleName: "GrokBotOpsReadOnlyRole", maxSessionDuration: Duration.hours 1 , assumedBy: new WebIdentityPrincipal this.oidcProvider.openIdConnectProviderArn, { StringEquals: { ${issuerHost}:aud : props.config.oidcAudience, ${issuerHost}:sub : allowedSubject, }, } , } ; Grok Bot agents share one computer. Any agent on that computer can mint a token for the trusted subject and assume the role. The trust policy matches the subject, not an agent. There is no control today that limits the role to one agent. The role stays read-only for that reason. The permissions are on GrokBotOpsReadOnlyRole https://github.com/JohannesKonings/tanstack-aws/blob/main/apps/cdk-account-setup/lib/constructs/GrokBotOpsReadOnlySetup.ts L98-L127 . The role has the AWS managed policy ReadOnlyAccess , plus two small statements: ce:Get , ce:Describe , and ce:List . Cost Explorer has no resource-level permissions, so those actions use Resource . cloudformation:DetectStackDrift and cloudformation:DetectStackResourceDrift on stacks in this account. Starting a drift check does not change the stack. An explicit deny, DENY SECRET AND DATA READS https://github.com/JohannesKonings/tanstack-aws/blob/main/apps/cdk-account-setup/lib/constructs/GrokBotOpsReadOnlySetup.ts L24-L56 , blocks the reads that would return secret or data-plane values: Secrets Manager secret values, SSM parameter values, kms:Decrypt , EC2 passwords, ECR authorization tokens, S3 object bytes, DynamoDB items, the RDS Data API, the Redshift Data API, and Lambda function code and configuration. Describe and list stay allowed, including secretsmanager:DescribeSecret and secretsmanager:ListSecrets . this.role.addManagedPolicy ManagedPolicy.fromAwsManagedPolicyName "ReadOnlyAccess" ; this.role.addToPolicy new PolicyStatement { sid: "DenySecretAndDataPlaneReads", effect: Effect.DENY, actions: DENY SECRET AND DATA READS, resources: " " , } , ; Log groups that use the default CloudWatch Logs encryption stay readable. A log group encrypted with a customer key needs kms:Decrypt , which this role denies. The alarm routine's first call after assuming the role is DescribeAlarms , to confirm the credentials and to read the alarm that fired. GrokBotAlarmForwarding https://github.com/JohannesKonings/tanstack-aws/blob/main/apps/cdk-account-setup/lib/constructs/GrokBotAlarmForwarding.ts L31-L78 runs in the workload region, us-east-2 . CloudWatch publishes the state change on the event bus in the alarm's region, so an alarm in us-east-1 a billing alarm, for example is not forwarded. The rule matches every alarm in the region that enters ALARM , not a named list. The connection sends Authorization: Bearer