Use base stack name as the environment within aws cloud formations
parent
52ef99fb78
commit
29442b7508
|
|
@ -400,25 +400,25 @@ class AWSBuildEnvironment {
|
|||
});
|
||||
}
|
||||
getParameterTemplate(p1) {
|
||||
return `
|
||||
${p1}:
|
||||
Type: String
|
||||
Default: ''
|
||||
return `
|
||||
${p1}:
|
||||
Type: String
|
||||
Default: ''
|
||||
`;
|
||||
}
|
||||
getSecretTemplate(p1) {
|
||||
return `
|
||||
${p1}Secret:
|
||||
Type: AWS::SecretsManager::Secret
|
||||
Properties:
|
||||
Name: !Join [ "", [ '${p1}', !Ref BUILDID ] ]
|
||||
SecretString: !Ref ${p1}
|
||||
return `
|
||||
${p1}Secret:
|
||||
Type: AWS::SecretsManager::Secret
|
||||
Properties:
|
||||
Name: !Join [ "", [ '${p1}', !Ref BUILDID ] ]
|
||||
SecretString: !Ref ${p1}
|
||||
`;
|
||||
}
|
||||
getSecretDefinitionTemplate(p1, p2) {
|
||||
return `
|
||||
- Name: '${p1}'
|
||||
ValueFrom: !Ref ${p2}Secret
|
||||
return `
|
||||
- Name: '${p1}'
|
||||
ValueFrom: !Ref ${p2}Secret
|
||||
`;
|
||||
}
|
||||
insertAtTemplate(template, insertionKey, insertion) {
|
||||
|
|
@ -429,8 +429,8 @@ class AWSBuildEnvironment {
|
|||
setupCloudFormations(CF, buildGuid, image, entrypoint, commands, mountdir, workingdir, secrets) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const logGuid = nanoid_1.customAlphabet(cloud_runner_constants_1.default.alphabet, 9)();
|
||||
commands[1] += `
|
||||
echo "${logGuid}"
|
||||
commands[1] += `
|
||||
echo "${logGuid}"
|
||||
`;
|
||||
yield this.setupBaseStack(CF);
|
||||
const taskDefStackName = `${this.baseStackName}-${buildGuid}`;
|
||||
|
|
@ -450,7 +450,7 @@ class AWSBuildEnvironment {
|
|||
taskDefCloudFormation = this.insertAtTemplate(taskDefCloudFormation, 'p2 - secret', this.getSecretTemplate(secret.ParameterKey.replace(/[^\dA-Za-z]/g, '')));
|
||||
taskDefCloudFormation = this.insertAtTemplate(taskDefCloudFormation, 'p3 - container def', this.getSecretDefinitionTemplate(secret.EnvironmentVariable, secret.ParameterKey.replace(/[^\dA-Za-z]/g, '')));
|
||||
}
|
||||
const mappedSecrets = secrets.map((x) => {
|
||||
const secretsMappedToCloudFormationParameters = secrets.map((x) => {
|
||||
return { ParameterKey: x.ParameterKey.replace(/[^\dA-Za-z]/g, ''), ParameterValue: x.ParameterValue };
|
||||
});
|
||||
yield CF.createStack({
|
||||
|
|
@ -458,6 +458,10 @@ class AWSBuildEnvironment {
|
|||
TemplateBody: taskDefCloudFormation,
|
||||
Capabilities: ['CAPABILITY_IAM'],
|
||||
Parameters: [
|
||||
{
|
||||
ParameterKey: 'Environment',
|
||||
ParameterValue: this.baseStackName,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'ImageUrl',
|
||||
ParameterValue: image,
|
||||
|
|
@ -486,7 +490,7 @@ class AWSBuildEnvironment {
|
|||
ParameterKey: 'BUILDID',
|
||||
ParameterValue: buildGuid,
|
||||
},
|
||||
...mappedSecrets,
|
||||
...secretsMappedToCloudFormationParameters,
|
||||
],
|
||||
}).promise();
|
||||
core.info('Creating cloud runner job');
|
||||
|
|
@ -547,7 +551,7 @@ class AWSBuildEnvironment {
|
|||
StackName: baseStackName,
|
||||
};
|
||||
const parameters = [
|
||||
{ ParameterKey: 'EnvironmentName', ParameterValue: 'development' },
|
||||
{ ParameterKey: 'EnvironmentName', ParameterValue: baseStackName },
|
||||
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
|
||||
{ ParameterKey: 'Version', ParameterValue: hash },
|
||||
];
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -152,7 +152,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
|||
this.getSecretDefinitionTemplate(secret.EnvironmentVariable, secret.ParameterKey.replace(/[^\dA-Za-z]/g, '')),
|
||||
);
|
||||
}
|
||||
const mappedSecrets = secrets.map((x) => {
|
||||
const secretsMappedToCloudFormationParameters = secrets.map((x) => {
|
||||
return { ParameterKey: x.ParameterKey.replace(/[^\dA-Za-z]/g, ''), ParameterValue: x.ParameterValue };
|
||||
});
|
||||
|
||||
|
|
@ -161,6 +161,10 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
|||
TemplateBody: taskDefCloudFormation,
|
||||
Capabilities: ['CAPABILITY_IAM'],
|
||||
Parameters: [
|
||||
{
|
||||
ParameterKey: 'Environment',
|
||||
ParameterValue: this.baseStackName,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'ImageUrl',
|
||||
ParameterValue: image,
|
||||
|
|
@ -189,7 +193,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
|||
ParameterKey: 'BUILDID',
|
||||
ParameterValue: buildGuid,
|
||||
},
|
||||
...mappedSecrets,
|
||||
...secretsMappedToCloudFormationParameters,
|
||||
],
|
||||
}).promise();
|
||||
core.info('Creating cloud runner job');
|
||||
|
|
@ -256,7 +260,7 @@ class AWSBuildEnvironment implements CloudRunnerProviderInterface {
|
|||
StackName: baseStackName,
|
||||
};
|
||||
const parameters: SDK.CloudFormation.Parameter[] = [
|
||||
{ ParameterKey: 'EnvironmentName', ParameterValue: 'development' },
|
||||
{ ParameterKey: 'EnvironmentName', ParameterValue: baseStackName },
|
||||
{ ParameterKey: 'Storage', ParameterValue: `${baseStackName}-storage` },
|
||||
{ ParameterKey: 'Version', ParameterValue: hash },
|
||||
];
|
||||
|
|
|
|||
Loading…
Reference in New Issue