Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat: add aws nimbus cloud provider (#38312)

Alaister Young0ed15ee3973a
diff --git a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts
index c1e11c59e66..47d4233c511 100644
--- a/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts
+++ b/apps/studio/components/interfaces/ProjectCreation/ProjectCreation.utils.ts
@@ -15,6 +15,7 @@ export function getAvailableRegions(cloudProvider: CloudProvider): Region {
switch (cloudProvider) {
case 'AWS':
case 'AWS_K8S':
+ case 'AWS_NIMBUS':
return AWS_REGIONS
case 'FLY':
return FLY_REGIONS
diff --git a/apps/studio/data/organizations/organization-available-regions-query.ts b/apps/studio/data/organizations/organization-available-regions-query.ts
index 93eed9a4f0e..01bcd9af28f 100644
--- a/apps/studio/data/organizations/organization-available-regions-query.ts
+++ b/apps/studio/data/organizations/organization-available-regions-query.ts
@@ -6,7 +6,7 @@ import { organizationKeys } from './keys'
export type OrganizationAvailableRegionsVariables = {
slug?: string
- cloudProvider: 'AWS' | 'FLY' | 'AWS_K8S'
+ cloudProvider: 'AWS' | 'FLY' | 'AWS_K8S' | 'AWS_NIMBUS'
}
export async function getOrganizationAvailableRegions(
diff --git a/apps/studio/hooks/custom-content/CustomContent.types.ts b/apps/studio/hooks/custom-content/CustomContent.types.ts
index 66816dffa96..28568d054b3 100644
--- a/apps/studio/hooks/custom-content/CustomContent.types.ts
+++ b/apps/studio/hooks/custom-content/CustomContent.types.ts
@@ -1,4 +1,5 @@
-import { ConnectionType } from 'components/interfaces/Connect/Connect.constants'
+import { CONNECTION_TYPES } from 'components/interfaces/Connect/Connect.constants'
+import type { CloudProvider } from 'shared-data'
export type CustomContentTypes = {
organizationLegalDocuments: {
@@ -25,9 +26,7 @@ export type CustomContentTypes = {
*
* These could be helpful in rendering, for e.g an environment file like `.env`
*/
- connectFrameworks: {
- key: string
- label: string
- obj: ConnectionType[]
- }
+ connectFrameworks: (typeof CONNECTION_TYPES)[number]
+
+ infraCloudProviders: CloudProvider[]
}
diff --git a/apps/studio/hooks/custom-content/custom-content.json b/apps/studio/hooks/custom-content/custom-content.json
index 1378a1822a9..57bd6db86b7 100644
--- a/apps/studio/hooks/custom-content/custom-content.json
+++ b/apps/studio/hooks/custom-content/custom-content.json
@@ -7,5 +7,7 @@
"logs:default_query": null,
- "connect:frameworks": null
+ "connect:frameworks": null,
+
+ "infra:cloud_providers": ["AWS", "AWS_K8S", "FLY"]
}
diff --git a/apps/studio/hooks/custom-content/custom-content.sample.json b/apps/studio/hooks/custom-content/custom-content.sample.json
index 7992201514d..da5a880f342 100644
--- a/apps/studio/hooks/custom-content/custom-content.sample.json
+++ b/apps/studio/hooks/custom-content/custom-content.sample.json
@@ -72,5 +72,7 @@
]
}
]
- }
+ },
+
+ "infra:cloud_providers": ["AWS_NIMBUS"]
}
diff --git a/apps/studio/hooks/custom-content/custom-content.schema.json b/apps/studio/hooks/custom-content/custom-content.schema.json
index 6d7020a3447..adea1a5f9fe 100644
--- a/apps/studio/hooks/custom-content/custom-content.schema.json
+++ b/apps/studio/hooks/custom-content/custom-content.schema.json
@@ -72,13 +72,23 @@
}
}
}
+ },
+
+ "infra:cloud_providers": {
+ "type": ["array"],
+ "description": "Filters the valid cloud providers",
+ "items": {
+ "type": "string",
+ "enum": ["AWS", "AWS_K8S", "AWS_NIMBUS", "FLY"]
+ }
}
},
"required": [
"organization:legal_documents",
"project_homepage:example_projects",
"logs:default_query",
- "connect:frameworks"
+ "connect:frameworks",
+ "infra:cloud_providers"
],
"additionalProperties": false
}
diff --git a/apps/studio/hooks/custom-content/useCustomContent.ts b/apps/studio/hooks/custom-content/useCustomContent.ts
index 0d1b2342642..8f26fe1f397 100644
--- a/apps/studio/hooks/custom-content/useCustomContent.ts
+++ b/apps/studio/hooks/custom-content/useCustomContent.ts
@@ -28,16 +28,16 @@ const useCustomContent = <T extends CustomContent[]>(
contents: T
): {
[key in CustomContentToCamelCase<T[number]>]:
- | (typeof customContentStaticObj)[CustomContent]
| CustomContentTypes[CustomContentToCamelCase<T[number]>]
+ | null
} => {
// [Joshen] Running into some TS errors without the `as` here - must be overlooking something super simple
return Object.fromEntries(
contents.map((content) => [contentToCamelCase(content), customContentStaticObj[content]])
) as {
[key in CustomContentToCamelCase<T[number]>]:
- | (typeof customContentStaticObj)[CustomContent]
| CustomContentTypes[CustomContentToCamelCase<T[number]>]
+ | null
}
}
diff --git a/apps/studio/lib/constants/infrastructure.ts b/apps/studio/lib/constants/infrastructure.ts
index 4d2d4ffbf66..d9343193b46 100644
--- a/apps/studio/lib/constants/infrastructure.ts
+++ b/apps/studio/lib/constants/infrastructure.ts
@@ -2,6 +2,7 @@ import type { CloudProvider } from 'shared-data'
import { AWS_REGIONS, FLY_REGIONS } from 'shared-data'
import type { components } from 'data/api'
+import { useCustomContent } from 'hooks/custom-content/useCustomContent'
export const AWS_REGIONS_DEFAULT =
process.env.NEXT_PUBLIC_ENVIRONMENT !== 'prod'
@@ -33,11 +34,21 @@ export const PRICING_TIER_PRODUCT_IDS = {
ENTERPRISE: 'tier_enterprise',
}
-export const DEFAULT_PROVIDER: CloudProvider =
- process.env.NEXT_PUBLIC_ENVIRONMENT &&
- ['staging', 'preview'].includes(process.env.NEXT_PUBLIC_ENVIRONMENT)
- ? 'AWS_K8S'
- : 'AWS'
+export function useDefaultProvider() {
+ const defaultProvider: CloudProvider =
+ process.env.NEXT_PUBLIC_ENVIRONMENT &&
+ ['staging', 'preview'].includes(process.env.NEXT_PUBLIC_ENVIRONMENT)
+ ? 'AWS_K8S'
+ : 'AWS'
+
+ const { infraCloudProviders: validCloudProviders } = useCustomContent(['infra:cloud_providers'])
+
+ if (validCloudProviders?.includes(defaultProvider)) {
+ return defaultProvider
+ }
+
+ return (validCloudProviders?.[0] ?? 'AWS') as CloudProvider
+}
export const PROVIDERS = {
FLY: {
@@ -60,6 +71,12 @@ export const PROVIDERS = {
default_region: AWS_REGIONS_DEFAULT,
regions: { ...AWS_REGIONS },
},
+ AWS_NIMBUS: {
+ id: 'AWS_NIMBUS',
+ name: 'AWS (Nimbus)',
+ default_region: AWS_REGIONS_DEFAULT,
+ regions: { ...AWS_REGIONS },
+ },
} as const
export const PROJECT_STATUS: {
diff --git a/apps/studio/pages/new/[slug].tsx b/apps/studio/pages/new/[slug].tsx
index fc11b85f88a..297dc3d709d 100644
--- a/apps/studio/pages/new/[slug].tsx
+++ b/apps/studio/pages/new/[slug].tsx
@@ -48,6 +48,7 @@ import {
} from 'data/projects/project-create-mutation'
import { useProjectsQuery } from 'data/projects/projects-query'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import { useCustomContent } from 'hooks/custom-content/useCustomContent'
import { useCheckPermissions } from 'hooks/misc/useCheckPermissions'
import { useIsFeatureEnabled } from 'hooks/misc/useIsFeatureEnabled'
import { useLocalStorageQuery } from 'hooks/misc/useLocalStorage'
@@ -57,11 +58,11 @@ import { getCloudProviderArchitecture } from 'lib/cloudprovider-utils'
import {
AWS_REGIONS_DEFAULT,
DEFAULT_MINIMUM_PASSWORD_STRENGTH,
- DEFAULT_PROVIDER,
FLY_REGIONS_DEFAULT,
MANAGED_BY,
PROJECT_STATUS,
PROVIDERS,
+ useDefaultProvider,
} from 'lib/constants'
import passwordStrength from 'lib/password-strength'
import { generateStrongPassword } from 'lib/project'
@@ -141,6 +142,8 @@ const Wizard: NextPageWithLayout = () => {
const showAdvancedConfig = useIsFeatureEnabled('project_creation:show_advanced_config')
+ const { infraCloudProviders: validCloudProviders } = useCustomContent(['infra:cloud_providers'])
+
// This is to make the database.new redirect work correctly. The database.new redirect should be set to supabase.com/dashboard/new/last-visited-org
if (slug === 'last-visited-org') {
if (lastVisitedOrganization) {
@@ -221,9 +224,11 @@ const Wizard: NextPageWithLayout = () => {
project.organization_id === currentOrg?.id && project.status !== PROJECT_STATUS.INACTIVE
) ?? []
+ const defaultProvider = useDefaultProvider()
+
const { data: _defaultRegion, error: defaultRegionError } = useDefaultRegionQuery(
{
- cloudProvider: PROVIDERS[DEFAULT_PROVIDER].id,
+ cloudProvider: PROVIDERS[defaultProvider].id,
},
{
enabled: !smartRegionEnabled,
@@ -239,7 +244,7 @@ const Wizard: NextPageWithLayout = () => {
useOrganizationAvailableRegionsQuery(
{
slug: slug,
- cloudProvider: PROVIDERS[DEFAULT_PROVIDER].id,
+ cloudProvider: PROVIDERS[defaultProvider].id,
},
{
enabled: smartRegionEnabled,
@@ -304,7 +309,7 @@ const Wizard: NextPageWithLayout = () => {
organization: slug,
projectName: projectName || '',
postgresVersion: '',
- cloudProvider: PROVIDERS[DEFAULT_PROVIDER].id,
+ cloudProvider: PROVIDERS[defaultProvider].id,
dbPass: '',
dbPassStrength: 0,
dbRegion: defaultRegion || undefined,
@@ -455,7 +460,7 @@ const Wizard: NextPageWithLayout = () => {
useEffect(() => {
if (regionError) {
- form.setValue('dbRegion', PROVIDERS[DEFAULT_PROVIDER].default_region.displayName)
+ form.setValue('dbRegion', PROVIDERS[defaultProvider].default_region.displayName)
}
}, [regionError])
@@ -707,15 +712,20 @@ const Wizard: NextPageWithLayout = () => {
</FormControl_Shadcn_>
<SelectContent_Shadcn_>
<SelectGroup_Shadcn_>
- {Object.values(PROVIDERS).map((providerObj) => {
- const label = providerObj['name']
- const value = providerObj['id']
- return (
- <SelectItem_Shadcn_ key={value} value={value}>
- {label}
- </SelectItem_Shadcn_>
+ {Object.values(PROVIDERS)
+ .filter(
+ (provider) =>
+ validCloudProviders?.includes(provider.id) ?? true
)
- })}
+ .map((providerObj) => {
+ const label = providerObj['name']
+ const value = providerObj['id']
+ return (
+ <SelectItem_Shadcn_ key={value} value={value}>
+ {label}
+ </SelectItem_Shadcn_>
+ )
+ })}
</SelectGroup_Shadcn_>
</SelectContent_Shadcn_>
</Select_Shadcn_>
diff --git a/packages/shared-data/regions.ts b/packages/shared-data/regions.ts
index 27caf5b2659..d38d8db339d 100644
--- a/packages/shared-data/regions.ts
+++ b/packages/shared-data/regions.ts
@@ -1,4 +1,4 @@
-export type CloudProvider = 'FLY' | 'AWS' | 'AWS_K8S'
+export type CloudProvider = 'FLY' | 'AWS' | 'AWS_K8S' | 'AWS_NIMBUS'
export type Region = typeof AWS_REGIONS | typeof FLY_REGIONS
export const AWS_REGIONS = {