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 stacks = JSON.parse(strings.trim(await system.run(`aws cloudformation list-stacks`)));
const teststacks: Stack[] = await Promise.all(stacks.StackSummaries.map(async (item) => { 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)) { 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`))); try {
const branch = pipeline.pipeline.stages.filter(stage => { const pipeline = JSON.parse(strings.trim(await system.run(`aws codepipeline get-pipeline --name ${item.StackName}Pipeline`)));
return stage.name === 'Source'; const branch = pipeline.pipeline.stages.filter(stage => {
})[0].actions[0].configuration.Branch; return stage.name === 'Source';
const lastUpdated = pipeline.metadata.updated; })[0].actions[0].configuration.Branch;
return { const lastUpdated = pipeline.metadata.updated;
name: item.StackName, return {
status: item.StackStatus, name: item.StackName,
drift_status: item.DriftInformation.StackDriftStatus, status: item.StackStatus,
branch: branch, drift_status: item.DriftInformation.StackDriftStatus,
updated: lastUpdated, branch: branch,
updated: lastUpdated,
}
} catch (e) {
return {
name: item.StackName,
status: 'NO_STATUS',
drift_status: '',
branch: '',
updated: '',
}
} }
} }
return Promise.resolve(null); return Promise.resolve(null);
})); }));
@@ -42,6 +53,8 @@ module.exports = {
const status = (status: string) => { const status = (status: string) => {
switch(status) { switch(status) {
case 'NO_STATUS':
return ` (❓) `;
case 'UPDATE_FAILED': case 'UPDATE_FAILED':
case 'CREATE_FAILED': case 'CREATE_FAILED':
return ` (💔) `; return ` (💔) `;