Skip to content

cognito: Remove custom resource from UserPoolDomain to get CloudFrontDistribution attribute #31342

@tmokmss

Description

@tmokmss

Describe the feature

Currently we use an AwsCutstomResource to get cloudFrontDomainName attribute for a UserPoolDomain resource.

public get cloudFrontDomainName(): string {
if (!this.cloudFrontCustomResource) {
const sdkCall: AwsSdkCall = {
service: 'CognitoIdentityServiceProvider',
action: 'describeUserPoolDomain',
parameters: {
Domain: this.domainName,
},

But actually CFn exposes the attribute natively. We can remove the unnecessary custom resource usage.

https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cognito-userpooldomain.html#aws-resource-cognito-userpooldomain-return-values

Use Case

To get a CloudFront domain for a user pool domain without using a custom resource. c.f. https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-add-custom-domain.html

Proposed Solution

We can just replace it with a getAtt call.

  public get cloudFrontDomainName(): string {
    return resource.getAtt('CloudFrontDistribution').toString(),
  }

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.155.0

Environment details (OS name and version, etc.)

macOS

Metadata

Metadata

Assignees

No one assigned

    Labels

    @aws-cdk/aws-cognitoRelated to Amazon Cognitoeffort/smallSmall work item – less than a day of effortfeature-requestA feature should be added or improved.p2

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions