fix aws check for base stack
parent
54cdb38171
commit
a9d25bcd6d
|
|
@ -1031,16 +1031,10 @@ class AWSBuildEnvironment {
|
||||||
const describeStackInput = {
|
const describeStackInput = {
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
};
|
};
|
||||||
let CFState;
|
const stacks = (_a = (yield CF.listStacks().promise()).StackSummaries) === null || _a === void 0 ? void 0 : _a.map((x) => x.StackName);
|
||||||
try {
|
const stackExists = (stacks === null || stacks === void 0 ? void 0 : stacks.includes(baseStackName)) || false;
|
||||||
CFState = yield CF.describeStacks(describeStackInput).promise();
|
|
||||||
}
|
|
||||||
catch (_g) {
|
|
||||||
CFState = { Stacks: [] };
|
|
||||||
}
|
|
||||||
const stackExists = CFState.Stacks !== null && CFState.Stacks !== [];
|
|
||||||
if (!stackExists) {
|
if (!stackExists) {
|
||||||
core.info('stack exists');
|
core.info('stack does not exist');
|
||||||
yield CF.createStack({
|
yield CF.createStack({
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
TemplateBody: baseStack,
|
||||||
|
|
@ -1050,15 +1044,19 @@ class AWSBuildEnvironment {
|
||||||
{ ParameterKey: 'Version', ParameterValue: `hash` },
|
{ ParameterKey: 'Version', ParameterValue: `hash` },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
CFState = yield CF.describeStacks(describeStackInput).promise();
|
|
||||||
}
|
}
|
||||||
else {
|
const CFState = yield CF.describeStacks(describeStackInput).promise();
|
||||||
const stack = (_a = CFState.Stacks) === null || _a === void 0 ? void 0 : _a[0];
|
let stack = (_b = CFState.Stacks) === null || _b === void 0 ? void 0 : _b[0];
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
throw new Error('expected base stack to exist');
|
throw new Error(`Base stack doesn't exist, even after creation, stackExists check: ${stackExists}`);
|
||||||
}
|
}
|
||||||
|
if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
|
||||||
|
yield CF.waitFor('stackCreateComplete', describeStackInput).promise();
|
||||||
|
}
|
||||||
|
if (stackExists) {
|
||||||
|
core.info('stack exists');
|
||||||
if (stack.StackName === baseStackName &&
|
if (stack.StackName === baseStackName &&
|
||||||
hash !== ((_c = (_b = stack.Parameters) === null || _b === void 0 ? void 0 : _b.find((x) => x.ParameterKey === 'Version')) === null || _c === void 0 ? void 0 : _c.ParameterValue)) {
|
hash !== ((_d = (_c = stack.Parameters) === null || _c === void 0 ? void 0 : _c.find((x) => x.ParameterKey === 'Version')) === null || _d === void 0 ? void 0 : _d.ParameterValue)) {
|
||||||
const updateInput = {
|
const updateInput = {
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
TemplateBody: baseStack,
|
||||||
|
|
@ -1066,15 +1064,17 @@ class AWSBuildEnvironment {
|
||||||
yield CF.updateStack(updateInput).promise();
|
yield CF.updateStack(updateInput).promise();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
core.info(`Skipping any update for base stack ${stack.StackName} ${(_d = stack.Parameters) === null || _d === void 0 ? void 0 : _d.find((x) => x.ParameterKey === 'Version')}`);
|
core.info(`Skipping any update for base stack ${stack.StackName} ${(_e = stack.Parameters) === null || _e === void 0 ? void 0 : _e.find((x) => x.ParameterKey === 'Version')}`);
|
||||||
|
}
|
||||||
|
stack = (_f = (yield CF.describeStacks(describeStackInput).promise()).Stacks) === null || _f === void 0 ? void 0 : _f[0];
|
||||||
|
if (!stack) {
|
||||||
|
throw new Error(`Base stack doesn't exist, even after updating and creation, stackExists check: ${stackExists}`);
|
||||||
|
}
|
||||||
|
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
|
||||||
|
yield CF.waitFor('stackUpdateComplete', describeStackInput).promise();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (((_e = CFState.Stacks) === null || _e === void 0 ? void 0 : _e[0].StackStatus) === 'CREATE_IN_PROGRESS') {
|
core.info('base stack exists and is ready');
|
||||||
yield CF.waitFor('stackCreateComplete', describeStackInput).promise();
|
|
||||||
}
|
|
||||||
else if (((_f = CFState.Stacks) === null || _f === void 0 ? void 0 : _f[0].StackStatus) === 'UPDATE_IN_PROGRESS') {
|
|
||||||
yield CF.waitFor('stackUpdateComplete', describeStackInput).promise();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
handleStackCreationFailure(error, CF, taskDefStackName, taskDefCloudFormation, secrets) {
|
handleStackCreationFailure(error, CF, taskDefStackName, taskDefCloudFormation, secrets) {
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -237,15 +237,11 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||||
const describeStackInput: SDK.CloudFormation.DescribeStacksInput = {
|
const describeStackInput: SDK.CloudFormation.DescribeStacksInput = {
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
};
|
};
|
||||||
let CFState;
|
const stacks = (await CF.listStacks().promise()).StackSummaries?.map((x) => x.StackName);
|
||||||
try {
|
const stackExists: Boolean = stacks?.includes(baseStackName) || false;
|
||||||
CFState = await CF.describeStacks(describeStackInput).promise();
|
|
||||||
} catch {
|
|
||||||
CFState = { Stacks: [] };
|
|
||||||
}
|
|
||||||
const stackExists: Boolean = CFState.Stacks !== null && CFState.Stacks !== [];
|
|
||||||
if (!stackExists) {
|
if (!stackExists) {
|
||||||
core.info('stack exists');
|
core.info('stack does not exist');
|
||||||
await CF.createStack({
|
await CF.createStack({
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
TemplateBody: baseStack,
|
||||||
|
|
@ -255,12 +251,19 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||||
{ ParameterKey: 'Version', ParameterValue: `hash` },
|
{ ParameterKey: 'Version', ParameterValue: `hash` },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
CFState = await CF.describeStacks(describeStackInput).promise();
|
}
|
||||||
} else {
|
const CFState = await CF.describeStacks(describeStackInput).promise();
|
||||||
const stack = CFState.Stacks?.[0];
|
let stack = CFState.Stacks?.[0];
|
||||||
if (!stack) {
|
if (!stack) {
|
||||||
throw new Error('expected base stack to exist');
|
throw new Error(`Base stack doesn't exist, even after creation, stackExists check: ${stackExists}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stack.StackStatus === 'CREATE_IN_PROGRESS') {
|
||||||
|
await CF.waitFor('stackCreateComplete', describeStackInput).promise();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (stackExists) {
|
||||||
|
core.info('stack exists');
|
||||||
if (
|
if (
|
||||||
stack.StackName === baseStackName &&
|
stack.StackName === baseStackName &&
|
||||||
hash !== stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue
|
hash !== stack.Parameters?.find((x) => x.ParameterKey === 'Version')?.ParameterValue
|
||||||
|
|
@ -277,12 +280,17 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||||
)}`,
|
)}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
stack = (await CF.describeStacks(describeStackInput).promise()).Stacks?.[0];
|
||||||
|
if (!stack) {
|
||||||
|
throw new Error(
|
||||||
|
`Base stack doesn't exist, even after updating and creation, stackExists check: ${stackExists}`,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (stack.StackStatus === 'UPDATE_IN_PROGRESS') {
|
||||||
|
await CF.waitFor('stackUpdateComplete', describeStackInput).promise();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (CFState.Stacks?.[0].StackStatus === 'CREATE_IN_PROGRESS') {
|
core.info('base stack exists and is ready');
|
||||||
await CF.waitFor('stackCreateComplete', describeStackInput).promise();
|
|
||||||
} else if (CFState.Stacks?.[0].StackStatus === 'UPDATE_IN_PROGRESS') {
|
|
||||||
await CF.waitFor('stackUpdateComplete', describeStackInput).promise();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleStackCreationFailure(
|
async handleStackCreationFailure(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue