insert secrets dynamically, expect uniqueness to fail

pull/263/head
Frostebite 2021-05-02 02:28:58 +01:00
parent 97d1a5bb54
commit d4099caeff
3 changed files with 71 additions and 63 deletions

18
dist/index.js vendored
View File

@ -478,14 +478,16 @@ class AWS {
`;
const taskDefStackName = `${stackName}-${buildUid}`;
let taskDefCloudFormation = fs.readFileSync(`${__dirname}/cloud-formations/task-def-formation.yml`, 'utf8');
for (const secret of secrets) {
const p1string = 'p1 - input';
const p2string = 'p2 - secret';
const p3string = 'p3 - container def';
const indexp1 = taskDefCloudFormation.search(p1string) + p1string.length + '\n'.length;
const template1 = `
AWSSecretAccessKeyssss:
${secret.ParameterKey}:
Type: String
Default: '0'`;
Default: ''
`;
taskDefCloudFormation = [
taskDefCloudFormation.slice(0, indexp1),
template1,
@ -493,11 +495,12 @@ class AWS {
].join('');
const indexp2 = taskDefCloudFormation.search(p2string) + p2string.length + '\n'.length;
const template2 = `
TestSec:
${secret.ParameterKey}Secret:
Type: AWS::SecretsManager::Secret
Properties:
Name: !Join [ "", [ 'testsec', !Ref BUILDID ] ]
SecretString: !Ref AWSSecretAccessKey`;
Name: !Join [ "", [ '${secret.ParameterKey}', !Ref BUILDID ] ]
SecretString: !Ref ${secret.ParameterKey}
`;
taskDefCloudFormation = [
taskDefCloudFormation.slice(0, indexp2),
template2,
@ -505,13 +508,14 @@ class AWS {
].join('');
const indexp3 = taskDefCloudFormation.search(p3string) + p3string.length + '\n'.length;
const template3 = `
- Name: 'test'
ValueFrom: !Ref GithubTokenSecret`;
- Name: '${secret.ParameterKey.toUpperCase()}'
ValueFrom: !Ref ${secret.ParameterKey}Secret`;
taskDefCloudFormation = [
taskDefCloudFormation.slice(0, indexp3),
template3,
taskDefCloudFormation.slice(indexp3),
].join('');
}
core.info(taskDefCloudFormation);
yield CF.createStack({
StackName: taskDefStackName,

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -333,14 +333,16 @@ class AWS {
`;
const taskDefStackName = `${stackName}-${buildUid}`;
let taskDefCloudFormation = fs.readFileSync(`${__dirname}/cloud-formations/task-def-formation.yml`, 'utf8');
for (const secret of secrets) {
const p1string = 'p1 - input';
const p2string = 'p2 - secret';
const p3string = 'p3 - container def';
const indexp1 = taskDefCloudFormation.search(p1string) + p1string.length + '\n'.length;
const template1 = `
AWSSecretAccessKeyssss:
${secret.ParameterKey}:
Type: String
Default: '0'`;
Default: ''
`;
taskDefCloudFormation = [
taskDefCloudFormation.slice(0, indexp1),
template1,
@ -348,11 +350,12 @@ class AWS {
].join('');
const indexp2 = taskDefCloudFormation.search(p2string) + p2string.length + '\n'.length;
const template2 = `
TestSec:
${secret.ParameterKey}Secret:
Type: AWS::SecretsManager::Secret
Properties:
Name: !Join [ "", [ 'testsec', !Ref BUILDID ] ]
SecretString: !Ref AWSSecretAccessKey`;
Name: !Join [ "", [ '${secret.ParameterKey}', !Ref BUILDID ] ]
SecretString: !Ref ${secret.ParameterKey}
`;
taskDefCloudFormation = [
taskDefCloudFormation.slice(0, indexp2),
template2,
@ -360,13 +363,14 @@ class AWS {
].join('');
const indexp3 = taskDefCloudFormation.search(p3string) + p3string.length + '\n'.length;
const template3 = `
- Name: 'test'
ValueFrom: !Ref GithubTokenSecret`;
- Name: '${secret.ParameterKey.toUpperCase()}'
ValueFrom: !Ref ${secret.ParameterKey}Secret`;
taskDefCloudFormation = [
taskDefCloudFormation.slice(0, indexp3),
template3,
taskDefCloudFormation.slice(indexp3),
].join('');
}
core.info(taskDefCloudFormation);