Skip to content

aws-apigateway: Custom log format account ID gets translated incorrectly #21731

@LiMuBei

Description

@LiMuBei

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

Metadata

Metadata

Assignees

Labels

@aws-cdk/aws-apigatewayRelated to Amazon API GatewaybugThis issue is a bug.effort/smallSmall work item – less than a day of effortgood first issueRelated to contributions. See CONTRIBUTING.mdp1package/toolsRelated to AWS CDK Tools or CLI

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions