Skip to content

Commit

Permalink
fix(apigateway): update value of the contextAccountId in AccessLogField
Browse files Browse the repository at this point in the history
Fixes #7951
  • Loading branch information
loganek committed May 13, 2020
1 parent ad5e35e commit 275c135
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-apigateway/lib/access-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AccessLogField {
* The API owner's AWS account ID.
*/
public static contextAccountId() {
return '$context.requestId';
return '$context.identity.accountId';
}

/**
Expand Down
3 changes: 2 additions & 1 deletion packages/@aws-cdk/aws-apigateway/test/test.access-log.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,13 @@ export = {
requestId: apigateway.AccessLogField.contextRequestId(),
sourceIp: apigateway.AccessLogField.contextIdentitySourceIp(),
method: apigateway.AccessLogField.contextHttpMethod(),
accountId: apigateway.AccessLogField.contextAccountId(),
userContext: {
sub: apigateway.AccessLogField.contextAuthorizerClaims('sub'),
email: apigateway.AccessLogField.contextAuthorizerClaims('email'),
},
}));
test.deepEqual(testFormat.toString(), '{"requestId":"$context.requestId","sourceIp":"$context.identity.sourceIp","method":"$context.httpMethod","userContext":{"sub":"$context.authorizer.claims.sub","email":"$context.authorizer.claims.email"}}');
test.deepEqual(testFormat.toString(), '{"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"}}');

test.done();
},
Expand Down

0 comments on commit 275c135

Please sign in to comment.