UNPKG

@aws-cdk/aws-redshift-alpha

Version:

The CDK Construct Library for AWS::Redshift

2 lines (1 loc) 1.52 kB
"use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var c=Object.prototype.hasOwnProperty;var m=(e,r)=>{for(var n in r)s(e,n,{get:r[n],enumerable:!0})},p=(e,r,n,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of f(r))!c.call(e,t)&&t!==n&&s(e,t,{get:()=>r[t],enumerable:!(i=d(r,t))||i.enumerable});return e};var y=e=>p(s({},"__esModule",{value:!0}),e);var b={};m(b,{handler:()=>C});module.exports=y(b);var l=require("@aws-sdk/client-redshift"),u=new l.Redshift({});async function C(e){if(e.RequestType!=="Delete")return w(e.ResourceProperties?.ClusterId,e.ResourceProperties?.ParameterGroupName)}async function w(e,r){return n(await i());async function n(t,o){if(await P(o??0),["pending-reboot","apply-deferred","apply-error"].includes(t)){try{await u.rebootCluster({ClusterIdentifier:e})}catch(a){if(a.name==="InvalidClusterStateFault")return n(t,3e4);throw a}return}else if(["applying","retry"].includes(t))return n(await i(),3e4)}async function i(){let t=await u.describeClusters({ClusterIdentifier:e});if(t.Clusters?.[0].ClusterParameterGroups===void 0)throw new Error(`Unable to find any Parameter Groups associated with ClusterId "${e}".`);for(let o of t.Clusters?.[0].ClusterParameterGroups)if(o.ParameterGroupName===r)return o.ParameterApplyStatus??"retry";throw new Error(`Unable to find Parameter Group named "${r}" associated with ClusterId "${e}".`)}}function P(e){return new Promise(r=>setTimeout(r,e))}0&&(module.exports={handler});