Add maxmind license key (#12)

* Add MaxMindLicenseKey

* fix lint errors

* fix update
This commit is contained in:
Anders Gustafsson
2022-11-15 14:12:08 +01:00
committed by GitHub
parent 42a3109441
commit 02beda5a40
3 changed files with 31 additions and 26 deletions
@@ -39,7 +39,7 @@ const getLifeCyclePolicyCommand = (stackName: string, policyFile: string) => {
return `aws ecr put-lifecycle-policy --repository-name ${stackName} --lifecycle-policy-text "${policyFile}"`;
}
const getUpdateStackCommand = (stackName: string, branch: string, templateFile: string) => {
const getUpdateStackCommand = (stackName: string, branch: string, templateFile: string, maxmindLicenseKey: string) => {
const cmd = [
`aws cloudformation update-stack --stack-name ${stackName}`,
`--template-body ${templateFile}`,
@@ -63,7 +63,8 @@ const getUpdateStackCommand = (stackName: string, branch: string, templateFile:
`ParameterKey=StaticCdnHostName,ParameterValue=${STACK_DEFAULTS.STATIC_CDN_HOSTNAME}`,
`ParameterKey=StaticCdnCertificateArn,ParameterValue=${STACK_DEFAULTS.STATIC_CDN_CERTIFICATE_ARN}`,
`ParameterKey=AwsAccessKeyParamNameEnvironment,ParameterValue=${STACK_DEFAULTS.AWS_KEY_ENVIRONMENT}`,
`ParameterKey=DatabaseSecurityGroup,ParameterValue=${STACK_DEFAULTS.DB_SECURITY_GROUP_ID}`
`ParameterKey=DatabaseSecurityGroup,ParameterValue=${STACK_DEFAULTS.DB_SECURITY_GROUP_ID}`,
`ParameterKey=MaxMindLicenseKey,ParameterValue=${maxmindLicenseKey}`,
];
return cmd.join(' ');
}
@@ -118,7 +119,7 @@ module.exports = {
hidden: false,
run: async (toolbox: GluegunMenuToolbox) => {
const { system, strings, print } = toolbox;
// Load settings
const config = await getSettings(toolbox);
if (!config) {
@@ -174,7 +175,7 @@ module.exports = {
const options = curratedStacks.map(item => {
return item.name;
});
const prompt = new AutoComplete({
name: 'testserver',
message: 'Choose a server',
@@ -190,16 +191,18 @@ module.exports = {
await system.run(getDownloadFileFromRepoCommand(config.gh_token, 'Photowall', 'photowall', 'cloudformation/ecs-service.yaml'));
const stackName = await prompt.run();
const maxmindLicenseKey = strings.trim(await system.run(`aws ssm get-parameter --with-decryption --name /maxmind/MAXMIND_LICENSE_KEY --output text --query Parameter.Value`));
const lifeCycleCommand = getLifeCyclePolicyCommand(stackName, `file://ecr-lifecycle-policy.json`);
const updateStackCommand = getUpdateStackCommand(stackName, branchName, `file://ecs-service.yaml`);
const updateStackCommand = getUpdateStackCommand(stackName, branchName, `file://ecs-service.yaml`, maxmindLicenseKey);
const shouldRun = await getConfirmation(branchName, stackName);
if (shouldRun) {
let output = await system.run(lifeCycleCommand, {cwd: '/tmp/', trim: true});
print.fancy(output);
output = await system.run(updateStackCommand, {cwd: '/tmp/', trim: true});
output = await system.run(updateStackCommand, {cwd: '/tmp/', trim: true});
print.fancy(output);
}