Skip to content

Commit

Permalink
separate s3 region from lightsail region
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy Razon committed Nov 13, 2023
1 parent 543ff78 commit 2c4b990
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 6 deletions.
8 changes: 5 additions & 3 deletions packages/cli/src/fs.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { fsTypeFromUrl, localFsFromUrl } from '@preevy/core'
import { googleCloudStorageFs, defaultBucketName as gsDefaultBucketName, defaultProjectId as defaultGceProjectId } from '@preevy/driver-gce'
import { s3fs, defaultBucketName as s3DefaultBucketName, AWS_REGIONS, awsUtils } from '@preevy/driver-lightsail'
import { s3fs, defaultBucketName as s3DefaultBucketName, awsUtils, S3_REGIONS } from '@preevy/driver-lightsail'
import inquirer from 'inquirer'
import inquirerAutoComplete from 'inquirer-autocomplete-prompt'
import { DriverName } from './drivers'
Expand Down Expand Up @@ -63,8 +63,10 @@ export const chooseFs: Record<FsType, FsChooser> = {
type: 'autocomplete',
name: 'region',
message: 'S3 bucket region',
source: async (_opts, input) => AWS_REGIONS.filter(r => !input || r.includes(input.toLowerCase())),
default: driver?.name === 'lightsail' ? driver.flags.region as string : 'us-east-1',
source: async (_opts, input) => S3_REGIONS.filter(r => !input || r.includes(input.toLowerCase())),
default: driver?.name === 'lightsail' && S3_REGIONS.includes(driver.flags.region as string)
? driver.flags.region as string
: 'us-east-1',
suggestOnly: true,
filter: i => i.toLowerCase(),
} as inquirerAutoComplete.AutocompleteQuestionOptions,
Expand Down
1 change: 0 additions & 1 deletion packages/driver-lightsail/src/driver/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ export const REGIONS = [
'eu-west-2',
'eu-west-3',
'eu-north-1',
'il-central-1',
] as const

const getFirstAvailabilityZoneForRegion = async (ls: Lightsail) => {
Expand Down
35 changes: 35 additions & 0 deletions packages/driver-lightsail/src/fs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,38 @@ export const s3fs = async (s3Url: string): Promise<VirtualFS> => {
},
}
}

export const S3_REGIONS = [
'us-east-2',
'us-east-1',
'us-west-1',
'us-west-2',
'af-south-1',
'ap-east-1',
'ap-south-2',
'ap-southeast-3',
'ap-southeast-4',
'ap-south-1',
'ap-northeast-3',
'ap-northeast-2',
'ap-southeast-1',
'ap-southeast-2',
'ap-northeast-1',
'ca-central-1',
'cn-north-1',
'cn-northwest-1',
'eu-central-1',
'eu-west-1',
'eu-west-2',
'eu-south-1',
'eu-west-3',
'eu-north-1',
'eu-south-2',
'eu-central-2',
'me-south-1',
'me-central-1',
'il-central-1',
'sa-east-1',
'us-gov-east-1',
'us-gov-west-1',
]
4 changes: 2 additions & 2 deletions packages/driver-lightsail/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ import lightsail from './driver'

export default lightsail
export * as awsUtils from './aws-utils'
export { REGIONS as AWS_REGIONS } from './driver/client'
export { s3fs, defaultBucketName } from './fs'
export { REGIONS as LIGHTSAIL_REGIONS } from './driver/client'
export { s3fs, defaultBucketName, S3_REGIONS } from './fs'

0 comments on commit 2c4b990

Please sign in to comment.