-
Notifications
You must be signed in to change notification settings - Fork 57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support region
configuration option
#5901
Open
eduardoboucas
wants to merge
6
commits into
main
Choose a base branch
from
feat/region-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
90e11e8
feat: support `region` configuration option
eduardoboucas beb2e23
Merge branch 'main' into feat/region-config
eduardoboucas b2b19ed
Merge branch 'main' into feat/region-config
eduardoboucas 8546f9c
fix: remove regions
eduardoboucas 30be130
fix: remove region
eduardoboucas a41d9f6
Merge branch 'main' into feat/region-config
serhalp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
17 changes: 17 additions & 0 deletions
17
packages/zip-it-and-ship-it/src/runtimes/node/in_source_config/properties/region.ts
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,17 @@ | ||
export const REGIONS = [ | ||
'ap-northeast-1', | ||
'ap-southeast-1', | ||
'ap-southeast-2', | ||
'ca-central-1', | ||
'eu-central-1', | ||
'eu-north-1', | ||
'eu-south-1', | ||
'eu-west-1', | ||
'eu-west-2', | ||
'eu-west-3', | ||
'sa-east-1', | ||
'us-east-1', | ||
'us-east-2', | ||
'us-west-1', | ||
'us-west-2', | ||
] as const |
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
10 changes: 10 additions & 0 deletions
10
packages/zip-it-and-ship-it/tests/fixtures-esm/v2-region/function.js
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,10 @@ | ||
export default async () => | ||
new Response('<h1>Hello world</h1>', { | ||
headers: { | ||
'content-type': 'text/html', | ||
}, | ||
}) | ||
|
||
export const config = { | ||
region: 'eu-west-1', | ||
} |
3 changes: 3 additions & 0 deletions
3
packages/zip-it-and-ship-it/tests/fixtures-esm/v2-region/package.json
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,3 @@ | ||
{ | ||
"type": "module" | ||
} |
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import { describe, expect, test } from 'vitest' | ||
|
||
import { parseSource } from '../../../../src/runtimes/node/in_source_config/index.js' | ||
import { REGIONS } from '../../../../src/runtimes/node/in_source_config/properties/region.js' | ||
import { getLogger } from '../../../../src/utils/logger.js' | ||
|
||
describe('`schedule` helper', () => { | ||
|
@@ -838,4 +839,60 @@ describe('V2 API', () => { | |
runtimeAPIVersion: 2, | ||
}) | ||
}) | ||
|
||
describe('`region` property', () => { | ||
test('With no region', () => { | ||
const source = ` | ||
export default async () => new Response("Hello!") | ||
export const config = {}` | ||
|
||
const isc = parseSource(source, options) | ||
expect(isc).toEqual({ | ||
config: {}, | ||
excludedRoutes: [], | ||
inputModuleFormat: 'esm', | ||
routes: [], | ||
runtimeAPIVersion: 2, | ||
}) | ||
}) | ||
|
||
test('With a supported region', () => { | ||
const source = ` | ||
export default async () => new Response("Hello!") | ||
export const config = { region: 'eu-west-1' }` | ||
|
||
const isc = parseSource(source, options) | ||
expect(isc).toEqual({ | ||
config: { region: 'eu-west-1' }, | ||
excludedRoutes: [], | ||
inputModuleFormat: 'esm', | ||
region: 'eu-west-1', | ||
routes: [], | ||
runtimeAPIVersion: 2, | ||
}) | ||
}) | ||
|
||
test('With an unsupported region', () => { | ||
expect.assertions(4) | ||
|
||
const source = ` | ||
export default async () => new Response("Hello!") | ||
export const config = { region: 'mars-west-1' }` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👽 |
||
|
||
try { | ||
parseSource(source, options) | ||
} catch (error) { | ||
const { customErrorInfo, message } = error | ||
|
||
expect(message).toBe( | ||
`Function func1 has a configuration error on 'region': Must be one of the supported regions (${REGIONS.join( | ||
', ', | ||
)})`, | ||
) | ||
expect(customErrorInfo.type).toBe('functionsBundling') | ||
expect(customErrorInfo.location.functionName).toBe('func1') | ||
expect(customErrorInfo.location.runtime).toBe('js') | ||
} | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does it make sense to include the regions that we don't support in self-serve mode (docs)? The reason we wanted folks to go through Support is to assess whether customers really need these
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, good catch. I copied this list from the UI but didn't realise two of the regions had a boolean set to
false
. I've removed them in 8546f9c.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, there's a third one. Fixed in 30be130.