@@ -36,7 +36,7 @@ const getDownloadFileFromRepoCommand = (token: string, org: string, repo: string
|
||||
return `curl -o /tmp/${file} -H 'Authorization: token ${token} ' -H 'Accept: application/vnd.github.v3.raw' -O -L https://api.github.com/repos/${org}/${repo}/contents/${path}`;
|
||||
}
|
||||
|
||||
const getCreateStackCommand = (stackName: string, branch: string, templateFile: string, dockerImage: string, githubToken: string, composerAuth: string, maxmindLicenseKey: string) => {
|
||||
const getCreateStackCommand = (stackName: string, branch: string, templateFile: string, dockerImage: string, githubToken: string, composerAuth: string) => {
|
||||
const stackDomain = stackName.replace('photowall-', '');
|
||||
const cmd = [
|
||||
`aws cloudformation create-stack --stack-name ${stackName}`,
|
||||
@@ -62,7 +62,6 @@ const getCreateStackCommand = (stackName: string, branch: string, templateFile:
|
||||
`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=MaxMindLicenseKey,ParameterValue=${maxmindLicenseKey}`,
|
||||
];
|
||||
|
||||
return cmd.join(' ');
|
||||
@@ -90,17 +89,17 @@ module.exports = {
|
||||
hidden: false,
|
||||
run: async (toolbox: GluegunMenuToolbox) => {
|
||||
const { system, strings, print, filesystem } = toolbox;
|
||||
|
||||
|
||||
// Load settings
|
||||
const config = await getSettings(toolbox);
|
||||
if (!config) {
|
||||
await toolbox.menu.showMenu('setup', defaultMenuSettings);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
const branches = await getRepoBranches(toolbox, config.gh_token, 'Photowall', 'photowall');
|
||||
const branchOptions = branches.map(item => item.name);
|
||||
|
||||
|
||||
const promptBranch = new AutoComplete({
|
||||
name: 'branchName',
|
||||
message: 'Select a branch',
|
||||
@@ -153,7 +152,7 @@ module.exports = {
|
||||
const options = curratedStacks.map(item => {
|
||||
return item.name;
|
||||
});
|
||||
|
||||
|
||||
const input = new Input({
|
||||
type: 'input',
|
||||
name: 'stack',
|
||||
@@ -164,9 +163,9 @@ module.exports = {
|
||||
|
||||
if (options.includes(stackName)) {
|
||||
print.error(`
|
||||
|
||||
|
||||
The stack ${chalk.yellow(stackName)} is already taken, try the update command instead.
|
||||
|
||||
|
||||
`);
|
||||
if (toolbox.fromMenu()) {
|
||||
await toolbox.menu.showMenu('deployment testservers');
|
||||
@@ -181,8 +180,8 @@ module.exports = {
|
||||
await toolbox.menu.showMenu('deployment testservers', defaultMenuSettings);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
try {
|
||||
|
||||
const shouldRun = await getConfirmation(branchName, stackName);
|
||||
@@ -195,7 +194,6 @@ module.exports = {
|
||||
const awsAccountId = strings.trim(await system.run(`aws sts get-caller-identity --query Account --output text`));
|
||||
const awsRegion = strings.trim(await system.run(`aws configure get region`));
|
||||
const githubToken = strings.trim(await system.run(`aws ssm get-parameter --with-decryption --name /github/CODE_PIPELINE_TOKEN --output text --query Parameter.Value`));
|
||||
const maxmindLicenseKey = strings.trim(await system.run(`aws ssm get-parameter --with-decryption --name /maxmind/MAXMIND_LICENSE_KEY --output text --query Parameter.Value`));
|
||||
|
||||
print.fancy(await system.run(`aws ecr create-repository --repository ${stackName}`));
|
||||
print.fancy(await system.run(`aws ecr get-login-password --region ${awsRegion} | docker login --username AWS --password-stdin ${awsAccountId}.dkr.ecr.${awsRegion}.amazonaws.com`));
|
||||
@@ -208,7 +206,7 @@ module.exports = {
|
||||
composerAuthToken = composerAuthToken.replace('\n', '');
|
||||
const composerAuth = `'{\\\"github-oauth\\\":{\\\"github.com\\\":\\\"${composerAuthToken}\\\"}}'`;
|
||||
|
||||
const createCommand = getCreateStackCommand(stackName, branchName, 'file://ecs-service.yaml', dockerImage, githubToken, composerAuth, maxmindLicenseKey);
|
||||
const createCommand = getCreateStackCommand(stackName, branchName, 'file://ecs-service.yaml', dockerImage, githubToken, composerAuth);
|
||||
print.fancy(await system.run(createCommand, {cwd: '/tmp/', trim: true}));
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user