-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c38ec2c
commit 16a5396
Showing
7 changed files
with
111 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Command } from '@oclif/core'; | ||
import { color } from '@oclif/color'; | ||
|
||
import { initConfig } from '../../config/init'; | ||
import { assertDockerIsRunning } from '../../lib/docker'; | ||
import { runSecretsEditor } from '../../lib/secretsEditor'; | ||
|
||
export default class BackendSecrets extends Command { | ||
static description = | ||
'Runs an ssm-editor helper tool in docker container to set runtime environmental variables of backend service. ' + | ||
'Underneath it uses chamber to both fetch and set those variables in AWS SSM Parameter Store'; | ||
|
||
static examples = [`$ <%= config.bin %> <%= command.id %>`]; | ||
|
||
async run(): Promise<void> { | ||
const { envStage, awsAccountId, awsRegion } = await initConfig(this, { | ||
requireAws: true, | ||
}); | ||
await assertDockerIsRunning(); | ||
|
||
this.log(`Settings secrets in AWS SSM Parameter store for: | ||
service: ${color.green('backend')} | ||
envStage: ${color.green(envStage)} | ||
AWS account: ${color.green(awsAccountId)} | ||
AWS region: ${color.green(awsRegion)} | ||
`); | ||
|
||
await runSecretsEditor({ serviceName: 'backend' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Command } from '@oclif/core'; | ||
import { color } from '@oclif/color'; | ||
|
||
import { initConfig } from '../../config/init'; | ||
import { assertDockerIsRunning } from '../../lib/docker'; | ||
import { runSecretsEditor } from '../../lib/secretsEditor'; | ||
|
||
export default class WebappSecrets extends Command { | ||
static description = | ||
'Runs an ssm-editor helper tool in docker container to set runtime environmental variables of webapp service. ' + | ||
'Underneath it uses chamber to both fetch and set those variables in AWS SSM Parameter Store'; | ||
|
||
static examples = [`$ <%= config.bin %> <%= command.id %>`]; | ||
|
||
async run(): Promise<void> { | ||
const { envStage, awsAccountId, awsRegion } = await initConfig(this, { | ||
requireAws: true, | ||
}); | ||
await assertDockerIsRunning(); | ||
|
||
this.log(`Settings secrets in AWS SSM Parameter store for: | ||
service: ${color.green('webapp')} | ||
envStage: ${color.green(envStage)} | ||
AWS account: ${color.green(awsAccountId)} | ||
AWS region: ${color.green(awsRegion)} | ||
`); | ||
|
||
await runSecretsEditor({ serviceName: 'webapp' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Command } from '@oclif/core'; | ||
import { color } from '@oclif/color'; | ||
|
||
import { initConfig } from '../../config/init'; | ||
import { assertDockerIsRunning } from '../../lib/docker'; | ||
import { runSecretsEditor } from '../../lib/secretsEditor'; | ||
|
||
export default class WebappSecrets extends Command { | ||
static description = | ||
'Runs an ssm-editor helper tool in docker container to set runtime environmental variables of workers service. ' + | ||
'Underneath it uses chamber to both fetch and set those variables in AWS SSM Parameter Store'; | ||
|
||
static examples = [`$ <%= config.bin %> <%= command.id %>`]; | ||
|
||
async run(): Promise<void> { | ||
const { envStage, awsAccountId, awsRegion } = await initConfig(this, { | ||
requireAws: true, | ||
}); | ||
await assertDockerIsRunning(); | ||
|
||
this.log(`Settings secrets in AWS SSM Parameter store for: | ||
service: ${color.green('workers')} | ||
envStage: ${color.green(envStage)} | ||
AWS account: ${color.green(awsAccountId)} | ||
AWS region: ${color.green(awsRegion)} | ||
`); | ||
|
||
await runSecretsEditor({ serviceName: 'workers' }); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { runCommand } from './runCommand'; | ||
|
||
type RunSecretsEditorOptions = { | ||
serviceName: string; | ||
}; | ||
|
||
export const runSecretsEditor = async ({ | ||
serviceName, | ||
}: RunSecretsEditorOptions) => { | ||
await runCommand('pnpm', ['nx', 'run', 'ssm-editor:compose-build-image']); | ||
await runCommand('docker', [ | ||
'compose', | ||
'run', | ||
'--rm', | ||
'-entrypoint /bin/bash', | ||
'ssm-editor', | ||
`/scripts/run.sh`, | ||
serviceName, | ||
]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,3 @@ build: | |
|
||
deploy: | ||
pnpm nx deploy | ||
|
||
secrets: | ||
$(MAKE) -C $(PROJECT_ROOT_DIR) secrets-editor SERVICE_NAME=webapp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters