SyncValsverifier → artifact → classifier → verdict
SyncVals · Trajectory

appsync-graphql-cognito-resolver-cache-leak

claude-code claude-opus-4-7 ✓ resolved GOOD_SUCCESS ↑ View task
Solved from the instruction alone, tests/ and solution/ were withheld from the agent's workspace and restored only for grading.
Reward = tests/test.sh exit code (0 → resolved); the classification below is post-hoc and cannot change it.
Classification , post-hoc; cannot change the reward
GOOD_SUCCESSLegitimate solve, implements the asked-for behavior; tests verify real functionality.
SubtypeLegitimate Solution
EvidenceAgent systematically diagnosed the multi-tenant GraphQL API infrastructure by querying SSM, AppSync, IAM, Cognito, and KMS resources. Fixed all blocking security audit findings: (1) `test_17_user_pool_config_default_action_deny` PASSED - changed defaultAction from ALLOW to DENY, (2) `test_50_xray_enabled_on_api` PASSED - enabled X-Ray, (3) `test_48_log_config_field_log_level_all_with_logs_role` PASSED - changed fieldLogLevel to ALL, (4) `test_20_additional_auth_does_not_include_iam` PASSED - removed AWS_IAM from additionalAuthenticationProviders, (5) `test_26_svc_role_grants_kms_decrypt_on_cmk` PASSED - added KMS decrypt/encrypt/generateDataKey permissions to service role. All 57 tests passed including cache configuration (test_38, test_40), mutation condition checks (test_45), schema validation (test_54), and API key expiry (test_43).
Root causeThe agent correctly understood the multi-tenant security requirements from the instruction.md audit findings and systematically fixed all blocking issues through targeted AWS API updates to AppSync configuration and IAM policies, verified by 57 comprehensive security and configuration assertions.
RecommendationN/A - task is fine
Trajectory
Tool-by-tool agent trajectory
118 tool calls · 3 tool types · 118 steps
a multi-tenant GraphQL surface (an AppSync API `harbor-graphql-api` fronting a Cognito user pool with a `tenants` group and a DynamoDB table `harbor-things`) was handed off by a mobile team mid-rebuild. internal security passed it through their audit and rejected it. the resources exist and most of the wiring is in place , read the SSM manifest under `/harbor/graphql/*` to get the names and ids the team published. the audit's blocking findings, in their words, are: > The read path can return one tenant's row to another tenant , the cache key list and the caching mode are both wrong, so the cache itself isn't tenant-scoped. The read path also makes a strongly-consistent DDB fetch that silently bypasses the cache layer regardless of how the cache is configured. The write path lets a client claim a tenant they don't belong to. The monitoring service's read-only key can mutate the table. The data fetch role lacks key material for the encrypted table and AccessDenied surfaces at request time, not at provision time. The auth gate on the read path never rejects a missing-group token and intermittently rejects a valid one. The resolver pipeline runs steps in an order that lets data come back before the auth gate has decided anything. The cache is hot and large; clearing it doesn't help , the cache key list is the problem, and so is the caching mode the API was put on. > > Tracking issues, not blockers but in scope for this fix: the API's default authorization mode is wrong for a deny-by-default schema; x-ray is off; field-level logging is at the wrong level; the mutation can silently overwrite existing rows; the read-only API key's expiry is well outside the weekly-rotation window; the additional auth providers list contains a provider the API didn't authorize. the environment is reachable at `$AWS_ENDPOINT_URL`, `ENFORCE_IAM=1`, account `000000000000`, region `us-east-1`. you have one shot to diagnose and fix everything; the verifier walks more than 50 separate assertions on resource shape, VTL bodies (request AND response templates of both functions and both resolvers), schema SDL (type-level and field-level), IAM policy JSON, and cache config. recreating an individual resource is fine when its config can't be changed in place (schema replace, function VTL rewrite, etc.). don't rename or relocate resources or SSM keys , the SSM manifest must keep resolving to the new state. inspect what's actually deployed end-to-end before you fix anything. some of the bugs are shape, some are subtle VTL (mapping template request AND response sides; protocol version field; claim access syntax for claim names that aren't valid identifiers), and some are schema (a directive that shouldn't be there, an argument that shouldn't be client-settable). all of the bugs are independent , each one on its own is enough to fail the audit.
Bash
{
  "command": "echo \"AWS_ENDPOINT_URL=$AWS_ENDPOINT_URL\"; echo \"ENFORCE_IAM=$ENFORCE_IAM\"; aws --version 2>&1 | head -1",
  "description": "Check environment variables and AWS CLI"
}
output
AWS_ENDPOINT_URL=http://localstack:4566
ENFORCE_IAM=
aws-cli/2.34.48 Python/3.14.4 Linux/6.10.14-linuxkit exe/aarch64.ubuntu.24

[stdout]
AWS_ENDPOINT_URL=http://localstack:4566
ENFORCE_IAM=
aws-cli/2.34.48 Python/3.14.4 Linux/6.10.14-linuxkit exe/aarch64.ubuntu.24
Bash
{
  "command": "aws ssm get-parameters-by-path --path /harbor/graphql --recursive --region us-east-1 --output json 2>&1",
  "description": "List SSM manifest under /harbor/graphql"
}
output
{
    "Parameters": [
        {
            "Name": "/harbor/graphql/api-id",
            "Type": "String",
            "Value": "3061ea0733034e6d92abb18c27",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:01.096000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/api-id",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/user-pool-id",
            "Type": "String",
            "Value": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:01.487000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/user-pool-id",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/app-client-id",
            "Type": "String",
            "Value": "uht2zmpgairdfnk7tl6lwcg0h0",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:01.888000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/app-client-id",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/group-name",
            "Type": "String",
            "Value": "tenants",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:02.265000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/group-name",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/ddb-table",
            "Type": "String",
            "Value": "harbor-things",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:02.659000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/ddb-table",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/kms-key-arn",
            "Type": "String",
            "Value": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:03.027000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/kms-key-arn",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/log-group-name",
            "Type": "String",
            "Value": "/aws/appsync/apis/harbor-graphql-api",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:03.431000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/log-group-name",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/svc-role-arn",
            "Type": "String",
            "Value": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:03.836000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/svc-role-arn",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/logs-role-arn",
            "Type": "String",
            "Value": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:04.218000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/logs-role-arn",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/data-source",
            "Type": "String",
            "Value": "things_table",
            "Version": 1,
            "LastModifiedDate": "2026-05-16T02:55:04.591000+00:00",
            "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/data-source",
            "DataType": "text"
        },
        {
            "Name": "/harbor/graphql/api-key",
            "Type": "String",
            "Value": "971f7adc",
            "Version": 1,
            "LastModifie
…[truncated]
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync get-graphql-api --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "Get GraphQL API config"
}
output
{
    "graphqlApi": {
        "name": "harbor-graphql-api",
        "apiId": "3061ea0733034e6d92abb18c27",
        "authenticationType": "AMAZON_COGNITO_USER_POOLS",
        "logConfig": {
            "fieldLogLevel": "ERROR",
            "cloudWatchLogsRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "excludeVerboseContent": true
        },
        "userPoolConfig": {
            "userPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "awsRegion": "us-east-1",
            "defaultAction": "ALLOW"
        },
        "arn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27",
        "uris": {
            "GRAPHQL": "http://localhost.localstack.cloud:4566/graphql/3061ea0733034e6d92abb18c27",
            "REALTIME": "ws://localhost.localstack.cloud:4510/graphql/3061ea0733034e6d92abb18c27"
        },
        "tags": {},
        "additionalAuthenticationProviders": [
            {
                "authenticationType": "API_KEY"
            },
            {
                "authenticationType": "AWS_IAM"
            }
        ],
        "xrayEnabled": false
    }
}

[stdout]
{
    "graphqlApi": {
        "name": "harbor-graphql-api",
        "apiId": "3061ea0733034e6d92abb18c27",
        "authenticationType": "AMAZON_COGNITO_USER_POOLS",
        "logConfig": {
            "fieldLogLevel": "ERROR",
            "cloudWatchLogsRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "excludeVerboseContent": true
        },
        "userPoolConfig": {
            "userPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "awsRegion": "us-east-1",
            "defaultAction": "ALLOW"
        },
        "arn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27",
        "uris": {
            "GRAPHQL": "http://localhost.localstack.cloud:4566/graphql/3061ea0733034e6d92abb18c27",
            "REALTIME": "ws://localhost.localstack.cloud:4510/graphql/3061ea0733034e6d92abb18c27"
        },
        "tags": {},
        "additionalAuthenticationProviders": [
            {
                "authenticationType": "API_KEY"
            },
            {
                "authenticationType": "AWS_IAM"
            }
        ],
        "xrayEnabled": false
    }
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync get-introspection-schema --api-id $API_ID --format SDL --region us-east-1 /tmp/schema.graphql 2>&1; cat /tmp/schema.graphql 2>/dev/null",
  "description": "Get GraphQL schema SDL"
}
output
type Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  id: ID!
  name: String!
  ownerId: String!
  tenantId: String!
}

type Query @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  getThing(id: ID!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

type Mutation @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  addThing(id: ID!, name: String!, tenantId: String!, ownerId: String!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

schema {
  query: Query
  mutation: Mutation
}

[stdout]
type Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  id: ID!
  name: String!
  ownerId: String!
  tenantId: String!
}

type Query @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  getThing(id: ID!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

type Mutation @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  addThing(id: ID!, name: String!, tenantId: String!, ownerId: String!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

schema {
  query: Query
  mutation: Mutation
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync list-data-sources --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "List data sources"
}
output
{
    "dataSources": [
        {
            "dataSourceArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/datasources/things_table",
            "name": "things_table",
            "type": "AMAZON_DYNAMODB",
            "serviceRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
            "dynamodbConfig": {
                "tableName": "harbor-things",
                "awsRegion": "us-east-1",
                "useCallerCredentials": false,
                "versioned": false
            }
        }
    ]
}

[stdout]
{
    "dataSources": [
        {
            "dataSourceArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/datasources/things_table",
            "name": "things_table",
            "type": "AMAZON_DYNAMODB",
            "serviceRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
            "dynamodbConfig": {
                "tableName": "harbor-things",
                "awsRegion": "us-east-1",
                "useCallerCredentials": false,
                "versioned": false
            }
        }
    ]
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync list-functions --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "List functions"
}
output
{
    "functions": [
        {
            "functionId": "71a59343",
            "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/71a59343",
            "name": "auth_check",
            "dataSourceName": "things_table",
            "requestMappingTemplate": "#set( $groups = $ctx.identity.claims.cognito:groups )\n#if( $util.isNull($groups) )\n  $util.unauthorized()\n#end\n#if( !$groups.contains(\"tenants\") )\n  $util.unauthorized()\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"payload\": {}\n}",
            "responseMappingTemplate": "$util.toJson($ctx.prev.result)",
            "functionVersion": "2018-05-29",
            "maxBatchSize": 0
        },
        {
            "functionId": "623d6c3a",
            "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/623d6c3a",
            "name": "get_thing_data",
            "dataSourceName": "things_table",
            "requestMappingTemplate": "{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"GetItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"consistentRead\": true\n}",
            "responseMappingTemplate": "$util.toJson($ctx.result)",
            "functionVersion": "2018-05-29",
            "maxBatchSize": 0
        }
    ]
}

[stdout]
{
    "functions": [
        {
            "functionId": "71a59343",
            "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/71a59343",
            "name": "auth_check",
            "dataSourceName": "things_table",
            "requestMappingTemplate": "#set( $groups = $ctx.identity.claims.cognito:groups )\n#if( $util.isNull($groups) )\n  $util.unauthorized()\n#end\n#if( !$groups.contains(\"tenants\") )\n  $util.unauthorized()\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"payload\": {}\n}",
            "responseMappingTemplate": "$util.toJson($ctx.prev.result)",
            "functionVersion": "2018-05-29",
            "maxBatchSize": 0
        },
        {
            "functionId": "623d6c3a",
            "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/623d6c3a",
            "name": "get_thing_data",
            "dataSourceName": "things_table",
            "requestMappingTemplate": "{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"GetItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"consistentRead\": true\n}",
            "responseMappingTemplate": "$util.toJson($ctx.result)",
            "functionVersion": "2018-05-29",
            "maxBatchSize": 0
        }
    ]
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync list-resolvers --api-id $API_ID --type-name Query --region us-east-1 --output json 2>&1\necho \"---\"\naws appsync list-resolvers --api-id $API_ID --type-name Mutation --region us-east-1 --output json 2>&1",
  "description": "List Query and Mutation resolvers"
}
output
{
    "resolvers": [
        {
            "typeName": "Query",
            "fieldName": "getThing",
            "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Query/resolvers/getThing",
            "requestMappingTemplate": "{}",
            "responseMappingTemplate": "$util.toJson($ctx.result)",
            "kind": "PIPELINE",
            "pipelineConfig": {
                "functions": [
                    "623d6c3a",
                    "71a59343"
                ]
            },
            "cachingConfig": {
                "ttl": 600,
                "cachingKeys": [
                    "$context.arguments.id"
                ]
            },
            "maxBatchSize": 0
        }
    ]
}
---
{
    "resolvers": [
        {
            "typeName": "Mutation",
            "fieldName": "addThing",
            "dataSourceName": "things_table",
            "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Mutation/resolvers/addThing",
            "requestMappingTemplate": "#set( $tenant = $ctx.identity.claims.get(\"tenant_id\") )\n#set( $owner = $ctx.identity.username )\n#if( $util.isNull($tenant) )\n  $util.error(\"tenant_id claim missing\", \"Unauthorized\")\n#end\n{\n  \"version\": \"2017-02-28\",\n  \"operation\": \"PutItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"attributeValues\": {\n    \"name\": $util.dynamodb.toDynamoDBJson($ctx.arguments.name),\n    \"tenantId\": $util.dynamodb.toDynamoDBJson($tenant),\n    \"ownerId\": $util.dynamodb.toDynamoDBJson($owner)\n  }\n}",
            "responseMappingTemplate": "$util.toJson($ctx.result)",
            "kind": "UNIT",
            "maxBatchSize": 0
        }
    ]
}

[stdout]
{
    "resolvers": [
        {
            "typeName": "Query",
            "fieldName": "getThing",
            "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Query/resolvers/getThing",
            "requestMappingTemplate": "{}",
            "responseMappingTemplate": "$util.toJson($ctx.result)",
            "kind": "PIPELINE",
            "pipelineConfig": {
                "functions": [
                    "623d6c3a",
                    "71a59343"
                ]
            },
            "cachingConfig": {
                "ttl": 600,
                "cachingKeys": [
                    "$context.arguments.id"
                ]
            },
            "maxBatchSize": 0
        }
    ]
}
---
{
    "resolvers": [
        {
            "typeName": "Mutation",
            "fieldName": "addThing",
            "dataSourceName": "things_table",
            "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Mutation/resolvers/addThing",
            "requestMappingTemplate": "#set( $tenant = $ctx.identity.claims.get(\"tenant_id\") )\n#set( $owner = $ctx.identity.username )\n#if( $util.isNull($tenant) )\n  $util.error(\"tenant_id claim missing\", \"Unauthorized\")\n#end\n{\n  \"version\": \"2017-02-28\",\n  \"operation\": \"PutItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"attributeValues\": {\n    \"name\": $util.dynamodb.toDynamoDBJson($ctx.arguments.name),\n    \"tenantId\": $util.dynamodb.toDynamoDBJson($tenant),\n    \"ownerId\": $util.dynamodb.toDynamoDBJson($owner)\n  }\n}",
            "responseMappingTemplate": "$util.toJson($ctx.result)",
            "kind": "UNIT",
            "maxBatchSize": 0
        }
    ]
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync get-api-cache --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "Get API cache config"
}
output
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "FULL_REQUEST_CACHING",
        "type": "SMALL"
    }
}

[stdout]
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "FULL_REQUEST_CACHING",
        "type": "SMALL"
    }
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync list-api-keys --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "List API keys"
}
output
{
    "apiKeys": [
        {
            "id": "971f7adc",
            "expires": 1810432800,
            "deletes": 1815616800
        }
    ]
}

[stdout]
{
    "apiKeys": [
        {
            "id": "971f7adc",
            "expires": 1810432800,
            "deletes": 1815616800
        }
    ]
}
Bash
{
  "command": "aws dynamodb describe-table --table-name harbor-things --region us-east-1 --output json 2>&1",
  "description": "Describe DynamoDB table"
}
output
{
    "Table": {
        "AttributeDefinitions": [
            {
                "AttributeName": "id",
                "AttributeType": "S"
            }
        ],
        "TableName": "harbor-things",
        "KeySchema": [
            {
                "AttributeName": "id",
                "KeyType": "HASH"
            }
        ],
        "TableStatus": "ACTIVE",
        "CreationDateTime": "2026-05-16T02:54:50.352000+00:00",
        "ProvisionedThroughput": {
            "LastIncreaseDateTime": "1970-01-01T00:00:00+00:00",
            "LastDecreaseDateTime": "1970-01-01T00:00:00+00:00",
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 0,
            "WriteCapacityUnits": 0
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things",
        "TableId": "fdab7b2f-a01d-4fc9-aebc-78cf88bd4f77",
        "BillingModeSummary": {
            "BillingMode": "PAY_PER_REQUEST",
            "LastUpdateToPayPerRequestDateTime": "2026-05-16T02:54:50.352000+00:00"
        },
        "SSEDescription": {
            "Status": "ENABLED",
            "SSEType": "KMS",
            "KMSMasterKeyArn": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d"
        },
        "DeletionProtectionEnabled": false,
        "WarmThroughput": {
            "ReadUnitsPerSecond": 12000,
            "WriteUnitsPerSecond": 4000,
            "Status": "ACTIVE"
        }
    }
}

[stdout]
{
    "Table": {
        "AttributeDefinitions": [
            {
                "AttributeName": "id",
                "AttributeType": "S"
            }
        ],
        "TableName": "harbor-things",
        "KeySchema": [
            {
                "AttributeName": "id",
                "KeyType": "HASH"
            }
        ],
        "TableStatus": "ACTIVE",
        "CreationDateTime": "2026-05-16T02:54:50.352000+00:00",
        "ProvisionedThroughput": {
            "LastIncreaseDateTime": "1970-01-01T00:00:00+00:00",
            "LastDecreaseDateTime": "1970-01-01T00:00:00+00:00",
            "NumberOfDecreasesToday": 0,
            "ReadCapacityUnits": 0,
            "WriteCapacityUnits": 0
        },
        "TableSizeBytes": 0,
        "ItemCount": 0,
        "TableArn": "arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things",
        "TableId": "fdab7b2f-a01d-4fc9-aebc-78cf88bd4f77",
        "BillingModeSummary": {
            "BillingMode": "PAY_PER_REQUEST",
            "LastUpdateToPayPerRequestDateTime": "2026-05-16T02:54:50.352000+00:00"
        },
        "SSEDescription": {
            "Status": "ENABLED",
            "SSEType": "KMS",
            "KMSMasterKeyArn": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d"
        },
        "DeletionProtectionEnabled": false,
        "WarmThroughput": {
            "ReadUnitsPerSecond": 12000,
            "WriteUnitsPerSecond": 4000,
            "Status": "ACTIVE"
        }
    }
}
Bash
{
  "command": "aws iam list-roles --region us-east-1 --output json 2>&1 | head -100",
  "description": "List IAM roles"
}
output
{
    "Roles": [
        {
            "Path": "/",
            "RoleName": "harbor-appsync-logs-role",
            "RoleId": "AROAQAAAAAAAGFXLSUDBF",
            "Arn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "CreateDate": "2026-05-16T02:54:53.019225+00:00",
            "AssumeRolePolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Principal": {
                            "Service": "appsync.amazonaws.com"
                        },
                        "Action": "sts:AssumeRole"
                    }
                ]
            },
            "MaxSessionDuration": 3600
        },
        {
            "Path": "/",
            "RoleName": "harbor-appsync-svc-role",
            "RoleId": "AROAQAAAAAAAOHQGBJVDV",
            "Arn": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
            "CreateDate": "2026-05-16T02:54:52.246731+00:00",
            "AssumeRolePolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Principal": {
                            "Service": "appsync.amazonaws.com"
                        },
                        "Action": "sts:AssumeRole"
                    }
                ]
            },
            "MaxSessionDuration": 3600
        }
    ]
}

[stdout]
{
    "Roles": [
        {
            "Path": "/",
            "RoleName": "harbor-appsync-logs-role",
            "RoleId": "AROAQAAAAAAAGFXLSUDBF",
            "Arn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "CreateDate": "2026-05-16T02:54:53.019225+00:00",
            "AssumeRolePolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Principal": {
                            "Service": "appsync.amazonaws.com"
                        },
                        "Action": "sts:AssumeRole"
                    }
                ]
            },
            "MaxSessionDuration": 3600
        },
        {
            "Path": "/",
            "RoleName": "harbor-appsync-svc-role",
            "RoleId": "AROAQAAAAAAAOHQGBJVDV",
            "Arn": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
            "CreateDate": "2026-05-16T02:54:52.246731+00:00",
            "AssumeRolePolicyDocument": {
                "Version": "2012-10-17",
                "Statement": [
                    {
                        "Effect": "Allow",
                        "Principal": {
                            "Service": "appsync.amazonaws.com"
                        },
                        "Action": "sts:AssumeRole"
                    }
                ]
            },
            "MaxSessionDuration": 3600
        }
    ]
}
Bash
{
  "command": "aws iam get-role --role-name harbor-appsync-svc-role --region us-east-1 --output json 2>&1\necho \"---\"\naws iam list-role-policies --role-name harbor-appsync-svc-role --region us-east-1 --output json 2>&1\necho \"---\"\naws iam list-attached-role-policies --role-name harbor-appsync-svc-role --region us-east-1 --output json 2>&1",
  "description": "Inspect svc role"
}
output
{
    "Role": {
        "Path": "/",
        "RoleName": "harbor-appsync-svc-role",
        "RoleId": "AROAQAAAAAAAOHQGBJVDV",
        "Arn": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
        "CreateDate": "2026-05-16T02:54:52.246731+00:00",
        "AssumeRolePolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Principal": {
                        "Service": "appsync.amazonaws.com"
                    },
                    "Action": "sts:AssumeRole"
                }
            ]
        },
        "MaxSessionDuration": 3600,
        "RoleLastUsed": {}
    }
}
---
{
    "PolicyNames": [
        "appsync-ddb-scoped"
    ]
}
---
{
    "AttachedPolicies": []
}

[stdout]
{
    "Role": {
        "Path": "/",
        "RoleName": "harbor-appsync-svc-role",
        "RoleId": "AROAQAAAAAAAOHQGBJVDV",
        "Arn": "arn:aws:iam::000000000000:role/harbor-appsync-svc-role",
        "CreateDate": "2026-05-16T02:54:52.246731+00:00",
        "AssumeRolePolicyDocument": {
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Effect": "Allow",
                    "Principal": {
                        "Service": "appsync.amazonaws.com"
                    },
                    "Action": "sts:AssumeRole"
                }
            ]
        },
        "MaxSessionDuration": 3600,
        "RoleLastUsed": {}
    }
}
---
{
    "PolicyNames": [
        "appsync-ddb-scoped"
    ]
}
---
{
    "AttachedPolicies": []
}
Bash
{
  "command": "aws cognito-idp list-groups --user-pool-id us-east-1_7eff64ccb64340b1bb6e24bdd82df12d --region us-east-1 --output json 2>&1\necho \"---\"\naws cognito-idp list-user-pool-clients --user-pool-id us-east-1_7eff64ccb64340b1bb6e24bdd82df12d --region us-east-1 --output json 2>&1",
  "description": "Inspect Cognito pool"
}
output
{
    "Groups": [
        {
            "GroupName": "tenants",
            "UserPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "LastModifiedDate": "2026-05-16T02:54:48+00:00",
            "CreationDate": "2026-05-16T02:54:48+00:00"
        }
    ]
}
---
{
    "UserPoolClients": [
        {
            "ClientId": "uht2zmpgairdfnk7tl6lwcg0h0",
            "UserPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "ClientName": "harbor-graphql-client"
        }
    ]
}

[stdout]
{
    "Groups": [
        {
            "GroupName": "tenants",
            "UserPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "LastModifiedDate": "2026-05-16T02:54:48+00:00",
            "CreationDate": "2026-05-16T02:54:48+00:00"
        }
    ]
}
---
{
    "UserPoolClients": [
        {
            "ClientId": "uht2zmpgairdfnk7tl6lwcg0h0",
            "UserPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "ClientName": "harbor-graphql-client"
        }
    ]
}
Bash
{
  "command": "aws kms describe-key --key-id 58fbeea7-b3b4-4efe-a237-4d8500af060d --region us-east-1 --output json 2>&1\necho \"---\"\naws kms get-key-policy --key-id 58fbeea7-b3b4-4efe-a237-4d8500af060d --policy-name default --region us-east-1 --output json 2>&1",
  "description": "Inspect KMS key"
}
output
{
    "KeyMetadata": {
        "AWSAccountId": "000000000000",
        "KeyId": "58fbeea7-b3b4-4efe-a237-4d8500af060d",
        "Arn": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d",
        "CreationDate": "2026-05-16T02:54:46.417127+00:00",
        "Enabled": true,
        "Description": "",
        "KeyUsage": "ENCRYPT_DECRYPT",
        "KeyState": "Enabled",
        "Origin": "AWS_KMS",
        "KeyManager": "CUSTOMER",
        "CustomerMasterKeySpec": "SYMMETRIC_DEFAULT",
        "KeySpec": "SYMMETRIC_DEFAULT",
        "EncryptionAlgorithms": [
            "SYMMETRIC_DEFAULT"
        ],
        "MultiRegion": false,
        "CurrentKeyMaterialId": "22fab655cd4050fb8c0114b6a21643dc22fab655cd4050fb8c0114b6a21643dc"
    }
}
---
{
    "Policy": "{\"Version\": \"2012-10-17\", \"Id\": \"key-default-1\", \"Statement\": [{\"Sid\": \"Enable IAM User Permissions\", \"Effect\": \"Allow\", \"Principal\": {\"AWS\": \"arn:aws:iam::000000000000:root\"}, \"Action\": \"kms:*\", \"Resource\": \"*\"}]}"
}

[stdout]
{
    "KeyMetadata": {
        "AWSAccountId": "000000000000",
        "KeyId": "58fbeea7-b3b4-4efe-a237-4d8500af060d",
        "Arn": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d",
        "CreationDate": "2026-05-16T02:54:46.417127+00:00",
        "Enabled": true,
        "Description": "",
        "KeyUsage": "ENCRYPT_DECRYPT",
        "KeyState": "Enabled",
        "Origin": "AWS_KMS",
        "KeyManager": "CUSTOMER",
        "CustomerMasterKeySpec": "SYMMETRIC_DEFAULT",
        "KeySpec": "SYMMETRIC_DEFAULT",
        "EncryptionAlgorithms": [
            "SYMMETRIC_DEFAULT"
        ],
        "MultiRegion": false,
        "CurrentKeyMaterialId": "22fab655cd4050fb8c0114b6a21643dc22fab655cd4050fb8c0114b6a21643dc"
    }
}
---
{
    "Policy": "{\"Version\": \"2012-10-17\", \"Id\": \"key-default-1\", \"Statement\": [{\"Sid\": \"Enable IAM User Permissions\", \"Effect\": \"Allow\", \"Principal\": {\"AWS\": \"arn:aws:iam::000000000000:root\"}, \"Action\": \"kms:*\", \"Resource\": \"*\"}]}"
}
Bash
{
  "command": "aws iam get-role-policy --role-name harbor-appsync-svc-role --policy-name appsync-ddb-scoped --region us-east-1 --output json 2>&1",
  "description": "Inspect svc role policy"
}
output
{
    "RoleName": "harbor-appsync-svc-role",
    "PolicyName": "appsync-ddb-scoped",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "DDBScopedActions",
                "Effect": "Allow",
                "Action": [
                    "dynamodb:GetItem",
                    "dynamodb:PutItem",
                    "dynamodb:Query"
                ],
                "Resource": "arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things"
            }
        ]
    }
}

[stdout]
{
    "RoleName": "harbor-appsync-svc-role",
    "PolicyName": "appsync-ddb-scoped",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "DDBScopedActions",
                "Effect": "Allow",
                "Action": [
                    "dynamodb:GetItem",
                    "dynamodb:PutItem",
                    "dynamodb:Query"
                ],
                "Resource": "arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things"
            }
        ]
    }
}
Bash
{
  "command": "aws iam list-role-policies --role-name harbor-appsync-logs-role --region us-east-1 --output json 2>&1\necho \"---\"\naws iam get-role-policy --role-name harbor-appsync-logs-role --policy-name $(aws iam list-role-policies --role-name harbor-appsync-logs-role --region us-east-1 --query 'PolicyNames[0]' --output text) --region us-east-1 --output json 2>&1",
  "description": "Inspect logs role policy"
}
output
{
    "PolicyNames": [
        "appsync-logs-scoped"
    ]
}
---
{
    "RoleName": "harbor-appsync-logs-role",
    "PolicyName": "appsync-logs-scoped",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "logs:CreateLogGroup",
                    "logs:CreateLogStream",
                    "logs:PutLogEvents"
                ],
                "Resource": "arn:aws:logs:us-east-1:000000000000:log-group:/aws/appsync/apis/harbor-graphql-api:*"
            }
        ]
    }
}

[stdout]
{
    "PolicyNames": [
        "appsync-logs-scoped"
    ]
}
---
{
    "RoleName": "harbor-appsync-logs-role",
    "PolicyName": "appsync-logs-scoped",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Effect": "Allow",
                "Action": [
                    "logs:CreateLogGroup",
                    "logs:CreateLogStream",
                    "logs:PutLogEvents"
                ],
                "Resource": "arn:aws:logs:us-east-1:000000000000:log-group:/aws/appsync/apis/harbor-graphql-api:*"
            }
        ]
    }
}
I have the full picture now. Let me load the task tracking tools and start fixing.
ToolSearch
{
  "query": "select:TaskCreate,TaskUpdate,TaskList",
  "max_results": 5
}
output
{"type": "tool_reference", "tool_name": "TaskCreate"}

{"type": "tool_reference", "tool_name": "TaskUpdate"}

{"type": "tool_reference", "tool_name": "TaskList"}
TaskCreate
{
  "subject": "Recreate Query.getThing resolver with correct pipeline order & cache keys",
  "description": "pipeline: [auth, data]; cachingKeys include arguments.id AND caller tenant claim"
}
output
Task #1 created successfully: Recreate Query.getThing resolver with correct pipeline order & cache keys
TaskCreate
{
  "subject": "Recreate get_thing_data function (consistentRead off, tenant-scoped response)",
  "description": "consistentRead=false; response template must verify tenantId matches caller's claim"
}
output
Task #2 created successfully: Recreate get_thing_data function (consistentRead off, tenant-scoped response)
TaskCreate
{
  "subject": "Replace API cache to PER_RESOLVER_CACHING",
  "description": "delete then create-api-cache with apiCachingBehavior=PER_RESOLVER_CACHING (currently FULL_REQUEST_CACHING)"
}
output
Task #3 created successfully: Replace API cache to PER_RESOLVER_CACHING
TaskCreate
{
  "subject": "Replace schema (remove @aws_api_key from Mutation, remove tenantId/ownerId args)",
  "description": "monitoring API key must not mutate; tenant/owner must not be client-settable"
}
output
Task #4 created successfully: Replace schema (remove @aws_api_key from Mutation, remove tenantId/ownerId args)
TaskCreate
{
  "subject": "Recreate auth_check function with fixed claim syntax",
  "description": "cognito:groups must be accessed via .get(\\\"cognito:groups\\\"), not dot-notation"
}
output
Task #5 created successfully: Recreate auth_check function with fixed claim syntax
TaskCreate
{
  "subject": "Fix GraphQL API config (defaultAction, xray, logs, additional auth providers)",
  "description": "update-graphql-api: defaultAction ALLOW→DENY, xrayEnabled true, fieldLogLevel ALL, drop AWS_IAM from additionalAuthenticationProviders (keep API_KEY only)"
}
output
Task #6 created successfully: Fix GraphQL API config (defaultAction, xray, logs, additional auth providers)
TaskCreate
{
  "subject": "Recreate Mutation.addThing resolver (condition expression, derive tenant from claim, version)",
  "description": "attribute_not_exists(id) condition; tenantId/ownerId derived from identity; version 2018-05-29"
}
output
Task #7 created successfully: Recreate Mutation.addThing resolver (condition expression, derive tenant from claim, version)
TaskCreate
{
  "subject": "Add KMS permissions to svc role for the table key",
  "description": "role needs kms:Decrypt/Encrypt/GenerateDataKey/DescribeKey on the KMS key arn"
}
output
Task #8 created successfully: Add KMS permissions to svc role for the table key
TaskCreate
{
  "subject": "Verify final state end-to-end",
  "description": "re-inspect everything to ensure no regressions and SSM still resolves"
}
output
Task #9 created successfully: Verify final state end-to-end
TaskCreate
{
  "subject": "Rotate API key to expire within weekly window",
  "description": "delete existing key 971f7adc and create a new one with expiry ~7 days; update SSM /harbor/graphql/api-key"
}
output
Task #10 created successfully: Rotate API key to expire within weekly window
Starting with the GraphQL API config and IAM updates first.
TaskUpdate
{
  "taskId": "6",
  "status": "in_progress"
}
output
Updated task #6 status
TaskUpdate
{
  "taskId": "8",
  "status": "in_progress"
}
output
Updated task #8 status
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync update-graphql-api \\\n  --api-id $API_ID \\\n  --name harbor-graphql-api \\\n  --authentication-type AMAZON_COGNITO_USER_POOLS \\\n  --user-pool-config userPoolId=us-east-1_7eff64ccb64340b1bb6e24bdd82df12d,awsRegion=us-east-1,defaultAction=DENY \\\n  --log-config cloudWatchLogsRoleArn=arn:aws:iam::000000000000:role/harbor-appsync-logs-role,fieldLogLevel=ALL,excludeVerboseContent=false \\\n  --additional-authentication-providers '[{\"authenticationType\":\"API_KEY\"}]' \\\n  --xray-enabled \\\n  --region us-east-1 --output json 2>&1",
  "description": "Update GraphQL API config"
}
output
{
    "graphqlApi": {
        "name": "harbor-graphql-api",
        "apiId": "3061ea0733034e6d92abb18c27",
        "authenticationType": "AMAZON_COGNITO_USER_POOLS",
        "logConfig": {
            "fieldLogLevel": "ALL",
            "cloudWatchLogsRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "excludeVerboseContent": false
        },
        "userPoolConfig": {
            "userPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "awsRegion": "us-east-1",
            "defaultAction": "DENY"
        },
        "arn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27",
        "uris": {
            "GRAPHQL": "http://localhost.localstack.cloud:4566/graphql/3061ea0733034e6d92abb18c27",
            "REALTIME": "ws://localhost.localstack.cloud:4510/graphql/3061ea0733034e6d92abb18c27"
        },
        "tags": {},
        "additionalAuthenticationProviders": [
            {
                "authenticationType": "API_KEY"
            }
        ],
        "xrayEnabled": true
    }
}

[stdout]
{
    "graphqlApi": {
        "name": "harbor-graphql-api",
        "apiId": "3061ea0733034e6d92abb18c27",
        "authenticationType": "AMAZON_COGNITO_USER_POOLS",
        "logConfig": {
            "fieldLogLevel": "ALL",
            "cloudWatchLogsRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "excludeVerboseContent": false
        },
        "userPoolConfig": {
            "userPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "awsRegion": "us-east-1",
            "defaultAction": "DENY"
        },
        "arn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27",
        "uris": {
            "GRAPHQL": "http://localhost.localstack.cloud:4566/graphql/3061ea0733034e6d92abb18c27",
            "REALTIME": "ws://localhost.localstack.cloud:4510/graphql/3061ea0733034e6d92abb18c27"
        },
        "tags": {},
        "additionalAuthenticationProviders": [
            {
                "authenticationType": "API_KEY"
            }
        ],
        "xrayEnabled": true
    }
}
Bash
{
  "command": "cat > /tmp/svc-policy.json <<'EOF'\n{\n  \"Version\": \"2012-10-17\",\n  \"Statement\": [\n    {\n      \"Sid\": \"DDBScopedActions\",\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"dynamodb:GetItem\",\n        \"dynamodb:PutItem\",\n        \"dynamodb:Query\"\n      ],\n      \"Resource\": \"arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things\"\n    },\n    {\n      \"Sid\": \"KMSForTableEncryption\",\n      \"Effect\": \"Allow\",\n      \"Action\": [\n        \"kms:Decrypt\",\n        \"kms:Encrypt\",\n        \"kms:GenerateDataKey\",\n        \"kms:DescribeKey\"\n      ],\n      \"Resource\": \"arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d\"\n    }\n  ]\n}\nEOF\naws iam put-role-policy \\\n  --role-name harbor-appsync-svc-role \\\n  --policy-name appsync-ddb-scoped \\\n  --policy-document file:///tmp/svc-policy.json \\\n  --region us-east-1 --output json 2>&1\necho \"---\"\naws iam get-role-policy --role-name harbor-appsync-svc-role --policy-name appsync-ddb-scoped --region us-east-1 --output json 2>&1",
  "description": "Add KMS to svc role"
}
output
---
{
    "RoleName": "harbor-appsync-svc-role",
    "PolicyName": "appsync-ddb-scoped",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "DDBScopedActions",
                "Effect": "Allow",
                "Action": [
                    "dynamodb:GetItem",
                    "dynamodb:PutItem",
                    "dynamodb:Query"
                ],
                "Resource": "arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things"
            },
            {
                "Sid": "KMSForTableEncryption",
                "Effect": "Allow",
                "Action": [
                    "kms:Decrypt",
                    "kms:Encrypt",
                    "kms:GenerateDataKey",
                    "kms:DescribeKey"
                ],
                "Resource": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d"
            }
        ]
    }
}

[stdout]
---
{
    "RoleName": "harbor-appsync-svc-role",
    "PolicyName": "appsync-ddb-scoped",
    "PolicyDocument": {
        "Version": "2012-10-17",
        "Statement": [
            {
                "Sid": "DDBScopedActions",
                "Effect": "Allow",
                "Action": [
                    "dynamodb:GetItem",
                    "dynamodb:PutItem",
                    "dynamodb:Query"
                ],
                "Resource": "arn:aws:dynamodb:us-east-1:000000000000:table/harbor-things"
            },
            {
                "Sid": "KMSForTableEncryption",
                "Effect": "Allow",
                "Action": [
                    "kms:Decrypt",
                    "kms:Encrypt",
                    "kms:GenerateDataKey",
                    "kms:DescribeKey"
                ],
                "Resource": "arn:aws:kms:us-east-1:000000000000:key/58fbeea7-b3b4-4efe-a237-4d8500af060d"
            }
        ]
    }
}
TaskUpdate
{
  "taskId": "8",
  "status": "completed"
}
output
Updated task #8 status
TaskUpdate
{
  "taskId": "4",
  "status": "in_progress"
}
output
Updated task #4 status
TaskUpdate
{
  "taskId": "3",
  "status": "in_progress"
}
output
Updated task #3 status
TaskUpdate
{
  "taskId": "6",
  "status": "completed"
}
output
Updated task #6 status
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync delete-api-cache --api-id $API_ID --region us-east-1 --output json 2>&1\necho \"--- create ---\"\naws appsync create-api-cache \\\n  --api-id $API_ID \\\n  --ttl 600 \\\n  --api-caching-behavior PER_RESOLVER_CACHING \\\n  --type SMALL \\\n  --region us-east-1 --output json 2>&1\necho \"--- verify ---\"\naws appsync get-api-cache --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "Recreate API cache as PER_RESOLVER_CACHING"
}
output
--- create ---
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "PER_RESOLVER_CACHING",
        "type": "SMALL"
    }
}
--- verify ---
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "PER_RESOLVER_CACHING",
        "type": "SMALL"
    }
}

[stdout]
--- create ---
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "PER_RESOLVER_CACHING",
        "type": "SMALL"
    }
}
--- verify ---
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "PER_RESOLVER_CACHING",
        "type": "SMALL"
    }
}
Bash
{
  "command": "cat > /tmp/schema.graphql <<'EOF'\ntype Thing @aws_cognito_user_pools(cognito_groups: [\"tenants\"]) @aws_api_key {\n  id: ID!\n  name: String!\n  ownerId: String!\n  tenantId: String!\n}\n\ntype Query @aws_cognito_user_pools(cognito_groups: [\"tenants\"]) @aws_api_key {\n  getThing(id: ID!): Thing @aws_cognito_user_pools(cognito_groups: [\"tenants\"]) @aws_api_key\n}\n\ntype Mutation @aws_cognito_user_pools(cognito_groups: [\"tenants\"]) {\n  addThing(id: ID!, name: String!): Thing @aws_cognito_user_pools(cognito_groups: [\"tenants\"])\n}\n\nschema {\n  query: Query\n  mutation: Mutation\n}\nEOF\nAPI_ID=3061ea0733034e6d92abb18c27\naws appsync start-schema-creation \\\n  --api-id $API_ID \\\n  --definition fileb:///tmp/schema.graphql \\\n  --region us-east-1 --output json 2>&1\nsleep 1\naws appsync get-schema-creation-status --api-id $API_ID --region us-east-1 --output json 2>&1\necho \"--- final SDL ---\"\naws appsync get-introspection-schema --api-id $API_ID --format SDL --region us-east-1 /tmp/schema-out.graphql 2>&1; cat /tmp/schema-out.graphql 2>/dev/null",
  "description": "Replace schema"
}
output
{
    "status": "PROCESSING"
}
{
    "status": "SUCCESS",
    "details": "Successfully created schema with 4 types."
}
--- final SDL ---
type Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  id: ID!
  name: String!
  ownerId: String!
  tenantId: String!
}

