-
Notifications
You must be signed in to change notification settings - Fork 4.5k
aws-apigateway: Custom log format account ID gets translated incorrectly #21731
Copy link
Copy link
Closed
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API GatewaybugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLIRelated to AWS CDK Tools or CLI
Description
Describe the bug
I want to set up custom log format for API Gateway:
new RestApi(this, "myapi", {
deployOptions: {
accessLogFormat: AccessLogFormat.custom(JSON.stringify({
accountId: AccessLogField.contextAccountId(),
...
})
})Expected Behavior
According to the definition of AccessLogField.contextAccountId() this should return The API owner's AWS account ID. After synthesizing the template, this should then get translated to $context.accountId.
Current Behavior
AccessLogField.contextAccountId() gets translated to $context.identity.accountId which would return the account ID of the caller.
Reproduction Steps
Setup a RestApi with custom log format and use AccessLogField.contextAccountId().
Possible Solution
No response
Additional Information/Context
No response
CDK CLI Version
2.38.1 (build a5ced21)
Framework Version
No response
Node.js Version
v16.17.0
OS
macOS
Language
Typescript
Language Version
No response
Other information
No response
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
@aws-cdk/aws-apigatewayRelated to Amazon API GatewayRelated to Amazon API GatewaybugThis issue is a bug.This issue is a bug.effort/smallSmall work item – less than a day of effortSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLIRelated to AWS CDK Tools or CLI