aws-cognito: CfnLogDeliveryConfiguration wrong regular expression
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
I can't create a `CfnLogDeliveryConfiguration` because it is not accepting my log group arn
```typescript
const userpolLogsGroup = new logs.LogGroup(
this,
"node-ready-user-pool-logs-group",
{
logGroupName: "/node-ready/cognito/userpool/node-ready-user-pool",
removalPolicy: cdk.RemovalPolicy.DESTROY,
retention: logs.RetentionDays.ONE_WEEK,
},
);
new cognito.CfnLogDeliveryConfiguration(
this,
"node-ready-user-pool-log-delivery-configuration",
{
userPoolId: this.cognitoUserPool.userPoolId,
logConfigurations: [
{
cloudWatchLogsConfiguration: {
logGroupArn: userpolLogsGroup.logGroupArn,
},
eventSource: "userNotification",
logLevel: "ERROR",
},
],
},
);
```

As you can see, the issue is with the "*" at the end, which the regular expression for CloudWatchLogsConfiguration.logGroupArn doesn't accept.
### Regression Issue
- [X ] Select this option if this issue appears to be a regression.
-
Apparently you touched it already, according to a ticket a guy reported few months ago. But it broke again in a different part of the regex
https://repost.aws/questions/QUhjYRB83zR_Od3frN-PRQww/cloudformation-regex-validation-error-in-cognito-logdeliveryconfiguration-cloudwatchlogsconfiguration-loggrouparn
### Last Known Working CDK Version
2.154.0
### Expected Behavior
CfnLogDeliveryConfiguration.logConfigurations.cloudWatchLogsConfiguration.logGroupArn must accept Logs Group Arns that end with "*"
The official documentation for this property is also wrong, as you can see in the image below
source: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-cognito-logdeliveryconfiguration-cloudwatchlogsconfiguration.html
### Current Behavior

### Reproduction Steps
Try to deploy a CDK V2 Stack with these constructs in it
```typescript
const userpolLogsGroup = new logs.LogGroup(
this,
"node-ready-user-pool-logs-group",
{
logGroupName: "/node-ready/cognito/userpool/node-ready-user-pool",
removalPolicy: cdk.RemovalPolicy.DESTROY,
retention: logs.RetentionDays.ONE_WEEK,
},
);
new cognito.CfnLogDeliveryConfiguration(
this,
"node-ready-user-pool-log-delivery-configuration",
{
userPoolId: this.cognitoUserPool.userPoolId,
logConfigurations: [
{
cloudWatchLogsConfiguration: {
logGroupArn: userpolLogsGroup.logGroupArn,
},
eventSource: "userNotification",
logLevel: "ERROR",
},
],
},
);
```
### Possible Solution
Before validating the ARN, which is generated by cloudformation, split it by : , remove the last token, validate. This way you don't need to change the regex expression you currently use.
#### WORKAROUND
Build the arn yourself instead of relying on cloudfromation
````typescript
new cognito.CfnLogDeliveryConfiguration(
this,
"node-ready-user-pool-log-delivery-configuration",
{
userPoolId: this.cognitoUserPool.userPoolId,
logConfigurations: [
{
cloudWatchLogsConfiguration: {
logGroupArn: `arn:aws:logs:${getEnvVar("CDK_DEFAULT_REGION")}:${getEnvVar("CDK_DEFAULT_ACCOUNT")}:log-group:${userpolLogsGroup.logGroupName}`,
},
eventSource: "userNotification",
logLevel: "ERROR",
},
],
},
);
````
### Additional Information/Context
_No response_
### CDK CLI Version
2.154.0
### Framework Version
_No response_
### Node.js Version
18.19
### OS
macos
### Language
TypeScript
### Language Version
5.0.4
### Other information
_No response_
Contributor guide
Research direction
Start with the CfnLogDeliveryConfiguration construct and its logConfigurations.cloudWatchLogsConfiguration.logGroupArn property, then reproduce the validation failure using the TypeScript example in the issue. Trace where the ARN regular expression is defined and covered, and confirm done when CloudWatch log group ARNs ending in '*' are accepted without rejecting existing valid ARNs.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100