Skip to content
This repository was archived by the owner on Feb 1, 2025. It is now read-only.

Commit 216d371

Browse files
boundssladg
authored andcommitted
allow specifying aws profile
1 parent 9a72074 commit 216d371

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

Diff for: lib/cli.ts

+6-2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ program
6464
.option('--domainNamePrefix <prefix>', 'Prefix for creating DNS records, if left undefined, hostedZone will be used (example: app).', undefined)
6565
.option('--customApiDomain <domain>', 'Domain to forward the requests to /api routes, by default API routes will be handled by the server lambda.', undefined)
6666
.option('--redirectFromApex', 'Redirect from apex domain to specified address.', false)
67+
.option('--profile <name>', 'AWS profile to use with CDK', undefined)
6768
.action(async (options) => {
6869
console.log('Our config is: ', options)
6970
const {
@@ -80,6 +81,7 @@ program
8081
domainNamePrefix,
8182
customApiDomain,
8283
redirectFromApex,
84+
profile,
8385
} = options
8486

8587
wrapProcess(
@@ -97,6 +99,7 @@ program
9799
domainNamePrefix,
98100
customApiDomain,
99101
redirectFromApex,
102+
profile,
100103
}),
101104
)
102105
})
@@ -107,11 +110,12 @@ program
107110
.option('--stackName <name>', 'Name of the stack to be deployed.', 'StandaloneNextjsStack-Temporary')
108111
.option('--appPath <path>', 'Absolute path to app.', path.resolve(__dirname, '../dist/cdk/app.js'))
109112
.option('--region <region>', 'AWS region to deploy to.', undefined)
113+
.option('--profile <name>', 'AWS profile to use with CDK', undefined)
110114
.action(async (options) => {
111115
console.log('Our config is: ', options)
112-
const { stackName, appPath, region } = options
116+
const { stackName, appPath, region, profile } = options
113117

114-
wrapProcess(removeHandler({ stackName, appPath, region }))
118+
wrapProcess(removeHandler({ stackName, appPath, region, profile }))
115119
})
116120

117121
program.parse(process.argv)

Diff for: lib/cli/deploy.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ interface Props {
1414
hostedZone?: string
1515
domainNamePrefix?: string
1616
redirectFromApex?: boolean
17+
profile?: string
1718
}
1819

1920
const cdkExecutable = require.resolve('aws-cdk/bin/cdk')
@@ -32,10 +33,11 @@ export const deployHandler = async ({
3233
hostedZone,
3334
customApiDomain,
3435
redirectFromApex,
36+
profile,
3537
}: Props) => {
3638
// All paths are absolute.
3739
const cdkApp = `node ${appPath}`
38-
const cdkCiFlags = `--require-approval never --ci --hotswap`
40+
const cdkCiFlags = `--require-approval never --ci --hotswap` + profile ? `--profile ${profile}` : ``
3941

4042
const variables = {
4143
STACK_NAME: stackName,

Diff for: lib/cli/remove.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,14 @@ interface Props {
44
stackName: string
55
appPath: string
66
region?: string
7+
profile?: string
78
}
89

910
const cdkExecutable = require.resolve('aws-cdk/bin/cdk')
1011

11-
export const removeHandler = async ({ appPath, stackName, region }: Props) => {
12+
export const removeHandler = async ({ appPath, stackName, region, profile }: Props) => {
1213
const cdkApp = `node ${appPath}`
13-
const cdkCiFlags = `--force --ci`
14+
const cdkCiFlags = `--force --ci` + profile ? `--profile ${profile}` : ``
1415

1516
const variables = {
1617
STACK_NAME: stackName,

0 commit comments

Comments
 (0)