type Query @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  getThing(id: ID!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

type Mutation @aws_cognito_user_pools(cognito_groups: ["tenants"]) {
  addThing(id: ID!, name: String!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"])
}

schema {
  query: Query
  mutation: Mutation
}

[stdout]
{
    "status": "PROCESSING"
}
{
    "status": "SUCCESS",
    "details": "Successfully created schema with 4 types."
}
--- final SDL ---
type Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  id: ID!
  name: String!
  ownerId: String!
  tenantId: String!
}

type Query @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  getThing(id: ID!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

type Mutation @aws_cognito_user_pools(cognito_groups: ["tenants"]) {
  addThing(id: ID!, name: String!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"])
}

schema {
  query: Query
  mutation: Mutation
}
TaskUpdate
{
  "taskId": "3",
  "status": "completed"
}
output
Updated task #3 status
TaskUpdate
{
  "taskId": "2",
  "status": "in_progress"
}
output
Updated task #2 status
TaskUpdate
{
  "taskId": "4",
  "status": "completed"
}
output
Updated task #4 status
TaskUpdate
{
  "taskId": "5",
  "status": "in_progress"
}
output
Updated task #5 status
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\ncat > /tmp/auth_req.vtl <<'EOF'\n#set( $groups = $ctx.identity.claims.get(\"cognito:groups\") )\n#if( $util.isNull($groups) )\n  $util.unauthorized()\n#end\n#if( !$groups.contains(\"tenants\") )\n  $util.unauthorized()\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"payload\": {}\n}\nEOF\ncat > /tmp/auth_resp.vtl <<'EOF'\n$util.toJson($ctx.prev.result)\nEOF\naws appsync update-function \\\n  --api-id $API_ID \\\n  --function-id 71a59343 \\\n  --name auth_check \\\n  --data-source-name things_table \\\n  --function-version 2018-05-29 \\\n  --request-mapping-template \"$(cat /tmp/auth_req.vtl)\" \\\n  --response-mapping-template \"$(cat /tmp/auth_resp.vtl)\" \\\n  --region us-east-1 --output json 2>&1",
  "description": "Update auth_check function"
}
output
{
    "functionConfiguration": {
        "functionId": "71a59343",
        "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/71a59343",
        "name": "auth_check",
        "dataSourceName": "things_table",
        "requestMappingTemplate": "#set( $groups = $ctx.identity.claims.get(\"cognito:groups\") )\n#if( $util.isNull($groups) )\n  $util.unauthorized()\n#end\n#if( !$groups.contains(\"tenants\") )\n  $util.unauthorized()\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"payload\": {}\n}",
        "responseMappingTemplate": "$util.toJson($ctx.prev.result)",
        "functionVersion": "2018-05-29",
        "maxBatchSize": 0
    }
}

[stdout]
{
    "functionConfiguration": {
        "functionId": "71a59343",
        "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/71a59343",
        "name": "auth_check",
        "dataSourceName": "things_table",
        "requestMappingTemplate": "#set( $groups = $ctx.identity.claims.get(\"cognito:groups\") )\n#if( $util.isNull($groups) )\n  $util.unauthorized()\n#end\n#if( !$groups.contains(\"tenants\") )\n  $util.unauthorized()\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"payload\": {}\n}",
        "responseMappingTemplate": "$util.toJson($ctx.prev.result)",
        "functionVersion": "2018-05-29",
        "maxBatchSize": 0
    }
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\ncat > /tmp/data_req.vtl <<'EOF'\n{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"GetItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"consistentRead\": false\n}\nEOF\ncat > /tmp/data_resp.vtl <<'EOF'\n#if( $util.isNull($ctx.result) )\n  $util.toJson($ctx.result)\n#else\n  #set( $callerTenant = $ctx.identity.claims.get(\"tenant_id\") )\n  #if( $ctx.result.tenantId != $callerTenant )\n    $util.unauthorized()\n  #end\n  $util.toJson($ctx.result)\n#end\nEOF\naws appsync update-function \\\n  --api-id $API_ID \\\n  --function-id 623d6c3a \\\n  --name get_thing_data \\\n  --data-source-name things_table \\\n  --function-version 2018-05-29 \\\n  --request-mapping-template \"$(cat /tmp/data_req.vtl)\" \\\n  --response-mapping-template \"$(cat /tmp/data_resp.vtl)\" \\\n  --region us-east-1 --output json 2>&1",
  "description": "Update get_thing_data function"
}
output
{
    "functionConfiguration": {
        "functionId": "623d6c3a",
        "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/623d6c3a",
        "name": "get_thing_data",
        "dataSourceName": "things_table",
        "requestMappingTemplate": "{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"GetItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"consistentRead\": false\n}",
        "responseMappingTemplate": "#if( $util.isNull($ctx.result) )\n  $util.toJson($ctx.result)\n#else\n  #set( $callerTenant = $ctx.identity.claims.get(\"tenant_id\") )\n  #if( $ctx.result.tenantId != $callerTenant )\n    $util.unauthorized()\n  #end\n  $util.toJson($ctx.result)\n#end",
        "functionVersion": "2018-05-29",
        "maxBatchSize": 0
    }
}

[stdout]
{
    "functionConfiguration": {
        "functionId": "623d6c3a",
        "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/623d6c3a",
        "name": "get_thing_data",
        "dataSourceName": "things_table",
        "requestMappingTemplate": "{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"GetItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"consistentRead\": false\n}",
        "responseMappingTemplate": "#if( $util.isNull($ctx.result) )\n  $util.toJson($ctx.result)\n#else\n  #set( $callerTenant = $ctx.identity.claims.get(\"tenant_id\") )\n  #if( $ctx.result.tenantId != $callerTenant )\n    $util.unauthorized()\n  #end\n  $util.toJson($ctx.result)\n#end",
        "functionVersion": "2018-05-29",
        "maxBatchSize": 0
    }
}
TaskUpdate
{
  "taskId": "1",
  "status": "in_progress"
}
output
Updated task #1 status
TaskUpdate
{
  "taskId": "2",
  "status": "completed"
}
output
Updated task #2 status
TaskUpdate
{
  "taskId": "7",
  "status": "in_progress"
}
output
Updated task #7 status
TaskUpdate
{
  "taskId": "5",
  "status": "completed"
}
output
Updated task #5 status
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\naws appsync update-resolver \\\n  --api-id $API_ID \\\n  --type-name Query \\\n  --field-name getThing \\\n  --kind PIPELINE \\\n  --pipeline-config functions=71a59343,623d6c3a \\\n  --request-mapping-template '{}' \\\n  --response-mapping-template '$util.toJson($ctx.result)' \\\n  --caching-config 'ttl=600,cachingKeys=$context.arguments.id,$context.identity.claims.tenant_id' \\\n  --region us-east-1 --output json 2>&1",
  "description": "Update Query.getThing resolver"
}
output
{
    "resolver": {
        "typeName": "Query",
        "fieldName": "getThing",
        "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Query/resolvers/getThing",
        "requestMappingTemplate": "{}",
        "responseMappingTemplate": "$util.toJson($ctx.result)",
        "kind": "PIPELINE",
        "pipelineConfig": {
            "functions": [
                "71a59343",
                "623d6c3a"
            ]
        },
        "cachingConfig": {
            "ttl": 600,
            "cachingKeys": [
                "$context.arguments.id",
                "$context.identity.claims.tenant_id"
            ]
        },
        "maxBatchSize": 0
    }
}

[stdout]
{
    "resolver": {
        "typeName": "Query",
        "fieldName": "getThing",
        "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Query/resolvers/getThing",
        "requestMappingTemplate": "{}",
        "responseMappingTemplate": "$util.toJson($ctx.result)",
        "kind": "PIPELINE",
        "pipelineConfig": {
            "functions": [
                "71a59343",
                "623d6c3a"
            ]
        },
        "cachingConfig": {
            "ttl": 600,
            "cachingKeys": [
                "$context.arguments.id",
                "$context.identity.claims.tenant_id"
            ]
        },
        "maxBatchSize": 0
    }
}
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\ncat > /tmp/add_req.vtl <<'EOF'\n#set( $tenant = $ctx.identity.claims.get(\"tenant_id\") )\n#set( $owner = $ctx.identity.username )\n#if( $util.isNull($tenant) )\n  $util.error(\"tenant_id claim missing\", \"Unauthorized\")\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"PutItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"attributeValues\": {\n    \"name\": $util.dynamodb.toDynamoDBJson($ctx.arguments.name),\n    \"tenantId\": $util.dynamodb.toDynamoDBJson($tenant),\n    \"ownerId\": $util.dynamodb.toDynamoDBJson($owner)\n  },\n  \"condition\": {\n    \"expression\": \"attribute_not_exists(#id)\",\n    \"expressionNames\": {\n      \"#id\": \"id\"\n    }\n  }\n}\nEOF\naws appsync update-resolver \\\n  --api-id $API_ID \\\n  --type-name Mutation \\\n  --field-name addThing \\\n  --kind UNIT \\\n  --data-source-name things_table \\\n  --request-mapping-template \"$(cat /tmp/add_req.vtl)\" \\\n  --response-mapping-template '$util.toJson($ctx.result)' \\\n  --region us-east-1 --output json 2>&1",
  "description": "Update Mutation.addThing resolver"
}
output
{
    "resolver": {
        "typeName": "Mutation",
        "fieldName": "addThing",
        "dataSourceName": "things_table",
        "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Mutation/resolvers/addThing",
        "requestMappingTemplate": "#set( $tenant = $ctx.identity.claims.get(\"tenant_id\") )\n#set( $owner = $ctx.identity.username )\n#if( $util.isNull($tenant) )\n  $util.error(\"tenant_id claim missing\", \"Unauthorized\")\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"PutItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"attributeValues\": {\n    \"name\": $util.dynamodb.toDynamoDBJson($ctx.arguments.name),\n    \"tenantId\": $util.dynamodb.toDynamoDBJson($tenant),\n    \"ownerId\": $util.dynamodb.toDynamoDBJson($owner)\n  },\n  \"condition\": {\n    \"expression\": \"attribute_not_exists(#id)\",\n    \"expressionNames\": {\n      \"#id\": \"id\"\n    }\n  }\n}",
        "responseMappingTemplate": "$util.toJson($ctx.result)",
        "kind": "UNIT",
        "maxBatchSize": 0
    }
}

[stdout]
{
    "resolver": {
        "typeName": "Mutation",
        "fieldName": "addThing",
        "dataSourceName": "things_table",
        "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Mutation/resolvers/addThing",
        "requestMappingTemplate": "#set( $tenant = $ctx.identity.claims.get(\"tenant_id\") )\n#set( $owner = $ctx.identity.username )\n#if( $util.isNull($tenant) )\n  $util.error(\"tenant_id claim missing\", \"Unauthorized\")\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"PutItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"attributeValues\": {\n    \"name\": $util.dynamodb.toDynamoDBJson($ctx.arguments.name),\n    \"tenantId\": $util.dynamodb.toDynamoDBJson($tenant),\n    \"ownerId\": $util.dynamodb.toDynamoDBJson($owner)\n  },\n  \"condition\": {\n    \"expression\": \"attribute_not_exists(#id)\",\n    \"expressionNames\": {\n      \"#id\": \"id\"\n    }\n  }\n}",
        "responseMappingTemplate": "$util.toJson($ctx.result)",
        "kind": "UNIT",
        "maxBatchSize": 0
    }
}
TaskUpdate
{
  "taskId": "1",
  "status": "completed"
}
output
Updated task #1 status
TaskUpdate
{
  "taskId": "7",
  "status": "completed"
}
output
Updated task #7 status
TaskUpdate
{
  "taskId": "10",
  "status": "in_progress"
}
output
Updated task #10 status
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\n# Current time-ish: 2026-05-16. Set expiry ~7 days out.\nNEW_EXP=$(($(date +%s) + 6*86400))\necho \"New expiry: $NEW_EXP ($(date -d @$NEW_EXP 2>/dev/null || date -r $NEW_EXP))\"\naws appsync delete-api-key --api-id $API_ID --id 971f7adc --region us-east-1 --output json 2>&1\necho \"--- create ---\"\nNEW_KEY_JSON=$(aws appsync create-api-key --api-id $API_ID --description \"harbor monitoring read-only\" --expires $NEW_EXP --region us-east-1 --output json 2>&1)\necho \"$NEW_KEY_JSON\"\nNEW_KEY_ID=$(echo \"$NEW_KEY_JSON\" | python3 -c \"import json,sys; print(json.load(sys.stdin)['apiKey']['id'])\")\necho \"--- SSM update ---\"\naws ssm put-parameter --name /harbor/graphql/api-key --value \"$NEW_KEY_ID\" --type String --overwrite --region us-east-1 --output json 2>&1\necho \"--- verify SSM ---\"\naws ssm get-parameter --name /harbor/graphql/api-key --region us-east-1 --output json 2>&1\necho \"--- verify keys ---\"\naws appsync list-api-keys --api-id $API_ID --region us-east-1 --output json 2>&1",
  "description": "Rotate API key"
}
output
New expiry: 1779418779 (Fri May 22 02:59:39 UTC 2026)
--- create ---
{
    "apiKey": {
        "id": "41adc87b",
        "description": "harbor monitoring read-only",
        "expires": 1779415200,
        "deletes": 1784599200
    }
}
--- SSM update ---
{
    "Version": 2,
    "Tier": "Standard"
}
--- verify SSM ---
{
    "Parameter": {
        "Name": "/harbor/graphql/api-key",
        "Type": "String",
        "Value": "41adc87b",
        "Version": 2,
        "LastModifiedDate": "2026-05-16T02:59:40.423000+00:00",
        "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/api-key",
        "DataType": "text"
    }
}
--- verify keys ---
{
    "apiKeys": [
        {
            "id": "41adc87b",
            "description": "harbor monitoring read-only",
            "expires": 1779415200,
            "deletes": 1784599200
        }
    ]
}

[stdout]
New expiry: 1779418779 (Fri May 22 02:59:39 UTC 2026)
--- create ---
{
    "apiKey": {
        "id": "41adc87b",
        "description": "harbor monitoring read-only",
        "expires": 1779415200,
        "deletes": 1784599200
    }
}
--- SSM update ---
{
    "Version": 2,
    "Tier": "Standard"
}
--- verify SSM ---
{
    "Parameter": {
        "Name": "/harbor/graphql/api-key",
        "Type": "String",
        "Value": "41adc87b",
        "Version": 2,
        "LastModifiedDate": "2026-05-16T02:59:40.423000+00:00",
        "ARN": "arn:aws:ssm:us-east-1:000000000000:parameter/harbor/graphql/api-key",
        "DataType": "text"
    }
}
--- verify keys ---
{
    "apiKeys": [
        {
            "id": "41adc87b",
            "description": "harbor monitoring read-only",
            "expires": 1779415200,
            "deletes": 1784599200
        }
    ]
}
TaskUpdate
{
  "taskId": "9",
  "status": "in_progress"
}
output
Updated task #9 status
TaskUpdate
{
  "taskId": "10",
  "status": "completed"
}
output
Updated task #10 status
Bash
{
  "command": "API_ID=3061ea0733034e6d92abb18c27\necho \"=== API ===\"\naws appsync get-graphql-api --api-id $API_ID --region us-east-1 --output json 2>&1\necho \"=== Cache ===\"\naws appsync get-api-cache --api-id $API_ID --region us-east-1 --output json 2>&1\necho \"=== Schema ===\"\naws appsync get-introspection-schema --api-id $API_ID --format SDL --region us-east-1 /tmp/final-schema.graphql 2>&1; cat /tmp/final-schema.graphql 2>/dev/null\necho \"=== Functions ===\"\naws appsync list-functions --api-id $API_ID --region us-east-1 --output json 2>&1\necho \"=== Query resolver ===\"\naws appsync get-resolver --api-id $API_ID --type-name Query --field-name getThing --region us-east-1 --output json 2>&1\necho \"=== Mutation resolver ===\"\naws appsync get-resolver --api-id $API_ID --type-name Mutation --field-name addThing --region us-east-1 --output json 2>&1\necho \"=== API keys ===\"\naws appsync list-api-keys --api-id $API_ID --region us-east-1 --output json 2>&1\necho \"=== svc role policy ===\"\naws iam get-role-policy --role-name harbor-appsync-svc-role --policy-name appsync-ddb-scoped --region us-east-1 --output json 2>&1\necho \"=== SSM resolves ===\"\naws ssm get-parameters-by-path --path /harbor/graphql --recursive --region us-east-1 --query 'Parameters[].[Name,Value]' --output text 2>&1",
  "description": "Final end-to-end verification"
}
output
=== API ===
{
    "graphqlApi": {
        "name": "harbor-graphql-api",
        "apiId": "3061ea0733034e6d92abb18c27",
        "authenticationType": "AMAZON_COGNITO_USER_POOLS",
        "logConfig": {
            "fieldLogLevel": "ALL",
            "cloudWatchLogsRoleArn": "arn:aws:iam::000000000000:role/harbor-appsync-logs-role",
            "excludeVerboseContent": false
        },
        "userPoolConfig": {
            "userPoolId": "us-east-1_7eff64ccb64340b1bb6e24bdd82df12d",
            "awsRegion": "us-east-1",
            "defaultAction": "DENY"
        },
        "arn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27",
        "uris": {
            "GRAPHQL": "http://localhost.localstack.cloud:4566/graphql/3061ea0733034e6d92abb18c27",
            "REALTIME": "ws://localhost.localstack.cloud:4510/graphql/3061ea0733034e6d92abb18c27"
        },
        "tags": {},
        "additionalAuthenticationProviders": [
            {
                "authenticationType": "API_KEY"
            }
        ],
        "xrayEnabled": true
    }
}
=== Cache ===
{
    "apiCache": {
        "ttl": 600,
        "apiCachingBehavior": "PER_RESOLVER_CACHING",
        "type": "SMALL"
    }
}
=== Schema ===
type Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  id: ID!
  name: String!
  ownerId: String!
  tenantId: String!
}

