Stop aws stack creation if stack already exists
parent
a76135128d
commit
8343c06c71
|
|
@ -806,6 +806,7 @@ const core = __importStar(__webpack_require__(42186));
|
|||
class AWSError {
|
||||
static handleStackCreationFailure(error, CF, taskDefStackName, taskDefCloudFormation, parameters, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
cloud_runner_logger_1.default.log(' \n ');
|
||||
cloud_runner_logger_1.default.log('aws stack parameters: ');
|
||||
cloud_runner_logger_1.default.log(JSON.stringify(parameters, undefined, 4));
|
||||
cloud_runner_logger_1.default.log('aws stack secrets: ');
|
||||
|
|
@ -937,6 +938,20 @@ class AWSJobStack {
|
|||
},
|
||||
...secretsMappedToCloudFormationParameters,
|
||||
];
|
||||
let previousStackExists = true;
|
||||
while (previousStackExists) {
|
||||
previousStackExists = false;
|
||||
const stacks = yield CF.listStacks().promise();
|
||||
if (!stacks.StackSummaries) {
|
||||
throw new Error('Faild to get stacks');
|
||||
}
|
||||
for (let index = 0; index < stacks.StackSummaries.length; index++) {
|
||||
const element = stacks.StackSummaries[index];
|
||||
if (element.StackName === taskDefStackName) {
|
||||
previousStackExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
try {
|
||||
yield CF.createStack({
|
||||
StackName: taskDefStackName,
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -12,6 +12,7 @@ export class AWSError {
|
|||
parameters: any[],
|
||||
secrets: CloudRunnerSecret[],
|
||||
) {
|
||||
CloudRunnerLogger.log(' \n ');
|
||||
CloudRunnerLogger.log('aws stack parameters: ');
|
||||
CloudRunnerLogger.log(JSON.stringify(parameters, undefined, 4));
|
||||
|
||||
|
|
|
|||
|
|
@ -101,6 +101,21 @@ export class AWSJobStack {
|
|||
...secretsMappedToCloudFormationParameters,
|
||||
];
|
||||
|
||||
let previousStackExists = true;
|
||||
while (previousStackExists) {
|
||||
previousStackExists = false;
|
||||
const stacks = await CF.listStacks().promise();
|
||||
if (!stacks.StackSummaries) {
|
||||
throw new Error('Faild to get stacks');
|
||||
}
|
||||
for (let index = 0; index < stacks.StackSummaries.length; index++) {
|
||||
const element = stacks.StackSummaries[index];
|
||||
if (element.StackName === taskDefStackName) {
|
||||
previousStackExists = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
await CF.createStack({
|
||||
StackName: taskDefStackName,
|
||||
|
|
|
|||
Loading…
Reference in New Issue