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

Commit 8087795

Browse files
committed
šŸ› fix(region): prefer default region by default, do not enforce eu-central-1 for cli
1 parent c8b948d commit 8087795

File tree

5 files changed

+16
-13
lines changed

5 files changed

+16
-13
lines changed

Diff for: ā€Žlib/cdk/stack.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,13 @@ export class NextStandaloneStack extends Stack {
9393
hostedZone: this.hostedZone,
9494
dnsPrefix: config.dnsPrefix,
9595
})
96-
}
9796

98-
if (config.redirectFromApex && this.domainName && this.hostedZone) {
99-
this.setupApexRedirect({
100-
sourceHostedZone: this.hostedZone,
101-
targetDomain: this.domainName,
102-
})
97+
if (!!config.redirectFromApex) {
98+
this.setupApexRedirect({
99+
sourceHostedZone: this.hostedZone,
100+
targetDomain: this.domainName,
101+
})
102+
}
103103
}
104104
}
105105

Diff for: ā€Žlib/cdk/utils/cfnDistro.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export interface SetupCfnDistroProps {
2525
customApiOrigin?: IOrigin
2626
}
2727

28-
export const setupCfnDistro = (scope: Stack, { apiGateway, imageBasePath, serverBasePath, assetsBucket, domainName, certificate, customApiOrigin }: SetupCfnDistroProps) => {
28+
export const setupCfnDistro = (
29+
scope: Stack,
30+
{ apiGateway, imageBasePath, serverBasePath, assetsBucket, domainName, certificate, customApiOrigin }: SetupCfnDistroProps,
31+
) => {
2932
const apiGwDomainName = `${apiGateway.apiId}.execute-api.${scope.region}.amazonaws.com`
3033

3134
const serverOrigin = new HttpOrigin(apiGwDomainName, { originPath: serverBasePath })
@@ -69,6 +72,7 @@ export const setupCfnDistro = (scope: Stack, { apiGateway, imageBasePath, server
6972
// Caching is optinionated to work out-of-the-box, for granular access and customization, create your own cache policies.
7073
const cfnDistro = new Distribution(scope, 'CfnDistro', {
7174
defaultRootObject: '',
75+
comment: `CloudFront distribution for ${scope.stackName}`,
7276
enableIpv6: true,
7377
priceClass: PriceClass.PRICE_CLASS_100,
7478
domainNames: domainName ? [domainName] : undefined,

Diff for: ā€Žlib/cli.ts

+2-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { packHandler } from './cli/pack'
88
import { wrapProcess } from './utils'
99
import { DEFAULT_TIMEOUT as IMAGE_LAMBDA_DEFAULT_TIMEOUT, DEFAULT_MEMORY as IMAGE_LAMBDA_DEFAULT_MEMORY } from './cdk/utils/imageLambda'
1010
import { removeHandler } from './cli/remove'
11-
import { DEFAULT_REGION } from './consts'
1211

1312
const commandCwd = process.cwd()
1413
const program = new Command()
@@ -55,7 +54,7 @@ program
5554
.option('--stackName <name>', 'Name of the stack to be deployed.', 'StandaloneNextjsStack-Temporary')
5655
.option('--appPath <path>', 'Absolute path to app.', path.resolve(__dirname, '../dist/cdk/app.js'))
5756
.option('--bootstrap', 'Bootstrap CDK stack.', false)
58-
.option('--region <region>', 'AWS region to deploy to.', DEFAULT_REGION)
57+
.option('--region <region>', 'AWS region to deploy to.', undefined)
5958
.option('--lambdaTimeout <sec>', 'Set timeout for lambda function handling server requests.', Number, 15)
6059
.option('--lambdaMemory <mb>', 'Set memory for lambda function handling server requests.', Number, 512)
6160
.option('--imageLambdaTimeout <sec>', 'Set timeout for lambda function handling image optimization.', Number, IMAGE_LAMBDA_DEFAULT_TIMEOUT)
@@ -104,7 +103,7 @@ program
104103
.description('Remove Next application via CDK')
105104
.option('--stackName <name>', 'Name of the stack to be deployed.', 'StandaloneNextjsStack-Temporary')
106105
.option('--appPath <path>', 'Absolute path to app.', path.resolve(__dirname, '../dist/cdk/app.js'))
107-
.option('--region <region>', 'AWS region to deploy to.', DEFAULT_REGION)
106+
.option('--region <region>', 'AWS region to deploy to.', undefined)
108107
.action(async (options) => {
109108
console.log('Our config is: ', options)
110109
const { stackName, appPath, region } = options

Diff for: ā€Žlib/cli/deploy.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ interface Props {
44
stackName: string
55
appPath: string
66
bootstrap: boolean
7-
region: string
7+
region?: string
88
lambdaMemory?: number
99
lambdaTimeout?: number
1010
imageLambdaMemory?: number

Diff for: ā€Žlib/cli/remove.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { executeAsyncCmd } from '../utils'
33
interface Props {
44
stackName: string
55
appPath: string
6-
region: string
6+
region?: string
77
}
88

99
const cdkExecutable = require.resolve('aws-cdk/bin/cdk')
@@ -14,7 +14,7 @@ export const removeHandler = async ({ appPath, stackName, region }: Props) => {
1414

1515
const variables = {
1616
STACK_NAME: stackName,
17-
AWS_REGION: region,
17+
...(region && { AWS_REGION: region }),
1818
}
1919

2020
await executeAsyncCmd({

0 commit comments

Comments
Ā (0)