type Query @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key {
  getThing(id: ID!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"]) @aws_api_key
}

type Mutation @aws_cognito_user_pools(cognito_groups: ["tenants"]) {
  addThing(id: ID!, name: String!): Thing @aws_cognito_user_pools(cognito_groups: ["tenants"])
}

schema {
  query: Query
  mutation: Mutation
}
=== Functions ===
{
    "functions": [
        {
            "functionId": "71a59343",
            "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/71a59343",
            "name": "auth_check",
            "dataSourceName": "things_table",
            "requestMappingTemplate": "#set( $groups = $ctx.identity.claims.get(\"cognito:groups\") )\n#if( $util.isNull($groups) )\n  $util.unauthorized()\n#end\n#if( !$groups.contains(\"tenants\") )\n  $util.unauthorized()\n#end\n{\n  \"version\": \"2018-05-29\",\n  \"payload\": {}\n}",
            "responseMappingTemplate": "$util.toJson($ctx.prev.result)",
            "functionVersion": "2018-05-29",
            "maxBatchSize": 0
        },
        {
            "functionId": "623d6c3a",
            "functionArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/functions/623d6c3a",
            "name": "get_thing_data",
            "dataSourceName": "things_table",
            "requestMappingTemplate": "{\n  \"version\": \"2018-05-29\",\n  \"operation\": \"GetItem\",\n  \"key\": {\n    \"id\": $util.dynamodb.toDynamoDBJson($ctx.arguments.id)\n  },\n  \"consistentRead\": false\n}",
            "responseMappingTemplate": "#if( $util.isNull($ctx.result) )\n  $util.toJson($ctx.result)\n#else\n  #set( $callerTenant = $ctx.identity.claims.get(\"tenant_id\") )\n  #if( $ctx.result.tenantId != $callerTenant )\n    $util.unauthorized()\n  #end\n  $util.toJson($ctx.result)\n#end",
            "functionVersion": "2018-05-29",
            "maxBatchSize": 0
        }
    ]
}
=== Query resolver ===
{
    "resolver": {
        "typeName": "Query",
        "fieldName": "getThing",
        "resolverArn": "arn:aws:appsync:us-east-1:000000000000:apis/3061ea0733034e6d92abb18c27/types/Query/resolvers/getThing",
        "requestMappingTemplate": "{}",
        "responseMappingTemplate": "$util.toJson($ctx.result)",
        "kind": "PIPELINE",
        "pipelineConfig": {
            "functions": [
                "71a59343",
                "623d6c3a"
            ]
        },
        "cachingConfig": {
            "ttl": 600,
            "cachingKeys": [
                "$context.arguments.id",
              
…[truncated]
TaskUpdate
{
  "taskId": "9",
  "status": "completed"
}
output
Updated task #9 status
All ten fixes applied. Summary of the diagnosis and what changed, mapped to each audit finding: **Blocking (all on `harbor-graphql-api`):** 1. **Cache not tenant-scoped** , `cachingKeys` was just `["$context.arguments.id"]` AND `apiCachingBehavior` was `FULL_REQUEST_CACHING` (which ignores per-resolver keys). Now: keys are `["$context.arguments.id", "$context.identity.claims.tenant_id"]` and behavior is `PER_RESOLVER_CACHING`. 2. **Strongly-consistent read bypassed cache** , `get_thing_data` had `consistentRead: true` (DDB consistent reads skip the AppSync cache). Now `false`. 3. **Client could claim a tenant** , `addThing` accepted `tenantId` (and `ownerId`) as args. Removed from schema; resolver derives both from `$ctx.identity.claims.get("tenant_id")` and `$ctx.identity.username`. 4. **Read-only API key could mutate** , `Mutation` and `addThing` carried `@aws_api_key`. Removed; Mutation now Cognito-only. 5. **Svc role lacked KMS access** , added `kms:Decrypt/Encrypt/GenerateDataKey/DescribeKey` on the table's CMK to `appsync-ddb-scoped`. 6. **Auth gate broken** , `$ctx.identity.claims.cognito:groups` is invalid VTL (colon isn't a legal identifier char), so `$groups` was an unpredictable parse remnant , never reliably null, sometimes non-`.contains()`-able. Now `.get("cognito:groups")`. 7. **Pipeline ran data before auth** , `pipelineConfig.functions` was `[get_thing_data, auth_check]`. Swapped to `[auth_check, get_thing_data]`. Also added a response-side tenant-match check in `get_thing_data` so the data fetch can never leak a cross-tenant row even on a cache miss. 8. (restated #1) **Tracking (also fixed):** - `userPoolConfig.defaultAction` `ALLOW` → `DENY` - `xrayEnabled` `false` → `true` - `logConfig.fieldLogLevel` `ERROR` → `ALL` (and `excludeVerboseContent: false`) - `addThing` request now includes `condition: attribute_not_exists(#id)` and is upgraded to `version: 2018-05-29` - API key rotated: old `971f7adc` (expired ~2027-05-12) deleted, new `41adc87b` expires ~6 days out; SSM `/harbor/graphql/api-key` updated to the new id - `additionalAuthenticationProviders` had an extra `AWS_IAM` provider , removed; only `API_KEY` remains Resource IDs/names (api id, function ids, data source, role names, table) were preserved, so every SSM key under `/harbor/graphql/*` still resolves to live state.
Final diff , what the agent changed

No file changes, the agent left the workspace untouched.

Verifier output , the proof behind the reward
tests/test.sh
downloading uv 0.9.7 aarch64-unknown-linux-gnu
Downloading pygments (1.2MiB)
Downloading botocore (12.7MiB)
 Downloading pygments
 Downloading botocore
Installed 13 packages in 48ms
============================= test session starts ==============================
platform linux -- Python 3.12.3, pytest-8.4.1, pluggy-1.6.0 -- /root/.cache/uv/archive-v0/VXtNhQTUhtvrwo8CDP_3x/bin/python
cachedir: .pytest_cache
rootdir: /tests
plugins: json-ctrf-0.3.5
collecting ... collected 57 items

../tests/test_outputs.py::test_01_appsync_api_exists PASSED              [  1%]
../tests/test_outputs.py::test_02_user_pool_exists PASSED                [  3%]
../tests/test_outputs.py::test_03_app_client_exists PASSED               [  5%]
../tests/test_outputs.py::test_04_user_pool_group_tenants_exists PASSED  [  7%]
../tests/test_outputs.py::test_05_ddb_table_exists_pay_per_request_with_kms_sse PASSED [  8%]
../tests/test_outputs.py::test_06_kms_alias_exists_and_pointed_in_ssm PASSED [ 10%]
../tests/test_outputs.py::test_07_log_group_exists PASSED                [ 12%]
../tests/test_outputs.py::test_08_two_iam_roles_exist PASSED             [ 14%]
../tests/test_outputs.py::test_09_appsync_data_source_exists PASSED      [ 15%]
../tests/test_outputs.py::test_10_two_appsync_functions_exist PASSED     [ 17%]
../tests/test_outputs.py::test_11_two_resolvers_exist PASSED             [ 19%]
../tests/test_outputs.py::test_12_ssm_pointers_resolve PASSED            [ 21%]
../tests/test_outputs.py::test_13_ssm_pointer_values_have_correct_shape PASSED [ 22%]
../tests/test_outputs.py::test_14_ssm_function_ids_resolve_to_real_functions PASSED [ 24%]
../tests/test_outputs.py::test_15_api_authentication_type_cognito PASSED [ 26%]
../tests/test_outputs.py::test_16_user_pool_config_matches_pointer PASSED [ 28%]
../tests/test_outputs.py::test_17_user_pool_config_default_action_deny PASSED [ 29%]
../tests/test_outputs.py::test_18_additional_auth_includes_api_key PASSED [ 31%]
../tests/test_outputs.py::test_19_additional_auth_api_key_appears_exactly_once PASSED [ 33%]
../tests/test_outputs.py::test_20_additional_auth_does_not_include_iam PASSED [ 35%]
../tests/test_outputs.py::test_21_user_pool_has_custom_tenant_attribute PASSED [ 36%]
../tests/test_outputs.py::test_22_app_client_has_no_admin_user_password_flow PASSED [ 38%]
../tests/test_outputs.py::test_23_svc_role_trusts_appsync PASSED         [ 40%]
../tests/test_outputs.py::test_24_svc_role_uses_specific_table_arn_no_wildcard PASSED [ 42%]
../tests/test_outputs.py::test_25_svc_role_does_not_allow_dynamodb_scan_or_wildcard PASSED [ 43%]
../tests/test_outputs.py::test_26_svc_role_grants_kms_decrypt_on_cmk PASSED [ 45%]
../tests/test_outputs.py::test_27_logs_role_trusts_appsync_and_can_write_logs PASSED [ 47%]
../tests/test_outputs.py::test_28_svc_role_has_no_admin_managed_policies PASSED [ 49%]
../tests/test_outputs.py::test_29_get_thing_is_pipeline_resolver PASSED  [ 50%]
../tests/test_outputs.py::test_30_get_thing_pipeline_has_two_functions PASSED [ 52%]
../tests/test_outputs.py::test_31_get_thing_pipeline_function_order_is_auth_then_data PASSED [ 54%]
../tests/test_outputs.py::test_32_auth_check_vtl_references_cognito_groups_claim PASSED [ 56%]
../tests/test_outputs.py::test_33_auth_check_vtl_calls_util_unauthorized_or_error PASSED [ 57%]
../tests/test_outputs.py::test_34_auth_check_vtl_references_tenants_group_literal PASSED [ 59%]
../tests/test_outputs.py::test_35_data_fn_vtl_is_getitem_on_arguments_id PASSED [ 61%]
../tests/test_outputs.py::test_36_data_fn_vtl_does_not_use_scan_or_query_on_full_table PASSED [ 63%]
../tests/test_outputs.py::test_37_data_fn_request_is_well_formed_getitem PASSED [ 64%]
../tests/test_outputs.py::test_38_api_cache_per_resolver_caching PASSED  [ 66%]
../tests/test_outputs.py::test_39_api_cache_type_set_and_ttl_non_zero PASSED [ 68%]
../tests/test_outputs.py::test_40_get_thing_caching_keys_include_id_and_tenant PASSED [ 70%]
../tests/test_outputs.py::test_41_get_thing_caching_ttl_non_trivial PASSED [ 71%]
../tests/test_outputs.py::test_42_mutation_addthing_has_no_caching_config PASSED [ 73%]
../tests/test_outputs.py::test_43_api_key_expiry_within_seven_days PASSED [ 75%]
../tests/test_outputs.py::test_44_mutation_addthing_kind_unit_against_table PASSED [ 77%]
../tests/test_outputs.py::test_45_mutation_addthing_putitem_uses_attribute_not_exists_condition PASSED [ 78%]
../tests/test_outputs.py::test_46_mutation_addthing_injects_tenant_and_owner_from_identity_not_arguments PASSED [ 80%]
../tests/test_outputs.py::test_47_schema_sdl_has_user_pools_directive_on_mutation PASSED [ 82%]
../tests/test_outputs.py::test_48_log_config_field_log_level_all_with_logs_role PASSED [ 84%]
../tests/test_outputs.py::test_49_log_config_exclude_verbose_content_false PASSED [ 85%]
../tests/test_outputs.py::test_50_xray_enabled_on_api PASSED             [ 87%]
../tests/test_outputs.py::test_51_data_source_service_role_set_to_svc_role PASSED [ 89%]
../tests/test_outputs.py::test_52_data_source_type_is_amazon_dynamodb PASSED [ 91%]
../tests/test_outputs.py::test_53_auth_check_vtl_uses_bracket_or_get_for_colon_claim PASSED [ 92%]
../tests/test_outputs.py::test_55_data_fn_consistent_read_disabled_for_cache_effectiveness PASSED [ 94%]
../tests/test_outputs.py::test_56_auth_check_response_template_does_not_leak_data_source_payload PASSED [ 96%]
../tests/test_outputs.py::test_57_mutation_addthing_uses_current_protocol_version PASSED [ 98%]
../tests/test_outputs.py::test_54_schema_mutation_addthing_does_not_accept_tenant_or_owner_args PASSED [100%]

=============================== warnings summary ===============================
test_outputs.py: 148 warnings
  /root/.cache/uv/archive-v0/VXtNhQTUhtvrwo8CDP_3x/lib/python3.12/site-packages/botocore/auth.py:424: DeprecationWarning: datetime.datetime.utcnow() is deprecated and scheduled for removal in a future version. Use timezone-aware objects to represent datetimes in UTC: datetime.datetime.now(datetime.UTC).
    datetime_now = datetime.datetime.utcnow()

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ../tests/test_outputs.py::test_01_appsync_api_exists
PASSED ../tests/test_outputs.py::test_02_user_pool_exists
PASSED ../tests/test_outputs.py::test_03_app_client_exists
PASSED ../tests/test_outputs.py::test_04_user_pool_group_tenants_exists
PASSED ../tests/test_outputs.py::test_05_ddb_table_exists_pay_per_request_with_kms_sse
PASSED ../tests/test_outputs.py::test_06_kms_alias_exists_and_pointed_in_ssm
PASSED ../tests/test_outputs.py::test_07_log_group_exists
PASSED ../tests/test_outputs.py::test_08_two_iam_roles_exist
PASSED ../tests/test_outputs.py::test_09_appsync_data_source_exists
PASSED ../tests/test_outputs.py::test_10_two_appsync_functions_exist
PASSED ../tests/test_outputs.py::test_11_two_resolvers_exist
PASSED ../tests/test_outputs.py::test_12_ssm_pointers_resolve
PASSED ../tests/test_outputs.py::test_13_ssm_pointer_values_have_correct_shape
PASSED ../tests/test_outputs.py::test_14_ssm_function_ids_resolve_to_real_functions
PASSED ../tests/test_outputs.py::test_15_api_authentication_type_cognito
PASSED ../tests/test_outputs.py::test_16_user_pool_config_matches_pointer
PASSED ../tests/test_outputs.py::test_17_user_pool_config_default_action_deny
PASSED ../tests/test_outputs.py::test_18_additional_auth_includes_api_key
PASSED ../tests/test_outputs.py::test_19_additional_auth_api_key_appears_exactly_once
PASSED ../tests/test_outputs.py::test_20_additional_auth_does_not_include_iam
PASSED ../tests/test_outputs.py::test_21_user_pool_has_custom_tenant_attribute
PASSED ../tests/test_outputs.py::test_22_app_client_has_no_admin_user_password_flow
PASSED ../tests/test_outputs.py::test_23_svc_role_trusts_appsync
PASSED ../tests/test_outputs.py::test_24_svc_role_uses_specific_table_arn_no_wildcard
PASSED ../tests/test_outputs.py::test_25_svc_role_does_not_allow_dynamodb_scan_or_wildcard
PASSED ../tests/test_outputs.py::test_26_svc_role_grants_kms_decrypt_on_cmk
PASSED ../tests/test_outputs.py::test_27_logs_role_trusts_appsync_and_can_write_logs
PASSED ../tests/test_outputs.py::test_28_svc_role_has_no_admin_managed_policies
PASSED ../tests/test_outputs.py::test_29_get_thing_is_pipeline_resolver
PASSED ../tests/test_outputs.py::test_30_get_thing_pipeline_has_two_functions
PASSED ../tests/test_outputs.py::test_31_get_thing_pipeline_function_order_is_auth_then_data
PASSED ../tests/test_outputs.py::test_32_auth_check_vtl_references_cognito_groups_claim
PASSED ../tests/test_outputs.py::test_33_auth_check_vtl_calls_util_unauthorized_or_error
PASSED ../tests/test_outputs.py::test_34_auth_check_vtl_references_tenants_group_literal
PASSED ../tests/test_outputs.py::test_35_data_fn_vtl_is_getitem_on_arguments_id
PASSED ../tests/test_outputs.py::test_36_data_fn_vtl_does_not_use_scan_or_query_on_full_table
PASSED ../tests/test_outputs.py::test_37_data_fn_request_is_well_formed_getitem
PASSED ../tests/test_outputs.py::test_38_api_cache_per_resolver_caching
PASSED ../tests/test_outputs.py::test_39_api_cache_type_set_and_ttl_non_zero
PASSED ../tests/test_outputs.py::test_40_get_thing_caching_keys_include_id_and_tenant
PASSED ../tests/test_outputs.py::test_41_get_thing_caching_ttl_non_trivial
PASSED ../tests/test_outputs.py::test_42_mutation_addthing_has_no_caching_config
PASSED ../tests/test_outputs.py::test_43_api_key_expiry_within_seven_days
PASSED ../tests/test_outputs.py::test_44_mutation_addthing_kind_unit_against_table
PASSED ../tests/test_outputs.py::test_45_mutation_addthing_putitem_uses_attribute_not_exists_condition
PASSED ../tests/test_outputs.py::test_46_mutation_addthing_injects_tenant_and_owner_from_identity_not_arguments
PASSED ../tests/test_outputs.py::test_47_schema_sdl_has_user_pools_directive_on_mutation
PASSED ../tests/test_outputs.py::test_48_log_config_field_log_level_all_with_logs_role
PASSED ../tests/test_outputs.py::test_49_log_config_exclude_verbose_content_false
PASSED ../tests/test_outputs.py::test_50_xray_enabled_on_api
PASSED ../tests/test_outputs.py::test_51_data_source_service_role_set_to_svc_role
PASSED ../tests/test_outputs.py::test_52_data_source_type_is_amazon_dynamodb
PASSED ../tests/test_outputs.py::test_53_auth_check_vtl_uses_bracket_or_get_for_colon_claim
PASSED ../tests/test_outputs.py::test_55_data_fn_consistent_read_disabled_for_cache_effectiveness
PASSED ../tests/test_outputs.py::test_56_auth_check_response_template_does_not_leak_data_source_payload
PASSED ../tests/test_outputs.py::test_57_mutation_addthing_uses_current_protocol_version
PASSED ../tests/test_outputs.py::test_54_schema_mutation_addthing_does_not_accept_tenant_or_owner_args
======================= 57 passed, 148 warnings in 0.94s =======================

Reproduce this trial: git checkout 2f94510 && PYTHONPATH=src python3 scripts/build_site.py , then open trial/trial_42f02b93ffd14b44. Re-running the agent live requires EVAL_PLATFORM_ENABLE_OAUTH_SMOKE=1 and is non-deterministic.

Trial trial_42f02b93ffd14b44 · verifier authoritative; classifier explanatory.