UNPKG

@collaborne/custom-cloudformation-resources

Version:
56 lines 1.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.UserPoolDomainAttributes = void 0; const aws_sdk_1 = require("aws-sdk"); const custom_resource_1 = require("../custom-resource"); const SCHEMA = { type: 'object', properties: { UserPoolDomain: { type: 'string', }, UserPoolId: { type: 'string', comment: 'Required to ensure that the attributes get updated when the domain is moved between user pools', }, }, required: ['UserPoolDomain', 'UserPoolId'], }; class UserPoolDomainAttributes extends custom_resource_1.CustomResource { constructor(logicalResourceId, logger) { super(SCHEMA, logicalResourceId, logger); this.cognitoIdp = new aws_sdk_1.CognitoIdentityServiceProvider(); } async createResource(physicalResourceId, { UserPoolDomain: userPoolDomain }) { const attributes = await this.getAttributes(userPoolDomain); return { physicalResourceId, attributes, }; } async deleteResource(physicalResourceId) { return { physicalResourceId, }; } async updateResource(physicalResourceId, { UserPoolDomain: userPoolDomain }) { const attributes = await this.getAttributes(userPoolDomain); return { physicalResourceId, attributes, }; } async getAttributes(userPoolDomain) { const response = await this.cognitoIdp .describeUserPoolDomain({ Domain: userPoolDomain, }) .promise(); if (!response.DomainDescription) { throw new Error(`Unknown Cognito user pool domain ${userPoolDomain}`); } return response.DomainDescription; } } exports.UserPoolDomainAttributes = UserPoolDomainAttributes; //# sourceMappingURL=index.js.map