UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.1 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ResourceHandler=void 0;class ResourceHandler{constructor(eks,event){this.eks=eks,this.requestType=event.RequestType,this.requestId=event.RequestId,this.logicalResourceId=event.LogicalResourceId,this.physicalResourceId=event.PhysicalResourceId,this.event=event;const roleToAssume=event.ResourceProperties.AssumeRoleArn;if(!roleToAssume)throw new Error("AssumeRoleArn must be provided");eks.configureAssumeRole({RoleArn:roleToAssume,RoleSessionName:`AWSCDK.EKSCluster.${this.requestType}.${this.requestId}`})}onEvent(){switch(this.requestType){case"Create":return this.onCreate();case"Update":return this.onUpdate();case"Delete":return this.onDelete()}throw new Error(`Invalid request type ${this.requestType}`)}isComplete(){switch(this.requestType){case"Create":return this.isCreateComplete();case"Update":return this.isUpdateComplete();case"Delete":return this.isDeleteComplete()}throw new Error(`Invalid request type ${this.requestType}`)}log(x){console.log(JSON.stringify(x,void 0,2))}}exports.ResourceHandler=ResourceHandler;