aws-cognito: UserPoolGroup.groupName wrongly set to resource ref
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
Creating a UserPoolGroup object allows for setting the groupName attribute. However, the resource constructor is [overriding the field to the resource ref](https://github.com/aws/aws-cdk/blob/7379a4bb7d632c207cc67d3b038c9a8d4ed142bc/packages/aws-cdk-lib/aws-cognito/lib/user-pool-group.ts#L127).
While the underlying CfnUserPoolGroup is correctly created in CloudFormation, it is impossible to refer to the actual, explicitly set groupName in the CDK code. This makes it impossible to e.g. filter for a group in an array of groups by name.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
The explicitly set groupName attribute not to be overridden but taken, set and kept as specified for later reference.
### Current Behavior
groupName being overwritten with the cfn resource ref
### Reproduction Steps
```
const userPoolGroups: cognito.UserPoolGroup[] = [];
for (const userPoolGroupName of ["adminA", "adminB", "user"]) {
userPoolGroups.push(
new cognito.UserPoolGroup(this, userPoolGroupName, {
userPool: this.userPool,
groupName: userPoolGroupName,
})
);
}
new cdk.CfnOutput(this, "adminUserPoolGroupNames", {
value: userPoolGroups.map((group) => group.groupName).join(", "),
});
```
The output will NOT have the groupNames, but the group refs as value
### Possible Solution
do not set the groupName attribute to the resource ref, but the user provided groupName
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
2.217.0
### AWS CDK CLI version
2.1023.0 (build 45ceb89)
### Node.js Version
v20.19.3
### OS
Mac OS
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start in packages/aws-cdk-lib/aws-cognito/lib/user-pool-group.ts at the constructor line linked in the issue, then reproduce the TypeScript example with several UserPoolGroup instances. Done means the explicitly supplied groupName remains available through group.groupName and the CfnOutput contains the names rather than resource references.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- authentication, cloud
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100