Route53.PrivateHostedZone: queryLogsLogGroupArn breaks cloudformation deployment with error "You can't create a query logging config for a private hosted zone." #27986
Labels
@aws-cdk/aws-route53
Related to Amazon Route 53
bug
This issue is a bug.
effort/medium
Medium work item – several days of effort
p2
Describe the bug
I created a Route53 private hosted zone using TypeScript CDK. I then added a CloudWatch Logs log group, and tried to use the PrivateHostedZone construct's queryLogsLogGroupArn prop to send Route53 query logs to the log group. The CDK built the stack successfully but then the stack failed to deploy with CloudFormation returning this error:
This leads me to believe that the CDK is trying to deploy the wrong thing. Query logging for private hosted zones originates from the VPC, not the hosted zone itself, as is apparent in the L1 constructs CfnResolverQueryLoggingConfig and CfnResolverQueryLoggingConfigAssociation.
Expected Behavior
I expected the PrivateHostedZone construct's queryLogsLogGroupArn prop to automatically hook up the private hosted zone VPC's query log output to the specified query log group ARN.
Current Behavior
Stack deployment failed with this error:
Reproduction Steps
Relevant chunks to produce the failure:
Possible Solution
I'm guessing that the PrivateHostedZone construct is reusing code from the (public) HostedZone construct, which also has a queryLogsLogGroupArn prop. However for private hosted zones, the query logging happens at the VPC, not the Hosted Zone. So maybe the PrivateHostedZone construct needs to be updated so it's smart enough to figure out its primary VPC (see footnote) and in the background sets up the cfnResolverQueryLoggingConfigAssociation between that VPC and the log group.
footnote: Is it possible to determine a "primary" VPC for a private hosted zone? Private hosted zones can be associated with many VPCs, including cross-account. Maybe this would require an explicit VPC argument to go along with the queryLogsLogGroupArn argument, or maybe this would be better-suited as a VPC construct update.
Additional Information/Context
You can work around this issue using the L1 constructs, as I did here:
CDK CLI Version
2.103.1 (build 3bb19ac)
Framework Version
No response
Node.js Version
18
OS
Mac
Language
TypeScript
Language Version
No response
Other information
No response
The text was updated successfully, but these errors were encountered: