Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(cognito): new cloudFrontEndpoint method for user pool domain without custom resource #31402

Merged
merged 21 commits into from
Nov 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions packages/aws-cdk-lib/aws-cognito/lib/user-pool-domain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ export class UserPoolDomain extends Resource implements IUserPoolDomain {
private isCognitoDomain: boolean;

private cloudFrontCustomResource?: AwsCustomResource;
private resource: CfnUserPoolDomain;

constructor(scope: Construct, id: string, props: UserPoolDomainProps) {
super(scope, id);
Expand All @@ -114,18 +115,29 @@ export class UserPoolDomain extends Resource implements IUserPoolDomain {
this.isCognitoDomain = !!props.cognitoDomain;

const domainName = props.cognitoDomain?.domainPrefix || props.customDomain?.domainName!;
const resource = new CfnUserPoolDomain(this, 'Resource', {
this.resource = new CfnUserPoolDomain(this, 'Resource', {
userPoolId: props.userPool.userPoolId,
domain: domainName,
customDomainConfig: props.customDomain ? { certificateArn: props.customDomain.certificate.certificateArn } : undefined,
});

this.domainName = resource.ref;
this.domainName = this.resource.ref;
}

/**
* The domain name of the CloudFront distribution associated with the user pool domain.
*/
public get cloudFrontEndpoint(): string {
Copy link
Contributor Author

@go-to-k go-to-k Sep 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method name is based on the description in CFn doc.

The Amazon CloudFront endpoint that you use as the target of the alias that you set up with your Domain Name Service (DNS) provider.

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

return this.resource.getAtt('CloudFrontDistribution').toString();
}

/**
* The domain name of the CloudFront distribution associated with the user pool domain.
*
* This method creates a custom resource internally to get the CloudFront domain name.
*
* @deprecated use `cloudFrontEndpoint` method instead.
*/
public get cloudFrontDomainName(): string {
if (!this.cloudFrontCustomResource) {
const sdkCall: AwsSdkCall = {
Expand Down
Loading