@cumulus/aws-client
Version:
Utilities for working with AWS
42 lines • 1.66 kB
JavaScript
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
const p_retry_1 = __importDefault(require("p-retry"));
const logger_1 = __importDefault(require("@cumulus/logger"));
const errors_1 = require("@cumulus/errors");
const log = new logger_1.default({ sender: 'aws-client/CloudFormationGateway' });
class CloudFormationGateway {
constructor(cloudFormationService) {
this.cloudFormationService = cloudFormationService;
}
/**
* Get the status of a CloudFormation stack
*
* @param {string} StackName
* @returns {string} the stack status
*/
async getStackStatus(StackName) {
return await (0, p_retry_1.default)(async () => {
try {
const stackDetails = await this.cloudFormationService.describeStacks({
StackName,
});
if (!stackDetails.Stacks) {
throw new Error(`Could not fetch stack details of ${StackName}`);
}
return stackDetails.Stacks[0].StackStatus;
}
catch (error) {
if ((0, errors_1.isThrottlingException)(error))
throw new Error('Trigger retry');
throw new p_retry_1.default.AbortError(error);
}
}, {
maxTimeout: 5000,
onFailedAttempt: () => log.debug('ThrottlingException when calling cloudformation.describeStacks(), will retry.'),
});
}
}
module.exports = CloudFormationGateway;
//# sourceMappingURL=CloudFormationGateway.js.map
;