setup base stack automatically
parent
a35c029939
commit
ba2931a765
|
|
@ -1022,22 +1022,16 @@ class AWSBuildEnvironment {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
setupBaseStack(CF) {
|
setupBaseStack(CF) {
|
||||||
var _a;
|
var _a, _b, _c;
|
||||||
return __awaiter(this, void 0, void 0, function* () {
|
return __awaiter(this, void 0, void 0, function* () {
|
||||||
let createBaseStack = true;
|
|
||||||
const baseStackName = process.env.baseStackName || 'game-ci-base-stack-01';
|
const baseStackName = process.env.baseStackName || 'game-ci-base-stack-01';
|
||||||
const baseStack = fs.readFileSync(`${__dirname}/cloud-formations/base-setup.yml`, 'utf8');
|
const baseStack = fs.readFileSync(`${__dirname}/cloud-formations/base-setup.yml`, 'utf8');
|
||||||
for (const stack of ((_a = (yield CF.listStacks().promise())) === null || _a === void 0 ? void 0 : _a.StackSummaries) || []) {
|
const describeStackInput = {
|
||||||
if (stack.StackName === baseStackName) {
|
|
||||||
const updateInput = {
|
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
|
||||||
};
|
};
|
||||||
yield CF.updateStack(updateInput).promise();
|
let CFState = yield CF.describeStacks(describeStackInput).promise();
|
||||||
createBaseStack = false;
|
const stackExists = CFState.Stacks === null || CFState.Stacks === [];
|
||||||
}
|
if (stackExists) {
|
||||||
}
|
|
||||||
if (createBaseStack) {
|
|
||||||
yield CF.createStack({
|
yield CF.createStack({
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
TemplateBody: baseStack,
|
||||||
|
|
@ -1046,6 +1040,26 @@ class AWSBuildEnvironment {
|
||||||
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
|
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
CFState = yield CF.describeStacks(describeStackInput).promise();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
const stack = (_a = CFState.Stacks) === null || _a === void 0 ? void 0 : _a[0];
|
||||||
|
if (!stack) {
|
||||||
|
throw new Error('expected base stack to exist');
|
||||||
|
}
|
||||||
|
if (stack.StackName === baseStackName) {
|
||||||
|
const updateInput = {
|
||||||
|
StackName: baseStackName,
|
||||||
|
TemplateBody: baseStack,
|
||||||
|
};
|
||||||
|
yield CF.updateStack(updateInput).promise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (((_b = CFState.Stacks) === null || _b === void 0 ? void 0 : _b[0].StackStatus) === 'CREATE_IN_PROGRESS') {
|
||||||
|
yield CF.waitFor('stackCreateComplete', describeStackInput).promise();
|
||||||
|
}
|
||||||
|
else if (((_c = CFState.Stacks) === null || _c === void 0 ? void 0 : _c[0].StackStatus) === 'UPDATE_IN_PROGRESS') {
|
||||||
|
yield CF.waitFor('stackUpdateComplete', describeStackInput).promise();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -230,20 +230,14 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
async setupBaseStack(CF: SDK.CloudFormation) {
|
async setupBaseStack(CF: SDK.CloudFormation) {
|
||||||
let createBaseStack: Boolean = true;
|
|
||||||
const baseStackName = process.env.baseStackName || 'game-ci-base-stack-01';
|
const baseStackName = process.env.baseStackName || 'game-ci-base-stack-01';
|
||||||
const baseStack = fs.readFileSync(`${__dirname}/cloud-formations/base-setup.yml`, 'utf8');
|
const baseStack = fs.readFileSync(`${__dirname}/cloud-formations/base-setup.yml`, 'utf8');
|
||||||
for (const stack of (await CF.listStacks().promise())?.StackSummaries || []) {
|
const describeStackInput: SDK.CloudFormation.DescribeStacksInput = {
|
||||||
if (stack.StackName === baseStackName) {
|
|
||||||
const updateInput: SDK.CloudFormation.UpdateStackInput = {
|
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
|
||||||
};
|
};
|
||||||
await CF.updateStack(updateInput).promise();
|
let CFState = await CF.describeStacks(describeStackInput).promise();
|
||||||
createBaseStack = false;
|
const stackExists: Boolean = CFState.Stacks === null || CFState.Stacks === [];
|
||||||
}
|
if (stackExists) {
|
||||||
}
|
|
||||||
if (createBaseStack) {
|
|
||||||
await CF.createStack({
|
await CF.createStack({
|
||||||
StackName: baseStackName,
|
StackName: baseStackName,
|
||||||
TemplateBody: baseStack,
|
TemplateBody: baseStack,
|
||||||
|
|
@ -252,9 +246,25 @@ class AWSBuildEnvironment implements RemoteBuilderProviderInterface {
|
||||||
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
|
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
|
||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
CFState = await CF.describeStacks(describeStackInput).promise();
|
||||||
|
} else {
|
||||||
|
const stack = CFState.Stacks?.[0];
|
||||||
|
if (!stack) {
|
||||||
|
throw new Error('expected base stack to exist');
|
||||||
|
}
|
||||||
|
if (stack.StackName === baseStackName) {
|
||||||
|
const updateInput: SDK.CloudFormation.UpdateStackInput = {
|
||||||
|
StackName: baseStackName,
|
||||||
|
TemplateBody: baseStack,
|
||||||
|
};
|
||||||
|
await CF.updateStack(updateInput).promise();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (CFState.Stacks?.[0].StackStatus === 'CREATE_IN_PROGRESS') {
|
||||||
|
await CF.waitFor('stackCreateComplete', describeStackInput).promise();
|
||||||
|
} else if (CFState.Stacks?.[0].StackStatus === 'UPDATE_IN_PROGRESS') {
|
||||||
|
await CF.waitFor('stackUpdateComplete', describeStackInput).promise();
|
||||||
}
|
}
|
||||||
|
|
||||||
// wait for base stack to be finished...
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async handleStackCreationFailure(
|
async handleStackCreationFailure(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue