diff --git a/packages/@aws-cdk/aws-apigateway/lib/access-log.ts b/packages/@aws-cdk/aws-apigateway/lib/access-log.ts index bc73b13d78604..77b13ec342fbb 100644 --- a/packages/@aws-cdk/aws-apigateway/lib/access-log.ts +++ b/packages/@aws-cdk/aws-apigateway/lib/access-log.ts @@ -43,12 +43,27 @@ export class LogGroupLogDestination implements IAccessLogDestination { */ export class AccessLogField { /** - * The API owner's AWS account ID. + * The API callers AWS account ID. + * @deprecated Use `contextCallerAccountId` or `contextOwnerAccountId` instead */ public static contextAccountId() { return '$context.identity.accountId'; } + /** + * The API callers AWS account ID. + */ + public static contextCallerAccountId() { + return '$context.identity.accountId'; + } + + /** + * The API owner's AWS account ID. + */ + public static contextOwnerAccountId() { + return '$context.accountId'; + } + /** * The identifier API Gateway assigns to your API. */ diff --git a/packages/@aws-cdk/aws-apigateway/test/access-log.test.ts b/packages/@aws-cdk/aws-apigateway/test/access-log.test.ts index 3262207317c38..dcd89fcdc69f2 100644 --- a/packages/@aws-cdk/aws-apigateway/test/access-log.test.ts +++ b/packages/@aws-cdk/aws-apigateway/test/access-log.test.ts @@ -31,12 +31,13 @@ describe('access log', () => { requestId: apigateway.AccessLogField.contextRequestId(), sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(), method: apigateway.AccessLogField.contextHttpMethod(), - accountId: apigateway.AccessLogField.contextAccountId(), + callerAccountId: apigateway.AccessLogField.contextCallerAccountId(), + ownerAccountId: apigateway.AccessLogField.contextOwnerAccountId(), userContext: { sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'), email: apigateway.AccessLogField.contextAuthorizerClaims('email'), }, })); - expect(testFormat.toString()).toEqual('{"requestId":"$context.requestId","sourceIp":"$context.identity.sourceIp","method":"$context.httpMethod","accountId":"$context.identity.accountId","userContext":{"sub":"$context.authorizer.claims.sub","email":"$context.authorizer.claims.email"}}'); + expect(testFormat.toString()).toEqual('{"requestId":"$context.requestId","sourceIp":"$context.identity.sourceIp","method":"$context.httpMethod","callerAccountId":"$context.identity.accountId","ownerAccountId":"$context.accountId","userContext":{"sub":"$context.authorizer.claims.sub","email":"$context.authorizer.claims.email"}}'); }); }); diff --git a/packages/@aws-cdk/aws-apigateway/test/integ.restapi.access-log.ts b/packages/@aws-cdk/aws-apigateway/test/integ.restapi.access-log.ts new file mode 100644 index 0000000000000..085429a4a70d6 --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/integ.restapi.access-log.ts @@ -0,0 +1,41 @@ +import * as logs from '@aws-cdk/aws-logs'; +import * as cdk from '@aws-cdk/core'; +import { IntegTest } from '@aws-cdk/integ-tests'; +import * as apigateway from '../lib'; + +class Test extends cdk.Stack { + constructor(scope: cdk.App, id: string) { + super(scope, id); + + const testFormat = apigateway.AccessLogFormat.custom(JSON.stringify({ + requestId: apigateway.AccessLogField.contextRequestId(), + sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(), + method: apigateway.AccessLogField.contextHttpMethod(), + callerAccountId: apigateway.AccessLogField.contextCallerAccountId(), + ownerAccountId: apigateway.AccessLogField.contextOwnerAccountId(), + userContext: { + sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'), + email: apigateway.AccessLogField.contextAuthorizerClaims('email'), + }, + })); + + const logGroup = new logs.LogGroup(this, 'MyLogGroup'); + const api = new apigateway.RestApi(this, 'MyApi', { + cloudWatchRole: true, + deployOptions: { + accessLogDestination: new apigateway.LogGroupLogDestination(logGroup), + accessLogFormat: testFormat, + }, + }); + api.root.addMethod('GET'); + } +} + +const app = new cdk.App(); + +const testCase = new Test(app, 'test-apigateway-access-logs'); +new IntegTest(app, 'apigateway-access-logs', { + testCases: [testCase], +}); + +app.synth(); diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets.json new file mode 100644 index 0000000000000..9fbb6d61f2ef6 --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { + "source": { + "path": "apigatewayaccesslogsDefaultTestDeployAssert751ACD40.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/apigatewayaccesslogsDefaultTestDeployAssert751ACD40.template.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/apigatewayaccesslogsDefaultTestDeployAssert751ACD40.template.json new file mode 100644 index 0000000000000..ad9d0fb73d1dd --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/apigatewayaccesslogsDefaultTestDeployAssert751ACD40.template.json @@ -0,0 +1,36 @@ +{ + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/cdk.out b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/cdk.out new file mode 100644 index 0000000000000..8ecc185e9dbee --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/cdk.out @@ -0,0 +1 @@ +{"version":"21.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/integ.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/integ.json new file mode 100644 index 0000000000000..d4936da78074f --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/integ.json @@ -0,0 +1,12 @@ +{ + "version": "21.0.0", + "testCases": { + "apigateway-access-logs/DefaultTest": { + "stacks": [ + "test-apigateway-access-logs" + ], + "assertionStack": "apigateway-access-logs/DefaultTest/DeployAssert", + "assertionStackName": "apigatewayaccesslogsDefaultTestDeployAssert751ACD40" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/manifest.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/manifest.json new file mode 100644 index 0000000000000..e9a6bd1d33e07 --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/manifest.json @@ -0,0 +1,153 @@ +{ + "version": "21.0.0", + "artifacts": { + "Tree": { + "type": "cdk:tree", + "properties": { + "file": "tree.json" + } + }, + "test-apigateway-access-logs.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "test-apigateway-access-logs.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "test-apigateway-access-logs": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "test-apigateway-access-logs.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/bfcd014ed17d9d37eb988448edc7e87eb2ab77e6f7508bf3de2714a6322c99b3.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "test-apigateway-access-logs.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "test-apigateway-access-logs.assets" + ], + "metadata": { + "/test-apigateway-access-logs/MyLogGroup/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyLogGroup5C0DAD85" + } + ], + "/test-apigateway-access-logs/MyApi/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApi49610EDF" + } + ], + "/test-apigateway-access-logs/MyApi/CloudWatchRole/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApiCloudWatchRole2BEC1A9C" + } + ], + "/test-apigateway-access-logs/MyApi/Account": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApiAccount13882D84" + } + ], + "/test-apigateway-access-logs/MyApi/Deployment/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApiDeploymentECB0D05E81594d6748b4b291f993111a5070d710" + } + ], + "/test-apigateway-access-logs/MyApi/DeploymentStage.prod/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApiDeploymentStageprodE1054AF0" + } + ], + "/test-apigateway-access-logs/MyApi/Endpoint": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApiEndpoint869ABE96" + } + ], + "/test-apigateway-access-logs/MyApi/Default/GET/Resource": [ + { + "type": "aws:cdk:logicalId", + "data": "MyApiGETD0C7AA0C" + } + ], + "/test-apigateway-access-logs/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/test-apigateway-access-logs/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "test-apigateway-access-logs" + }, + "apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets": { + "type": "cdk:asset-manifest", + "properties": { + "file": "apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "apigatewayaccesslogsDefaultTestDeployAssert751ACD40": { + "type": "aws:cloudformation:stack", + "environment": "aws://unknown-account/unknown-region", + "properties": { + "templateFile": "apigatewayaccesslogsDefaultTestDeployAssert751ACD40.template.json", + "validateOnSynth": false, + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", + "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json", + "requiresBootstrapStackVersion": 6, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", + "additionalDependencies": [ + "apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets" + ], + "lookupRole": { + "arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}", + "requiresBootstrapStackVersion": 8, + "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version" + } + }, + "dependencies": [ + "apigatewayaccesslogsDefaultTestDeployAssert751ACD40.assets" + ], + "metadata": { + "/apigateway-access-logs/DefaultTest/DeployAssert/BootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "BootstrapVersion" + } + ], + "/apigateway-access-logs/DefaultTest/DeployAssert/CheckBootstrapVersion": [ + { + "type": "aws:cdk:logicalId", + "data": "CheckBootstrapVersion" + } + ] + }, + "displayName": "apigateway-access-logs/DefaultTest/DeployAssert" + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/test-apigateway-access-logs.assets.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/test-apigateway-access-logs.assets.json new file mode 100644 index 0000000000000..c13870f1eec0b --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/test-apigateway-access-logs.assets.json @@ -0,0 +1,19 @@ +{ + "version": "21.0.0", + "files": { + "bfcd014ed17d9d37eb988448edc7e87eb2ab77e6f7508bf3de2714a6322c99b3": { + "source": { + "path": "test-apigateway-access-logs.template.json", + "packaging": "file" + }, + "destinations": { + "current_account-current_region": { + "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", + "objectKey": "bfcd014ed17d9d37eb988448edc7e87eb2ab77e6f7508bf3de2714a6322c99b3.json", + "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" + } + } + } + }, + "dockerImages": {} +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/test-apigateway-access-logs.template.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/test-apigateway-access-logs.template.json new file mode 100644 index 0000000000000..f20a96de67427 --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/test-apigateway-access-logs.template.json @@ -0,0 +1,184 @@ +{ + "Resources": { + "MyLogGroup5C0DAD85": { + "Type": "AWS::Logs::LogGroup", + "Properties": { + "RetentionInDays": 731 + }, + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "MyApi49610EDF": { + "Type": "AWS::ApiGateway::RestApi", + "Properties": { + "Name": "MyApi" + } + }, + "MyApiCloudWatchRole2BEC1A9C": { + "Type": "AWS::IAM::Role", + "Properties": { + "AssumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "apigateway.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "ManagedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" + ] + ] + } + ] + }, + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "MyApiAccount13882D84": { + "Type": "AWS::ApiGateway::Account", + "Properties": { + "CloudWatchRoleArn": { + "Fn::GetAtt": [ + "MyApiCloudWatchRole2BEC1A9C", + "Arn" + ] + } + }, + "DependsOn": [ + "MyApi49610EDF" + ], + "UpdateReplacePolicy": "Retain", + "DeletionPolicy": "Retain" + }, + "MyApiDeploymentECB0D05E81594d6748b4b291f993111a5070d710": { + "Type": "AWS::ApiGateway::Deployment", + "Properties": { + "RestApiId": { + "Ref": "MyApi49610EDF" + }, + "Description": "Automatically created by the RestApi construct" + }, + "DependsOn": [ + "MyApiGETD0C7AA0C" + ] + }, + "MyApiDeploymentStageprodE1054AF0": { + "Type": "AWS::ApiGateway::Stage", + "Properties": { + "RestApiId": { + "Ref": "MyApi49610EDF" + }, + "AccessLogSetting": { + "DestinationArn": { + "Fn::GetAtt": [ + "MyLogGroup5C0DAD85", + "Arn" + ] + }, + "Format": "{\"requestId\":\"$context.requestId\",\"sourceIp\":\"$context.identity.sourceIp\",\"method\":\"$context.httpMethod\",\"callerAccountId\":\"$context.identity.accountId\",\"ownerAccountId\":\"$context.accountId\",\"userContext\":{\"sub\":\"$context.authorizer.claims.sub\",\"email\":\"$context.authorizer.claims.email\"}}" + }, + "DeploymentId": { + "Ref": "MyApiDeploymentECB0D05E81594d6748b4b291f993111a5070d710" + }, + "StageName": "prod" + }, + "DependsOn": [ + "MyApiAccount13882D84" + ] + }, + "MyApiGETD0C7AA0C": { + "Type": "AWS::ApiGateway::Method", + "Properties": { + "HttpMethod": "GET", + "ResourceId": { + "Fn::GetAtt": [ + "MyApi49610EDF", + "RootResourceId" + ] + }, + "RestApiId": { + "Ref": "MyApi49610EDF" + }, + "AuthorizationType": "NONE", + "Integration": { + "Type": "MOCK" + } + } + } + }, + "Outputs": { + "MyApiEndpoint869ABE96": { + "Value": { + "Fn::Join": [ + "", + [ + "https://", + { + "Ref": "MyApi49610EDF" + }, + ".execute-api.", + { + "Ref": "AWS::Region" + }, + ".", + { + "Ref": "AWS::URLSuffix" + }, + "/", + { + "Ref": "MyApiDeploymentStageprodE1054AF0" + }, + "/" + ] + ] + } + } + }, + "Parameters": { + "BootstrapVersion": { + "Type": "AWS::SSM::Parameter::Value", + "Default": "/cdk-bootstrap/hnb659fds/version", + "Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]" + } + }, + "Rules": { + "CheckBootstrapVersion": { + "Assertions": [ + { + "Assert": { + "Fn::Not": [ + { + "Fn::Contains": [ + [ + "1", + "2", + "3", + "4", + "5" + ], + { + "Ref": "BootstrapVersion" + } + ] + } + ] + }, + "AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI." + } + ] + } + } +} \ No newline at end of file diff --git a/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/tree.json b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/tree.json new file mode 100644 index 0000000000000..4520e2a77abb1 --- /dev/null +++ b/packages/@aws-cdk/aws-apigateway/test/restapi.access-log.integ.snapshot/tree.json @@ -0,0 +1,304 @@ +{ + "version": "tree-0.1", + "tree": { + "id": "App", + "path": "", + "children": { + "Tree": { + "id": "Tree", + "path": "Tree", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.95" + } + }, + "test-apigateway-access-logs": { + "id": "test-apigateway-access-logs", + "path": "test-apigateway-access-logs", + "children": { + "MyLogGroup": { + "id": "MyLogGroup", + "path": "test-apigateway-access-logs/MyLogGroup", + "children": { + "Resource": { + "id": "Resource", + "path": "test-apigateway-access-logs/MyLogGroup/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::Logs::LogGroup", + "aws:cdk:cloudformation:props": { + "retentionInDays": 731 + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-logs.CfnLogGroup", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-logs.LogGroup", + "version": "0.0.0" + } + }, + "MyApi": { + "id": "MyApi", + "path": "test-apigateway-access-logs/MyApi", + "children": { + "Resource": { + "id": "Resource", + "path": "test-apigateway-access-logs/MyApi/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::RestApi", + "aws:cdk:cloudformation:props": { + "name": "MyApi" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.CfnRestApi", + "version": "0.0.0" + } + }, + "CloudWatchRole": { + "id": "CloudWatchRole", + "path": "test-apigateway-access-logs/MyApi/CloudWatchRole", + "children": { + "Resource": { + "id": "Resource", + "path": "test-apigateway-access-logs/MyApi/CloudWatchRole/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::IAM::Role", + "aws:cdk:cloudformation:props": { + "assumeRolePolicyDocument": { + "Statement": [ + { + "Action": "sts:AssumeRole", + "Effect": "Allow", + "Principal": { + "Service": "apigateway.amazonaws.com" + } + } + ], + "Version": "2012-10-17" + }, + "managedPolicyArns": [ + { + "Fn::Join": [ + "", + [ + "arn:", + { + "Ref": "AWS::Partition" + }, + ":iam::aws:policy/service-role/AmazonAPIGatewayPushToCloudWatchLogs" + ] + ] + } + ] + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.CfnRole", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-iam.Role", + "version": "0.0.0" + } + }, + "Account": { + "id": "Account", + "path": "test-apigateway-access-logs/MyApi/Account", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Account", + "aws:cdk:cloudformation:props": { + "cloudWatchRoleArn": { + "Fn::GetAtt": [ + "MyApiCloudWatchRole2BEC1A9C", + "Arn" + ] + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.CfnAccount", + "version": "0.0.0" + } + }, + "Deployment": { + "id": "Deployment", + "path": "test-apigateway-access-logs/MyApi/Deployment", + "children": { + "Resource": { + "id": "Resource", + "path": "test-apigateway-access-logs/MyApi/Deployment/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Deployment", + "aws:cdk:cloudformation:props": { + "restApiId": { + "Ref": "MyApi49610EDF" + }, + "description": "Automatically created by the RestApi construct" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.CfnDeployment", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.Deployment", + "version": "0.0.0" + } + }, + "DeploymentStage.prod": { + "id": "DeploymentStage.prod", + "path": "test-apigateway-access-logs/MyApi/DeploymentStage.prod", + "children": { + "Resource": { + "id": "Resource", + "path": "test-apigateway-access-logs/MyApi/DeploymentStage.prod/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Stage", + "aws:cdk:cloudformation:props": { + "restApiId": { + "Ref": "MyApi49610EDF" + }, + "accessLogSetting": { + "destinationArn": { + "Fn::GetAtt": [ + "MyLogGroup5C0DAD85", + "Arn" + ] + }, + "format": "{\"requestId\":\"$context.requestId\",\"sourceIp\":\"$context.identity.sourceIp\",\"method\":\"$context.httpMethod\",\"callerAccountId\":\"$context.identity.accountId\",\"ownerAccountId\":\"$context.accountId\",\"userContext\":{\"sub\":\"$context.authorizer.claims.sub\",\"email\":\"$context.authorizer.claims.email\"}}" + }, + "deploymentId": { + "Ref": "MyApiDeploymentECB0D05E81594d6748b4b291f993111a5070d710" + }, + "stageName": "prod" + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.CfnStage", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.Stage", + "version": "0.0.0" + } + }, + "Endpoint": { + "id": "Endpoint", + "path": "test-apigateway-access-logs/MyApi/Endpoint", + "constructInfo": { + "fqn": "@aws-cdk/core.CfnOutput", + "version": "0.0.0" + } + }, + "Default": { + "id": "Default", + "path": "test-apigateway-access-logs/MyApi/Default", + "children": { + "GET": { + "id": "GET", + "path": "test-apigateway-access-logs/MyApi/Default/GET", + "children": { + "Resource": { + "id": "Resource", + "path": "test-apigateway-access-logs/MyApi/Default/GET/Resource", + "attributes": { + "aws:cdk:cloudformation:type": "AWS::ApiGateway::Method", + "aws:cdk:cloudformation:props": { + "httpMethod": "GET", + "resourceId": { + "Fn::GetAtt": [ + "MyApi49610EDF", + "RootResourceId" + ] + }, + "restApiId": { + "Ref": "MyApi49610EDF" + }, + "authorizationType": "NONE", + "integration": { + "type": "MOCK" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.CfnMethod", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.Method", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.ResourceBase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/aws-apigateway.RestApi", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + }, + "apigateway-access-logs": { + "id": "apigateway-access-logs", + "path": "apigateway-access-logs", + "children": { + "DefaultTest": { + "id": "DefaultTest", + "path": "apigateway-access-logs/DefaultTest", + "children": { + "Default": { + "id": "Default", + "path": "apigateway-access-logs/DefaultTest/Default", + "constructInfo": { + "fqn": "constructs.Construct", + "version": "10.1.95" + } + }, + "DeployAssert": { + "id": "DeployAssert", + "path": "apigateway-access-logs/DefaultTest/DeployAssert", + "constructInfo": { + "fqn": "@aws-cdk/core.Stack", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTestCase", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/integ-tests.IntegTest", + "version": "0.0.0" + } + } + }, + "constructInfo": { + "fqn": "@aws-cdk/core.App", + "version": "0.0.0" + } + } +} \ No newline at end of file