fixed status for newly created stacks

This commit is contained in:
Arwid Thornström
2022-01-25 11:40:16 +01:00
parent c00be4305e
commit 13af2cebba
@@ -22,18 +22,29 @@ module.exports = {
const stacks = JSON.parse(strings.trim(await system.run(`aws cloudformation list-stacks`)));
const teststacks: Stack[] = await Promise.all(stacks.StackSummaries.map(async (item) => {
if (item.StackName.indexOf('photowall-test-') > -1 && ['CREATE_COMPLETE', 'UPDATE_COMPLETE', 'UPDATE_IN_PROGRESS', 'UPDATE_FAILED', 'CREATE_FAILED', 'CREATE_IN_PROGRESS'].includes(item.StackStatus)) {
const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`)));
const branch = pipeline.pipeline.stages.filter(stage => {
return stage.name === 'Source';
})[0].actions[0].configuration.Branch;
const lastUpdated = pipeline.metadata.updated;
return {
name: item.StackName,
status: item.StackStatus,
drift_status: item.DriftInformation.StackDriftStatus,
branch: branch,
updated: lastUpdated,
try {
const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`)));
const branch = pipeline.pipeline.stages.filter(stage => {
return stage.name === 'Source';
})[0].actions[0].configuration.Branch;
const lastUpdated = pipeline.metadata.updated;
return {
name: item.StackName,
status: item.StackStatus,
drift_status: item.DriftInformation.StackDriftStatus,
branch: branch,
updated: lastUpdated,
}
} catch (e) {
return {
name: item.StackName,
status: 'NO_STATUS',
drift_status: '',
branch: '',
updated: '',
}
}
}
return Promise.resolve(null);
}));
@@ -42,6 +53,8 @@ module.exports = {
const status = (status: string) => {
switch(status) {
case 'NO_STATUS':
return ` (❓) `;
case 'UPDATE_FAILED':
case 'CREATE_FAILED':
return ` (💔) `;