Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(redshift-batch-export): Support integrations in frontend (#89990)

Tomás Farías Santanaa84f0fee94ad
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 1884988a0136..159dc00ae8bf 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6101,9 +6101,9 @@ snapshots:
scenes-app-batchexports--new-postgres-export--light:
hash: v1.k794b7964.a91e98e99f18feaab3e35cc74c61e587a93f0d5145dbb0ffe87cba47753e2b69.xH4R5lW0I6Jc6kaJhwrBbmt3aAm7WBxGgI233qSOQ5s
scenes-app-batchexports--new-redshift-export--dark:
- hash: v1.k794b7964.8f0388fbdd4a8d00212684d736e614f2344aad1cfe39367f3b816b20dd763c15.YHxV-ye4sDuyCfkAEScg1Cu1fJNySEqpEd9vHiCqEA4
+ hash: v1.k794b7964.ca943cf5b531f67d25f8d2ece7746ed6768af501d10aa71082bd0c4bf38ad13e.C2HPb5m5ZJdSu-GNI75wMkuiEiaEOtHxfQmzUbRrySs
scenes-app-batchexports--new-redshift-export--light:
- hash: v1.k794b7964.fa2185c87dad9181ffdec1888102174d0ec3acc2a11411ef597177a9d0d570b1.2wW_Q7snJas3pAN8GKb0XGnS2QMeI_CUZkMwiQ7Wkuc
+ hash: v1.k794b7964.1d608dd053858bb0b55ad2048d476c5ce19448758185e277352a4b81d42a20d4.qEj-MdakedhK-9bGnAOS7P2dpCESdvDrHyi80qbRt_A
scenes-app-batchexports--new-s-3-compatible-export--dark:
hash: v1.k794b7964.64732abe9af577a8d94f717698373476218db08db3d62f1fc2c37dc52db29a01.6KvN-kOY6LRFnyCA59HvtJ1_vM-3c6wt-X42C4w5fP4
scenes-app-batchexports--new-s-3-compatible-export--light:
diff --git a/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.test.tsx b/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.test.tsx
index e70cc39b1845..65c331c077be 100644
--- a/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.test.tsx
+++ b/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.test.tsx
@@ -1,6 +1,6 @@
import '@testing-library/jest-dom'
-import { cleanup, render, screen, waitFor } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import { Provider } from 'kea'
import { useMocks } from '~/mocks/jest'
@@ -25,6 +25,20 @@ describe('IntegrationChoice', () => {
get: {
'/api/environments/:team_id/integrations': () => [200, { results: [GITHUB_INTEGRATION] }],
},
+ post: {
+ '/api/environments/:team_id/integrations': () => [
+ 200,
+ {
+ id: 42,
+ kind: 'aws-s3',
+ display_name: 'Test connection',
+ icon_url: '',
+ config: {},
+ created_by: null,
+ created_at: '2026-01-01T00:00:00Z',
+ },
+ ],
+ },
})
initKeaTests()
})
@@ -75,6 +89,43 @@ describe('IntegrationChoice', () => {
expect(onChange).toHaveBeenCalledTimes(1)
})
+ it('routes a new connection to the picker that opened the modal, not a same-kind sibling', async () => {
+ // A Redshift COPY export renders two aws-s3 pickers that share one unkeyed setup-modal
+ // logic. Completing the modal opened from the first picker must call the first picker's
+ // onChange — not the last-rendered sibling's, which would drop the new id into the wrong
+ // field and fail the backend kind check on save.
+ const onChangeFirst = jest.fn()
+ const onChangeSecond = jest.fn()
+ render(
+ <Provider>
+ <div data-attr="picker-first">
+ <IntegrationChoice integration="aws-s3" onChange={onChangeFirst} />
+ </div>
+ <div data-attr="picker-second">
+ <IntegrationChoice integration="aws-s3" onChange={onChangeSecond} />
+ </div>
+ </Provider>
+ )
+
+ const firstTrigger = await within(screen.getByTestId('picker-first')).findByText('Choose AWS S3 connection')
+ fireEvent.click(firstTrigger)
+ fireEvent.click(await screen.findByText('Configure new AWS S3 connection'))
+
+ // Fill the minimal valid form (default 'Assume IAM role' mode) and save.
+ fireEvent.change(await screen.findByPlaceholderText('e.g. Production data lake'), {
+ target: { value: 'Test connection' },
+ })
+ fireEvent.change(screen.getByPlaceholderText(/arn:aws:iam/), {
+ target: { value: 'arn:aws:iam::123456789012:role/posthog' },
+ })
+ fireEvent.click(screen.getByText('Save'))
+
+ await waitFor(() => {
+ expect(onChangeFirst).toHaveBeenCalledWith(42)
+ })
+ expect(onChangeSecond).not.toHaveBeenCalled()
+ })
+
it('still warns when the stored id matches no integration', async () => {
// Regression guard: a genuinely dangling reference must keep surfacing the banner.
render(
diff --git a/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.tsx b/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.tsx
index 93e3eaa55150..880becd83f2b 100644
--- a/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.tsx
+++ b/frontend/src/lib/components/CyclotronJob/integrations/IntegrationChoice.tsx
@@ -2,7 +2,7 @@
import './integrationSetups'
import { useActions, useValues } from 'kea'
-import { useEffect, useRef } from 'react'
+import { useEffect, useId, useRef } from 'react'
import { IconExternal, IconTrash, IconX } from '@posthog/icons'
import { LemonBanner, LemonButton, LemonMenu, LemonSkeleton } from '@posthog/lemon-ui'
@@ -15,7 +15,7 @@ import { eventUsageLogic } from 'lib/utils/eventUsageLogic'
import { urls } from 'scenes/urls'
import { findIntegrationByFormValue, matchesIntegrationIdValue } from './integrationLookup'
-import { getAllRegisteredIntegrationSetups, getIntegrationSetup } from './integrationSetupRegistry'
+import { getIntegrationSetup } from './integrationSetupRegistry'
export type IntegrationConfigureProps = {
value?: number
@@ -36,12 +36,18 @@ export function IntegrationChoice({
beforeRedirect,
allowClear = true,
}: IntegrationConfigureProps): JSX.Element | null {
- const { integrationsLoading, integrations, newIntegrationModalKind, slackAvailable } = useValues(integrationsLogic)
+ const { integrationsLoading, integrations, newIntegrationModalKind, newIntegrationModalId, slackAvailable } =
+ useValues(integrationsLogic)
const { newGoogleCloudKey, openNewIntegrationModal, closeNewIntegrationModal, deleteIntegration } =
useActions(integrationsLogic)
const { reportIntegrationConnectClicked } = useActions(eventUsageLogic)
const kind = integration
+ // Identifies this specific picker. Several IntegrationChoice pickers can share a kind (a
+ // Redshift export has separate aws-s3 fields for the bucket and the authorization), so the
+ // shared modal open-state is matched on this id to route completion back to the right picker.
+ const modalId = useId()
+
const integrationsOfKind = integrations?.filter((x) => x.kind === kind)
const integrationKind = findIntegrationByFormValue(integrationsOfKind, value)
@@ -94,11 +100,12 @@ export function IntegrationChoice({
}
const setupDef = getIntegrationSetup(kind)
+ const SetupModalComponent = setupDef?.SetupModal
// When the instance doesn't have OAuth credentials for this kind, /integrations/authorize
// 400s with "Kind not configured". Send users to the settings page instead.
const oauthUnavailable = kind === 'slack' && !slackAvailable
const setupMenuItem = setupDef
- ? setupDef.menuItem({ kind, openModal: openNewIntegrationModal, uploadKey })
+ ? setupDef.menuItem({ kind, openModal: (modalKind) => openNewIntegrationModal(modalKind, modalId), uploadKey })
: oauthUnavailable
? {
to: urls.settings('project-integrations'),
@@ -193,22 +200,19 @@ export function IntegrationChoice({
button
)}
- {getAllRegisteredIntegrationSetups()
- .filter((def) => def.SetupModal)
- .map((def) => {
- const modalKind = Array.isArray(def.kind) ? def.kind[0] : def.kind
- const SetupModalComponent = def.SetupModal!
- return (
- <SetupModalComponent
- key={modalKind}
- isOpen={newIntegrationModalKind === modalKind}
- kind={modalKind}
- integration={integrationKind || undefined}
- onComplete={handleModalComplete}
- onClose={closeNewIntegrationModal}
- />
- )
- })}
+ {/* Render only this picker's own-kind modal, and only while this picker is the opener.
+ Sibling pickers can share a kind, and the setup-modal logics are singletons —
+ mounting more than one lets a submit's onComplete resolve to the last-rendered
+ picker and write the new id into the wrong field. */}
+ {SetupModalComponent && newIntegrationModalKind === kind && newIntegrationModalId === modalId ? (
+ <SetupModalComponent
+ isOpen
+ kind={kind}
+ integration={integrationKind || undefined}
+ onComplete={handleModalComplete}
+ onClose={closeNewIntegrationModal}
+ />
+ ) : null}
</>
)
}
diff --git a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx
index f511d52a59c8..d777ef547c70 100644
--- a/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx
+++ b/frontend/src/lib/components/CyclotronJob/integrations/integrationSetups.tsx
@@ -4,6 +4,7 @@ import { DatabricksSetupModal } from 'scenes/integrations/databricks/DatabricksS
import { GitLabSetupModal } from 'scenes/integrations/gitlab/GitLabSetupModal'
import { GoogleCloudServiceAccountSetupModal } from 'scenes/integrations/google-cloud-service-account/GoogleCloudServiceAccountSetupModal'
import { PostgreSQLSetupModal } from 'scenes/integrations/postgresql/PostgreSQLSetupModal'
+import { RedshiftSetupModal } from 'scenes/integrations/redshift/RedshiftSetupModal'
import { S3CompatibleSetupModal } from 'scenes/integrations/s3-compatible/S3CompatibleSetupModal'
import { SnowflakeSetupModal } from 'scenes/integrations/snowflake/SnowflakeSetupModal'
import { urls } from 'scenes/urls'
@@ -112,6 +113,17 @@ registerIntegrationSetup({
),
})
+registerIntegrationSetup({
+ kind: 'aws-redshift',
+ menuItem: ({ openModal }) => ({
+ label: 'Configure new Redshift connection',
+ onClick: () => openModal('aws-redshift'),
+ }),
+ SetupModal: ({ isOpen, integration, onComplete }) => (
+ <RedshiftSetupModal isOpen={isOpen} integration={integration} onComplete={onComplete} />
+ ),
+})
+
registerIntegrationSetup({
kind: 's3-compatible',
menuItem: ({ openModal }) => ({
diff --git a/frontend/src/lib/integrations/integrationsLogic.ts b/frontend/src/lib/integrations/integrationsLogic.ts
index 7e3e4c322b0d..74658e420abc 100644
--- a/frontend/src/lib/integrations/integrationsLogic.ts
+++ b/frontend/src/lib/integrations/integrationsLogic.ts
@@ -57,6 +57,7 @@ export interface integrationsLogicValues {
getIntegrationsByKind: (
kinds: (
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -112,6 +113,7 @@ export interface integrationsLogicValues {
integrationsLoading: boolean
linkedGithubInstallation: IntegrationType | null
linkedGithubInstallationLoading: boolean
+ newIntegrationModalId: string | null
newIntegrationModalKind: IntegrationKind | null
pollingSubscribers: number
requestedAccessKinds: IntegrationKind[]
@@ -142,6 +144,7 @@ export interface integrationsLogicActions {
) => {
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -261,6 +264,7 @@ export interface integrationsLogicActions {
installation_status?: InstallationStatusEnumApi | null | undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -318,6 +322,7 @@ export interface integrationsLogicActions {
installation_status?: InstallationStatusEnumApi | null | undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -392,6 +397,7 @@ export interface integrationsLogicActions {
installation_status?: InstallationStatusEnumApi | null | undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -453,6 +459,7 @@ export interface integrationsLogicActions {
installation_status?: InstallationStatusEnumApi | null | undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -501,9 +508,14 @@ export interface integrationsLogicActions {
kind: string
}
}
- openNewIntegrationModal: (kind: IntegrationKind) => {
+ openNewIntegrationModal: (
+ kind: IntegrationKind,
+ id: string
+ ) => {
+ id: string
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -566,6 +578,7 @@ export interface integrationsLogicActions {
requestIntegrationAccessSuccess: (
accessRequest:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -613,6 +626,7 @@ export interface integrationsLogicActions {
) => {
accessRequest:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -685,6 +699,7 @@ export interface integrationsLogicMeta {
) => (
kinds: (
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -764,7 +779,7 @@ export const integrationsLogic = kea<integrationsLogicType>([
callback,
}),
deleteIntegration: (id: number) => ({ id }),
- openNewIntegrationModal: (kind: IntegrationKind) => ({ kind }),
+ openNewIntegrationModal: (kind: IntegrationKind, id: string) => ({ kind, id }),
closeNewIntegrationModal: true,
openSetupModal: (integration?: IntegrationType, channelType?: ChannelType) => ({ integration, channelType }),
closeSetupModal: true,
@@ -787,6 +802,13 @@ export const integrationsLogic = kea<integrationsLogicType>([
stopPolling: true,
}),
reducers({
+ newIntegrationModalId: [
+ null as string | null,
+ {
+ openNewIntegrationModal: (_, { id }: { id: string }) => id,
+ closeNewIntegrationModal: () => null,
+ },
+ ],
newIntegrationModalKind: [
null as IntegrationKind | null,
{
diff --git a/frontend/src/lib/integrations/utils.ts b/frontend/src/lib/integrations/utils.ts
index 637cf8a5cebc..2391ba8bd209 100644
--- a/frontend/src/lib/integrations/utils.ts
+++ b/frontend/src/lib/integrations/utils.ts
@@ -31,6 +31,7 @@ import IconPardot from 'public/services/pardot.png'
import IconPinterest from 'public/services/pinterest_ads.png'
import IconPostgres from 'public/services/postgres.png'
import IconReddit from 'public/services/reddit.png'
+import IconRedshift from 'public/services/redshift.png'
import IconS3Compatible from 'public/services/s3-compatible.png'
import IconSalesforce from 'public/services/salesforce.png'
import IconSlack from 'public/services/slack.png'
@@ -108,6 +109,7 @@ export const ICONS: Record<IntegrationKind, any> = {
apns: IconApple,
postgresql: IconPostgres,
'aws-s3': IconAwsS3,
+ 'aws-redshift': IconRedshift,
's3-compatible': IconS3Compatible,
snowflake: IconSnowflake,
'youtube-analytics': IconYouTubeAnalytics,
@@ -157,6 +159,9 @@ export const getIntegrationNameFromKind = (kind: string): string => {
return 'PostgreSQL'
case 'aws-s3':
return 'AWS S3'
+ // Named after the batch export destination users already see, not the `aws-` kind prefix.
+ case 'aws-redshift':
+ return 'Redshift'
case 's3-compatible':
return 'S3-compatible storage'
case 'youtube-analytics':
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 2e9e2f413488..320f22964786 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -31015,6 +31015,7 @@
"apns",
"postgresql",
"aws-s3",
+ "aws-redshift",
"s3-compatible",
"snowflake",
"youtube-analytics"
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportConfiguration.tsx b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportConfiguration.tsx
index 324cafedea4f..6224c508b81b 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportConfiguration.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportConfiguration.tsx
@@ -22,7 +22,12 @@ import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
import { teamLogic } from 'scenes/teamLogic'
import { NodeKind } from '~/queries/schema/schema-general'
-import { AnyPropertyFilter, BatchExportConfigurationTest, BatchExportConfigurationTestStep } from '~/types'
+import {
+ AnyPropertyFilter,
+ BatchExportConfigurationTest,
+ BatchExportConfigurationTestStep,
+ IntegrationType,
+} from '~/types'
import { batchExportConfigFormLogic } from './batchExportConfigFormLogic'
import {
@@ -45,6 +50,7 @@ export function BatchExportConfiguration(): JSX.Element {
runningStep,
isDatabaseDestination,
service,
+ selectedIntegration,
} = useValues(batchExportConfigFormLogic)
const { setSelectedModel, setConfigurationValue, runBatchExportConfigTestStep } =
useActions(batchExportConfigFormLogic)
@@ -367,6 +373,7 @@ export function BatchExportConfiguration(): JSX.Element {
<BatchExportConfigurationFields
isNew={isNew}
formValues={configuration as BatchExportConfigurationForm}
+ selectedIntegration={selectedIntegration}
/>
</div>
{batchExportConfigTest && (
@@ -393,14 +400,20 @@ export function BatchExportConfiguration(): JSX.Element {
function BatchExportConfigurationFields({
isNew,
formValues,
+ selectedIntegration,
}: {
isNew: boolean
formValues: BatchExportConfigurationForm
+ selectedIntegration: IntegrationType | null
}): JSX.Element {
return (
<>
<BatchExportGeneralEditFields isNew={isNew} isPipeline batchExportConfigForm={formValues} />
- <BatchExportsEditFields isNew={isNew} batchExportConfigForm={formValues} />
+ <BatchExportsEditFields
+ isNew={isNew}
+ batchExportConfigForm={formValues}
+ selectedIntegration={selectedIntegration}
+ />
</>
)
}
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportEditForm.tsx b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportEditForm.tsx
index 562f24ce6ec6..cbaee58553c6 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/BatchExportEditForm.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/BatchExportEditForm.tsx
@@ -5,6 +5,8 @@ import { DatePicker } from 'lib/components/DatePicker/DatePicker'
import { dayjs } from 'lib/dayjs'
import { LemonField } from 'lib/lemon-ui/LemonField'
+import type { IntegrationType } from '~/types'
+
import { DESTINATIONS } from './destinations'
import { BatchExportConfigurationForm } from './types'
@@ -82,16 +84,24 @@ export function BatchExportGeneralEditFields({
export function BatchExportsEditFields({
isNew,
batchExportConfigForm,
+ selectedIntegration,
}: {
isNew: boolean
batchExportConfigForm: BatchExportConfigurationForm
+ selectedIntegration?: IntegrationType | null
}): JSX.Element {
const destination = batchExportConfigForm.destination
const definition = destination ? DESTINATIONS[destination] : undefined
return (
<div className="flex flex-col gap-y-4 max-w-200">
- {definition && <definition.Fields isNew={isNew} formValues={batchExportConfigForm} />}
+ {definition && (
+ <definition.Fields
+ isNew={isNew}
+ formValues={batchExportConfigForm}
+ selectedIntegration={selectedIntegration}
+ />
+ )}
</div>
)
}
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts
index 3b4cea0e0bef..fd2e35ad6ea9 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts
+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.test.ts
@@ -193,6 +193,23 @@ const REDSHIFT_INSERT_BATCH_EXPORT = fixture('fixture-redshift-insert', 'Redshif
} as any,
})
+// Redshift exports created before the COPY option existed store no `mode` at all.
+const REDSHIFT_NO_MODE_BATCH_EXPORT = fixture('fixture-redshift-no-mode', 'Redshift Legacy Export', {
+ type: 'Redshift',
+ config: {
+ user: 'rs-user',
+ password: 'rs-pass',
+ host: 'rs-host',
+ port: 5439,
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ properties_data_type: 'SUPER' as any,
+ exclude_events: [],
+ include_events: [],
+ } as any,
+})
+
const REDSHIFT_COPY_IAM_BATCH_EXPORT = fixture('fixture-redshift-copy-iam', 'Redshift COPY IAM Export', {
type: 'Redshift',
config: {
@@ -292,6 +309,69 @@ const AZUREBLOB_BATCH_EXPORT = fixture('fixture-azureblob', 'Azure Blob Export',
},
})
+// Only a plain Redshift connection stores its own host. AWS ones mint temporary credentials for a
+// cluster endpoint the export has to carry itself, so `host` is required alongside them.
+const AWS_REDSHIFT_INTEGRATION = {
+ id: 21,
+ kind: 'aws-redshift',
+ display_name: 'prod-redshift (AWS role)',
+ config: { name: 'prod-redshift', aws_role_arn: 'arn:aws:iam::123456789012:role/rs', user: 'awsuser' },
+ created_at: '2024-01-01T00:00:00Z',
+}
+
+const PLAIN_REDSHIFT_INTEGRATION = {
+ id: 22,
+ kind: 'aws-redshift',
+ display_name: 'posthog@rs-host',
+ config: { host: 'rs-host', port: 5439, user: 'posthog', ssl_mode: 'require' },
+ created_at: '2024-01-01T00:00:00Z',
+}
+
+const S3_STAGING_INTEGRATION = {
+ id: 31,
+ kind: 'aws-s3',
+ display_name: 'staging-bucket-creds',
+ config: { name: 'staging-bucket-creds', aws_account_id: '123456789012' },
+ created_at: '2024-01-01T00:00:00Z',
+}
+
+const S3_READER_INTEGRATION = {
+ id: 32,
+ kind: 'aws-s3',
+ display_name: 'redshift-reader',
+ config: { name: 'redshift-reader', aws_role_arn: 'arn:aws:iam::123456789012:role/reader' },
+ created_at: '2024-01-01T00:00:00Z',
+}
+
+// Integration-backed COPY: both staging and read-back credentials are integration ids, and they
+// differ, so this covers the number branch of copy_inputs on the way in and out.
+const REDSHIFT_COPY_INTEGRATIONS_BATCH_EXPORT = fixture(
+ 'fixture-redshift-copy-integrations',
+ 'Redshift COPY Integrations Export',
+ {
+ type: 'Redshift',
+ integration: AWS_REDSHIFT_INTEGRATION.id,
+ config: {
+ host: 'rs-host',
+ port: 5439,
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ properties_data_type: 'super',
+ mode: 'COPY',
+ copy_inputs: {
+ s3_bucket: 'rs-staging',
+ s3_key_prefix: 'rs/copy/',
+ region_name: 'us-east-1',
+ bucket_credentials: S3_STAGING_INTEGRATION.id,
+ authorization: S3_READER_INTEGRATION.id,
+ },
+ exclude_events: [],
+ include_events: [],
+ } as any,
+ }
+)
+
// Single map keyed by id; used to register GET + PATCH mocks dynamically below.
const ALL_BATCH_EXPORTS: BatchExportConfiguration[] = [
AWS_S3_BATCH_EXPORT,
@@ -303,8 +383,10 @@ const ALL_BATCH_EXPORTS: BatchExportConfiguration[] = [
SNOWFLAKE_PASSWORD_BATCH_EXPORT,
SNOWFLAKE_KEYPAIR_BATCH_EXPORT,
REDSHIFT_INSERT_BATCH_EXPORT,
+ REDSHIFT_NO_MODE_BATCH_EXPORT,
REDSHIFT_COPY_IAM_BATCH_EXPORT,
REDSHIFT_COPY_CREDENTIALS_BATCH_EXPORT,
+ REDSHIFT_COPY_INTEGRATIONS_BATCH_EXPORT,
HTTP_BATCH_EXPORT,
DATABRICKS_BATCH_EXPORT,
AZUREBLOB_BATCH_EXPORT,
@@ -361,6 +443,15 @@ describe('batchExportConfigFormLogic', () => {
get: {
...getMocks,
'/api/environments/:team_id/batch_exports/test': { steps: [] },
+ '/api/environments/:team_id/integrations/': {
+ count: 4,
+ results: [
+ AWS_REDSHIFT_INTEGRATION,
+ PLAIN_REDSHIFT_INTEGRATION,
+ S3_STAGING_INTEGRATION,
+ S3_READER_INTEGRATION,
+ ],
+ },
},
post: {
'/api/environments/:team_id/batch_exports/': async ({ request }) => {
@@ -432,8 +523,19 @@ describe('batchExportConfigFormLogic', () => {
fields: ['integration_id', 'database', 'schema', 'table_name'],
},
{
+ // New Redshift exports authenticate via an integration, and default to COPY, which
+ // stages files through an S3 connection. `host` only joins once a connection is
+ // picked, since a plain one carries its own.
service: 'Redshift' as const,
- fields: ['user', 'password', 'host', 'port', 'database', 'schema', 'table_name'],
+ fields: [
+ 'integration_id',
+ 'database',
+ 'schema',
+ 'table_name',
+ 'redshift_s3_bucket',
+ 'redshift_s3_bucket_region_name',
+ 'redshift_s3_integration_id',
+ ],
},
{
// New Snowflake exports authenticate via an integration, not inline credentials.
@@ -616,8 +718,7 @@ describe('batchExportConfigFormLogic', () => {
logic.actions.setConfigurationValues({
...logic.values.configuration,
- user: 'rs-user',
- password: 'rs-pass',
+ integration_id: AWS_REDSHIFT_INTEGRATION.id,
host: 'rs-host',
port: 5439,
database: 'rs-db',
@@ -627,7 +728,7 @@ describe('batchExportConfigFormLogic', () => {
redshift_s3_bucket: 'INVALID-BUCKET',
redshift_s3_key_prefix: 'rs/',
redshift_s3_bucket_region_name: 'us-east-1',
- redshift_iam_role: 'arn:aws:iam::123:role/rs',
+ redshift_s3_integration_id: S3_STAGING_INTEGRATION.id,
interval: 'hour',
name: 'Test Export',
model: 'events',
@@ -640,6 +741,35 @@ describe('batchExportConfigFormLogic', () => {
})
})
+ describe('Redshift host requirement follows the picked connection', () => {
+ // A plain Redshift connection stores its own host, an AWS one does not. Getting this wrong
+ // either blocks plain-connection users from saving, or lets AWS-connection exports save
+ // without the cluster endpoint they need at run time.
+ it.each([
+ { name: 'AWS connection', integration: AWS_REDSHIFT_INTEGRATION, expected: 'This field is required' },
+ { name: 'plain connection', integration: PLAIN_REDSHIFT_INTEGRATION, expected: undefined },
+ ])('$name → host error: $expected', async ({ integration, expected }) => {
+ await initLogic({ service: 'Redshift', id: null })
+
+ logic.actions.setConfigurationValues({
+ ...logic.values.configuration,
+ integration_id: integration.id,
+ mode: 'INSERT',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ interval: 'hour',
+ name: 'Test Export',
+ model: 'events',
+ })
+
+ logic.actions.submitConfiguration()
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.configurationErrors.host).toBe(expected)
+ })
+ })
+
describe('Redshift COPY → INSERT drops the staging copy_inputs', () => {
// Loading a COPY export flattens copy_inputs into redshift_* form fields. Switching the
// mode to INSERT must null out copy_inputs (matching a native INSERT export) rather than
@@ -679,6 +809,27 @@ describe('batchExportConfigFormLogic', () => {
})
})
+ describe('Redshift export with no stored mode', () => {
+ // Exports predating the COPY option store no `mode`. Without a default the Command select
+ // renders blank, so the user has to guess which value reproduces what the export already
+ // does. INSERT is that value, and saving writes it back.
+ it('defaults to INSERT and persists it on save', async () => {
+ await initLogic({ service: null, id: REDSHIFT_NO_MODE_BATCH_EXPORT.id })
+
+ expect(logic.values.configuration.mode).toBe('INSERT')
+
+ await expectLogic(logic, () => {
+ logic.actions.submitConfiguration()
+ })
+ .toDispatchActions(['submitConfiguration', 'updateBatchExportConfigSuccess'])
+ .toFinishAllListeners()
+
+ const body = patchBodiesById[REDSHIFT_NO_MODE_BATCH_EXPORT.id]
+ expect(body.destination.config.mode).toBe('INSERT')
+ expect(body.destination.config.copy_inputs).toBeNull()
+ })
+ })
+
describe('successful update', () => {
it('sends changed field plus untouched fixture defaults', async () => {
await initLogic({ service: null, id: AWS_S3_BATCH_EXPORT.id })
@@ -760,8 +911,8 @@ describe('batchExportConfigFormLogic', () => {
expected: {
destination: 'Redshift',
mode: 'COPY',
- authorization_mode: 'IAMRole',
- properties_data_type: 'SUPER',
+ authorization_mode: 'SameConnection',
+ properties_data_type: 'super',
paused: true,
model: 'events',
},
@@ -894,11 +1045,12 @@ describe('batchExportConfigFormLogic', () => {
},
},
{
- name: 'Redshift (default COPY + IAM)',
+ // Default COPY: one S3 connection stages the files and Redshift reads them back
+ // through the same one, so both copy_inputs credentials carry that id.
+ name: 'Redshift (default COPY, same S3 connection)',
service: 'Redshift' as const,
requiredValues: {
- user: 'rs-user',
- password: 'rs-pass',
+ integration_id: AWS_REDSHIFT_INTEGRATION.id,
host: 'rs-host',
port: 5439,
database: 'rs-db',
@@ -907,24 +1059,131 @@ describe('batchExportConfigFormLogic', () => {
redshift_s3_bucket: 'rs-staging',
redshift_s3_key_prefix: 'rs/copy/',
redshift_s3_bucket_region_name: 'us-east-1',
- redshift_iam_role: 'arn:aws:iam::123:role/rs',
+ redshift_s3_integration_id: S3_STAGING_INTEGRATION.id,
},
expectedDestination: {
type: 'Redshift',
+ integration: AWS_REDSHIFT_INTEGRATION.id,
config: {
- user: 'rs-user',
- password: 'rs-pass',
host: 'rs-host',
port: 5439,
database: 'rs-db',
schema: 'public',
table_name: 'events',
- properties_data_type: 'SUPER',
+ properties_data_type: 'super',
+ mode: 'COPY',
+ copy_inputs: {
+ s3_bucket: 'rs-staging',
+ s3_key_prefix: 'rs/copy/',
+ region_name: 'us-east-1',
+ bucket_credentials: S3_STAGING_INTEGRATION.id,
+ authorization: S3_STAGING_INTEGRATION.id,
+ },
+ },
+ },
+ },
+ {
+ // A blank S3 key prefix is valid: the backend defaults a missing prefix to the
+ // bucket root. The form must not require it, and must omit it from the payload when
+ // unset so the backend applies that default.
+ name: 'Redshift (COPY, blank S3 key prefix stages at bucket root)',
+ service: 'Redshift' as const,
+ requiredValues: {
+ integration_id: AWS_REDSHIFT_INTEGRATION.id,
+ host: 'rs-host',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ redshift_s3_bucket: 'rs-staging',
+ redshift_s3_bucket_region_name: 'us-east-1',
+ redshift_s3_integration_id: S3_STAGING_INTEGRATION.id,
+ },
+ expectedDestination: {
+ type: 'Redshift',
+ integration: AWS_REDSHIFT_INTEGRATION.id,
+ config: {
+ host: 'rs-host',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ properties_data_type: 'super',
+ mode: 'COPY',
+ copy_inputs: {
+ s3_bucket: 'rs-staging',
+ region_name: 'us-east-1',
+ bucket_credentials: S3_STAGING_INTEGRATION.id,
+ authorization: S3_STAGING_INTEGRATION.id,
+ },
+ },
+ },
+ },
+ {
+ name: 'Redshift (COPY, different S3 connection for Redshift)',
+ service: 'Redshift' as const,
+ requiredValues: {
+ integration_id: AWS_REDSHIFT_INTEGRATION.id,
+ host: 'rs-host',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ redshift_s3_bucket: 'rs-staging',
+ redshift_s3_key_prefix: 'rs/copy/',
+ redshift_s3_bucket_region_name: 'us-east-1',
+ redshift_s3_integration_id: S3_STAGING_INTEGRATION.id,
+ authorization_mode: 'DifferentConnection',
+ redshift_authorization_integration_id: S3_READER_INTEGRATION.id,
+ },
+ expectedDestination: {
+ type: 'Redshift',
+ integration: AWS_REDSHIFT_INTEGRATION.id,
+ config: {
+ host: 'rs-host',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ properties_data_type: 'super',
+ mode: 'COPY',
+ copy_inputs: {
+ s3_bucket: 'rs-staging',
+ s3_key_prefix: 'rs/copy/',
+ region_name: 'us-east-1',
+ bucket_credentials: S3_STAGING_INTEGRATION.id,
+ authorization: S3_READER_INTEGRATION.id,
+ },
+ },
+ },
+ },
+ {
+ name: 'Redshift (COPY, cluster IAM role)',
+ service: 'Redshift' as const,
+ requiredValues: {
+ integration_id: AWS_REDSHIFT_INTEGRATION.id,
+ host: 'rs-host',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ redshift_s3_bucket: 'rs-staging',
+ redshift_s3_key_prefix: 'rs/copy/',
+ redshift_s3_bucket_region_name: 'us-east-1',
+ redshift_s3_integration_id: S3_STAGING_INTEGRATION.id,
+ authorization_mode: 'IAMRole',
+ redshift_iam_role: 'arn:aws:iam::123:role/rs',
+ },
+ expectedDestination: {
+ type: 'Redshift',
+ integration: AWS_REDSHIFT_INTEGRATION.id,
+ config: {
+ host: 'rs-host',
+ database: 'rs-db',
+ schema: 'public',
+ table_name: 'events',
+ properties_data_type: 'super',
mode: 'COPY',
copy_inputs: {
s3_bucket: 'rs-staging',
s3_key_prefix: 'rs/copy/',
region_name: 'us-east-1',
+ bucket_credentials: S3_STAGING_INTEGRATION.id,
authorization: 'arn:aws:iam::123:role/rs',
},
},
@@ -1040,6 +1299,7 @@ describe('batchExportConfigFormLogic', () => {
{ name: 'Redshift (INSERT)', fixture: REDSHIFT_INSERT_BATCH_EXPORT },
{ name: 'Redshift (COPY + IAM)', fixture: REDSHIFT_COPY_IAM_BATCH_EXPORT },
{ name: 'Redshift (COPY + Credentials)', fixture: REDSHIFT_COPY_CREDENTIALS_BATCH_EXPORT },
+ { name: 'Redshift (COPY + integrations)', fixture: REDSHIFT_COPY_INTEGRATIONS_BATCH_EXPORT },
{ name: 'HTTP', fixture: HTTP_BATCH_EXPORT },
{ name: 'Databricks', fixture: DATABRICKS_BATCH_EXPORT },
{ name: 'AzureBlob', fixture: AZUREBLOB_BATCH_EXPORT },
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx
index 44b21188ae07..e91255c35822 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/batchExportConfigFormLogic.tsx
@@ -7,6 +7,7 @@ import { beforeUnload, router } from 'kea-router'
import { LemonDialog, lemonToast } from '@posthog/lemon-ui'
import api from 'lib/api'
+import { integrationsLogic } from 'lib/integrations/integrationsLogic'
import { addProductIntent } from 'lib/utils/product-intents'
import { teamLogic } from 'scenes/teamLogic'
import { urls } from 'scenes/urls'
@@ -17,6 +18,7 @@ import {
BatchExportConfigurationTest,
BatchExportConfigurationTestStep,
BatchExportService,
+ IntegrationType,
} from '~/types'
import { batchExportDataLogic } from './batchExportDataLogic'
@@ -540,6 +542,7 @@ const sessionsTable: DatabaseSchemaBatchExportTable = {
export interface batchExportConfigFormLogicValues {
batchExportConfig: BatchExportConfiguration | null // batchExportDataLogic
batchExportConfigLoading: boolean // batchExportDataLogic
+ integrations: IntegrationType[] | null // integrationsLogic
teamTimezone: string // teamLogic
teamWeekStartDay: number // teamLogic
batchExportConfigTest: BatchExportConfigurationTest | null
@@ -564,6 +567,7 @@ export interface batchExportConfigFormLogicValues {
requiredFields: string[]
runningStep: number | null
savedConfiguration: Record<string, any>
+ selectedIntegration: IntegrationType | null
selectedModel: string
service:
| 'AwsS3'
@@ -733,6 +737,10 @@ export interface batchExportConfigFormLogicMeta {
| 'Snowflake'
| null
) => boolean
+ selectedIntegration: (
+ integrations: IntegrationType[] | null,
+ configuration: Record<string, any>
+ ) => IntegrationType | null
requiredFields: (
service:
| 'AwsS3'
@@ -746,7 +754,8 @@ export interface batchExportConfigFormLogicMeta {
| 'Snowflake'
| null,
isNew: boolean,
- configuration: Record<string, any>
+ configuration: Record<string, any>,
+ selectedIntegration: IntegrationType | null
) => string[]
}
}
@@ -778,6 +787,8 @@ export const batchExportConfigFormLogic = kea<batchExportConfigFormLogicType>([
['timezone as teamTimezone', 'weekStartDay as teamWeekStartDay'],
batchExportDataLogic({ id: props.id }),
['batchExportConfig', 'batchExportConfigLoading'],
+ integrationsLogic,
+ ['integrations'],
],
actions: [
batchExportDataLogic({ id: props.id }),
@@ -984,8 +995,16 @@ export const batchExportConfigFormLogic = kea<batchExportConfigFormLogicType>([
): boolean =>
!!service && ['Postgres', 'Redshift', 'Snowflake', 'Databricks', 'BigQuery'].includes(service),
],
+ // The Integration picked in the form, for destinations whose required fields depend on what
+ // the Integration itself stores (a plain Redshift connection carries its own host, an AWS
+ // one does not).
+ selectedIntegration: [
+ (s) => [s.integrations, s.configuration],
+ (integrations: IntegrationType[] | null, config: Record<string, any>): IntegrationType | null =>
+ integrations?.find((integration) => integration.id === config.integration_id) ?? null,
+ ],
requiredFields: [
- (s) => [s.service, s.isNew, s.configuration],
+ (s) => [s.service, s.isNew, s.configuration, s.selectedIntegration],
(
service:
| 'AwsS3'
@@ -999,7 +1018,8 @@ export const batchExportConfigFormLogic = kea<batchExportConfigFormLogicType>([
| 'Snowflake'
| null,
isNew: boolean,
- config: Record<string, any>
+ config: Record<string, any>,
+ selectedIntegration: IntegrationType | null
): string[] => {
const generalRequiredFields = ['interval', 'name', 'model']
if (!service) {
@@ -1009,7 +1029,10 @@ export const batchExportConfigFormLogic = kea<batchExportConfigFormLogicType>([
if (!definition) {
return generalRequiredFields
}
- return [...generalRequiredFields, ...definition.requiredFields({ isNew, formValues: config })]
+ return [
+ ...generalRequiredFields,
+ ...definition.requiredFields({ isNew, formValues: config, selectedIntegration }),
+ ]
},
],
})),
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx
index de72820916f0..23b833b1ce4d 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx
@@ -1,7 +1,10 @@
-import { LemonInput, LemonSelect } from '@posthog/lemon-ui'
+import { LemonBanner, LemonInput, LemonSelect } from '@posthog/lemon-ui'
+import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'
import { LemonField } from 'lib/lemon-ui/LemonField'
+import type { IntegrationType } from '~/types'
+
import { AWS_ONLY_REGION_OPTIONS, PERSON_PROPERTIES_EVENT_FIELD, validateBucketName } from './common'
import type { DestinationDefinition } from './types'
@@ -9,6 +12,50 @@ import type { DestinationDefinition } from './types'
// The COPY mode requires nested copy_inputs (s3_bucket, s3_key_prefix, region_name,
// authorization, bucket_credentials), which we flatten to top-level redshift_* fields
// in the form for editing and re-assemble on save.
+//
+// The two COPY credentials do different jobs: bucket_credentials is what PostHog writes the staged
+// files with, authorization is what Redshift reads them back with. Either can be an aws-s3
+// Integration id; authorization can also be the ARN of a role attached to the cluster.
+type AuthorizationMode = 'SameConnection' | 'DifferentConnection' | 'IAMRole' | 'Credentials'
+
+function buildBucketCredentials(formValues: Record<string, any>): number | Record<string, string> | undefined {
+ if (typeof formValues.redshift_s3_integration_id === 'number') {
+ return formValues.redshift_s3_integration_id
+ }
+ if (formValues.redshift_s3_bucket_aws_access_key_id && formValues.redshift_s3_bucket_aws_secret_access_key) {
+ return {
+ aws_access_key_id: formValues.redshift_s3_bucket_aws_access_key_id,
+ aws_secret_access_key: formValues.redshift_s3_bucket_aws_secret_access_key,
+ }
+ }
+ return undefined
+}
+
+function buildAuthorization(formValues: Record<string, any>): number | string | Record<string, string> | undefined {
+ switch (formValues.authorization_mode as AuthorizationMode) {
+ case 'SameConnection':
+ return typeof formValues.redshift_s3_integration_id === 'number'
+ ? formValues.redshift_s3_integration_id
+ : undefined
+ case 'DifferentConnection':
+ return typeof formValues.redshift_authorization_integration_id === 'number'
+ ? formValues.redshift_authorization_integration_id
+ : undefined
+ case 'IAMRole':
+ return formValues.redshift_iam_role || undefined
+ case 'Credentials':
+ return formValues.redshift_aws_access_key_id && formValues.redshift_aws_secret_access_key
+ ? {
+ aws_access_key_id: formValues.redshift_aws_access_key_id,
+ aws_secret_access_key: formValues.redshift_aws_secret_access_key,
+ }
+ : undefined
+ }
+}
+
+// Credentials the form cannot see (the API strips them from `config` on read) are left out of the
+// payload entirely rather than sent blank. The backend merges a partial config over the stored one,
+// so an omitted field keeps its value.
function buildCopyInputs(formValues: Record<string, any>): Record<string, any> {
const copyInputs: Record<string, any> = {
s3_bucket: formValues.redshift_s3_bucket,
@@ -16,20 +63,14 @@ function buildCopyInputs(formValues: Record<string, any>): Record<string, any> {
region_name: formValues.redshift_s3_bucket_region_name,
}
- if (formValues.redshift_iam_role) {
- copyInputs.authorization = formValues.redshift_iam_role
- } else if (formValues.redshift_aws_access_key_id && formValues.redshift_aws_secret_access_key) {
- copyInputs.authorization = {
- aws_access_key_id: formValues.redshift_aws_access_key_id,
- aws_secret_access_key: formValues.redshift_aws_secret_access_key,
- }
+ const bucketCredentials = buildBucketCredentials(formValues)
+ if (bucketCredentials !== undefined) {
+ copyInputs.bucket_credentials = bucketCredentials
}
- if (formValues.redshift_s3_bucket_aws_access_key_id && formValues.redshift_s3_bucket_aws_secret_access_key) {
- copyInputs.bucket_credentials = {
- aws_access_key_id: formValues.redshift_s3_bucket_aws_access_key_id,
- aws_secret_access_key: formValues.redshift_s3_bucket_aws_secret_access_key,
- }
+ const authorization = buildAuthorization(formValues)
+ if (authorization !== undefined) {
+ copyInputs.authorization = authorization
}
return copyInputs
@@ -44,28 +85,88 @@ const REDSHIFT_FORM_ONLY_FIELDS = [
'redshift_s3_bucket',
'redshift_s3_key_prefix',
'redshift_s3_bucket_region_name',
+ 'redshift_s3_integration_id',
+ 'redshift_s3_credentials_inline',
'redshift_s3_bucket_aws_access_key_id',
'redshift_s3_bucket_aws_secret_access_key',
+ 'redshift_authorization_integration_id',
'redshift_iam_role',
'redshift_aws_access_key_id',
'redshift_aws_secret_access_key',
] as const
+// New exports must store their credentials in Integrations. Exports created before integrations
+// existed keep their inline credentials, detected by what deserialize found in the stored config.
+function usesConnection(isNew: boolean, formValues: Record<string, any>): boolean {
+ return isNew || !!formValues.integration_id
+}
+
+function usesS3Connection(isNew: boolean, formValues: Record<string, any>): boolean {
+ return isNew || !formValues.redshift_s3_credentials_inline
+}
+
+// Only a plain Redshift connection stores its own endpoint. AWS ones mint temporary credentials for
+// a cluster endpoint that stays on the export, so the export has to carry the host itself.
+function connectionCarriesHost(connection: IntegrationType | null | undefined): boolean {
+ return !!connection?.config?.host
+}
+
export const redshiftDefinition: DestinationDefinition = {
type: 'Redshift',
+ usesIntegration: true,
defaults: () => ({
mode: 'COPY',
- authorization_mode: 'IAMRole',
- properties_data_type: 'SUPER',
+ authorization_mode: 'SameConnection',
+ properties_data_type: 'super',
}),
- requiredFields: ({ isNew }) => [
- ...(isNew ? ['user'] : []),
- ...(isNew ? ['password'] : []),
+ requiredFields: ({ isNew, formValues, selectedIntegration }) => {
+ const fields = ['database', 'schema', 'table_name']
+
+ if (usesConnection(isNew, formValues)) {
+ if (isNew) {
+ fields.push('integration_id')
+ }
+ // Held back until a connection is picked: `integration_id` already blocks the save, and
+ // flagging an endpoint we may not even need reads as a second, wrong problem.
+ if (formValues.integration_id && !connectionCarriesHost(selectedIntegration)) {
+ fields.push('host')
+ }
+ } else {
+ fields.push('host')
+ }
+
+ if (formValues.mode === 'COPY') {
+ // s3_key_prefix is intentionally not required: the backend defaults a missing prefix to
+ // the bucket root, so leaving it blank is a valid choice, not an error.
+ fields.push('redshift_s3_bucket', 'redshift_s3_bucket_region_name')
+
+ if (usesS3Connection(isNew, formValues)) {
+ fields.push('redshift_s3_integration_id')
+ }
+
+ if (formValues.authorization_mode === 'DifferentConnection') {
+ fields.push('redshift_authorization_integration_id')
+ } else if (formValues.authorization_mode === 'IAMRole') {
+ fields.push('redshift_iam_role')
+ }
+ }
+
+ return fields
+ },
+ // Mirrors the destination fields of RedshiftBatchExportInputs. The inline credential keys stay
+ // allowlisted for grandfathered exports.
+ // TODO: drop user/password once every export is integration-backed
+ configKeys: [
+ 'database',
'host',
'port',
- 'database',
'schema',
'table_name',
+ 'properties_data_type',
+ 'mode',
+ 'copy_inputs',
+ 'user',
+ 'password',
],
validate: (formValues) => {
if (formValues.mode === 'COPY') {
@@ -88,49 +189,111 @@ export const redshiftDefinition: DestinationDefinition = {
return config
},
deserialize: (config) => {
- const result: Record<string, any> = { ...config, authorization_mode: 'IAMRole' }
- if (config.copy_inputs) {
- const copyInputs = config.copy_inputs
- result.redshift_s3_bucket = copyInputs.s3_bucket
- result.redshift_s3_key_prefix = copyInputs.s3_key_prefix
- result.redshift_s3_bucket_region_name = copyInputs.region_name
- result.redshift_s3_bucket_aws_access_key_id = copyInputs.bucket_credentials?.aws_access_key_id
- result.redshift_s3_bucket_aws_secret_access_key = copyInputs.bucket_credentials?.aws_secret_access_key
- result.redshift_iam_role = undefined
- result.redshift_aws_access_key_id = undefined
- result.redshift_aws_secret_access_key = undefined
-
- if (typeof copyInputs.authorization === 'string') {
- result.authorization_mode = 'IAMRole'
- result.redshift_iam_role = copyInputs.authorization
- } else if (copyInputs.authorization) {
- result.authorization_mode = 'Credentials'
- result.redshift_aws_access_key_id = copyInputs.authorization.aws_access_key_id
- result.redshift_aws_secret_access_key = copyInputs.authorization.aws_secret_access_key
- }
+ const result: Record<string, any> = {
+ // Exports created before COPY existed store no mode, and INSERT is what they run.
+ mode: 'INSERT',
+ ...config,
+ authorization_mode: 'SameConnection',
}
+ const copyInputs = config.copy_inputs
+ if (!copyInputs) {
+ return result
+ }
+
+ result.redshift_s3_bucket = copyInputs.s3_bucket
+ result.redshift_s3_key_prefix = copyInputs.s3_key_prefix
+ result.redshift_s3_bucket_region_name = copyInputs.region_name
+ result.redshift_s3_integration_id = undefined
+ result.redshift_s3_bucket_aws_access_key_id = undefined
+ result.redshift_s3_bucket_aws_secret_access_key = undefined
+ result.redshift_authorization_integration_id = undefined
+ result.redshift_iam_role = undefined
+ result.redshift_aws_access_key_id = undefined
+ result.redshift_aws_secret_access_key = undefined
+
+ const bucketCredentials = copyInputs.bucket_credentials
+ // Inline credentials come back as an empty object once the API strips them, so the shape of
+ // what is stored — not its contents — is what says whether this export predates connections.
+ result.redshift_s3_credentials_inline = bucketCredentials !== undefined && typeof bucketCredentials !== 'number'
+ if (typeof bucketCredentials === 'number') {
+ result.redshift_s3_integration_id = bucketCredentials
+ } else if (bucketCredentials) {
+ result.redshift_s3_bucket_aws_access_key_id = bucketCredentials.aws_access_key_id
+ result.redshift_s3_bucket_aws_secret_access_key = bucketCredentials.aws_secret_access_key
+ }
+
+ const authorization = copyInputs.authorization
+ if (typeof authorization === 'number') {
+ result.redshift_authorization_integration_id = authorization
+ result.authorization_mode = authorization === bucketCredentials ? 'SameConnection' : 'DifferentConnection'
+ } else if (typeof authorization === 'string') {
+ result.authorization_mode = 'IAMRole'
+ result.redshift_iam_role = authorization
+ } else if (authorization) {
+ result.authorization_mode = 'Credentials'
+ result.redshift_aws_access_key_id = authorization.aws_access_key_id
+ result.redshift_aws_secret_access_key = authorization.aws_secret_access_key
+ }
+
return result
},
eventTableOverrides: { teamIdHogql: 'toInt32(team_id)' },
eventTableExtraFields: { ...PERSON_PROPERTIES_EVENT_FIELD },
- Fields: function RedshiftFields({ isNew, formValues }) {
+ Fields: function RedshiftFields({ isNew, formValues, selectedIntegration }) {
+ const useConnection = usesConnection(isNew, formValues)
+ const useS3Connection = usesS3Connection(isNew, formValues)
+ // Until a connection is picked we cannot tell which kind it is, so we keep asking.
+ const showHost = !useConnection || !connectionCarriesHost(selectedIntegration)
+
+ // "Credentials" is never offered to a new export. It stays reachable while an export still
+ // stores inline keys, so an accidental switch away from it can be undone.
+ const allowInlineAuthorizationKeys = !useS3Connection || formValues.authorization_mode === 'Credentials'
+ const authorizationOptions = [
+ ...(useS3Connection ? [{ value: 'SameConnection', label: 'Use the S3 connection above' }] : []),
+ {
+ value: 'DifferentConnection',
+ label: useS3Connection ? 'Use a different S3 connection' : 'Use an S3 connection',
+ },
+ { value: 'IAMRole', label: 'Use an IAM role attached to the cluster' },
+ ...(allowInlineAuthorizationKeys ? [{ value: 'Credentials', label: 'Use AWS access keys' }] : []),
+ ]
+
return (
<>
- <LemonField name="user" label="User">
- <LemonInput placeholder={isNew ? 'my-user' : 'Leave unchanged'} />
- </LemonField>
+ {useConnection ? (
+ <LemonField name="integration_id" label="Connection">
+ {({ value, onChange }) => (
+ <IntegrationChoice integration="aws-redshift" value={value} onChange={onChange} />
+ )}
+ </LemonField>
+ ) : (
+ <>
+ <LemonBanner type="warning">
+ PostHog is moving Redshift batch exports to saved connections. This export will be migrated
+ automatically.
+ </LemonBanner>
- <LemonField name="password" label="Password">
- <LemonInput placeholder={isNew ? 'my-password' : 'Leave unchanged'} type="password" />
- </LemonField>
+ <LemonField name="user" label="User">
+ <LemonInput placeholder="Leave unchanged" />
+ </LemonField>
- <LemonField name="host" label="Host">
- <LemonInput placeholder="my-host" />
- </LemonField>
+ <LemonField name="password" label="Password">
+ <LemonInput placeholder="Leave unchanged" type="password" />
+ </LemonField>
+ </>
+ )}
- <LemonField name="port" label="Port">
- <LemonInput placeholder="5439" type="number" min="0" max="65535" />
- </LemonField>
+ {showHost && (
+ <>
+ <LemonField name="host" label="Host">
+ <LemonInput placeholder="my-host" />
+ </LemonField>
+
+ <LemonField name="port" label="Port" showOptional>
+ <LemonInput placeholder="5439" type="number" min="0" max="65535" />
+ </LemonField>
+ </>
+ )}
<LemonField name="database" label="Database">
<LemonInput placeholder="my-database" />
@@ -187,12 +350,8 @@ export const redshiftDefinition: DestinationDefinition = {
{formValues.mode === 'COPY' && (
<>
<p className="text-xs text-muted mt-1">
- In order to execute a COPY SQL command, the batch export will first export files to an S3
- bucket, which requires credentials to access it. After the files are available in the
- bucket, we will instruct Redshift to copy them into the configured table. As part of this,
- the batch export needs to specify to Redshift how to access your bucket. For this reason,
- additionally to the first set of credentials used by the batch export, either an IAM role
- (recommended), or the same or a different set of credentials is required.
+ COPY loads data through an S3 bucket. PostHog stages the export files there, then tells
+ Redshift to copy them into your table.
</p>
<div className="flex gap-4">
@@ -212,50 +371,64 @@ export const redshiftDefinition: DestinationDefinition = {
<LemonInput placeholder="e.g. /posthog-copy-files" />
</LemonField>
- <div className="flex gap-4">
+ {useS3Connection ? (
<LemonField
- name="redshift_s3_bucket_aws_access_key_id"
- label="AWS Access Key ID"
- className="flex-1"
+ name="redshift_s3_integration_id"
+ label="S3 connection"
+ info="The credentials PostHog uses to stage export files in the bucket."
>
- <LemonInput
- placeholder={isNew ? 'e.g. AKIAIOSFODNN7EXAMPLE' : 'Leave unchanged'}
- autoComplete="off"
- />
+ {({ value, onChange }) => (
+ <IntegrationChoice integration="aws-s3" value={value} onChange={onChange} />
+ )}
</LemonField>
+ ) : (
+ <>
+ <LemonBanner type="warning">
+ PostHog is moving the S3 staging credentials to saved connections. This export will
+ be migrated automatically.
+ </LemonBanner>
- <LemonField
- name="redshift_s3_bucket_aws_secret_access_key"
- label="AWS Secret Access Key"
- className="flex-1"
- >
- <LemonInput
- placeholder={isNew ? 'e.g. secret-key' : 'Leave unchanged'}
- type="password"
- autoComplete="new-password"
- />
- </LemonField>
- </div>
+ <div className="flex gap-4">
+ <LemonField
+ name="redshift_s3_bucket_aws_access_key_id"
+ label="AWS Access Key ID"
+ className="flex-1"
+ >
+ <LemonInput placeholder="Leave unchanged" autoComplete="off" />
+ </LemonField>
+
+ <LemonField
+ name="redshift_s3_bucket_aws_secret_access_key"
+ label="AWS Secret Access Key"
+ className="flex-1"
+ >
+ <LemonInput
+ placeholder="Leave unchanged"
+ type="password"
+ autoComplete="new-password"
+ />
+ </LemonField>
+ </div>
+ </>
+ )}
<LemonField
name="authorization_mode"
- label="Authorization"
+ label="How Redshift reads staged files"
className="flex-1"
- info={
- <>
- Redshift needs to authenticate to COPY data from your S3 bucket. Choose whether to
- assume an IAM role or to provide it with credentials to access the S3 bucket.
- </>
- }
+ info="PostHog writes the staged files. Redshift then needs its own access to read them back."
>
- <LemonSelect
- options={[
- { value: 'IAMRole', label: 'IAM Role' },
- { value: 'Credentials', label: 'Credentials' },
- ]}
- />
+ <LemonSelect options={authorizationOptions} />
</LemonField>
+ {formValues.authorization_mode === 'DifferentConnection' && (
+ <LemonField name="redshift_authorization_integration_id" label="S3 connection for Redshift">
+ {({ value, onChange }) => (
+ <IntegrationChoice integration="aws-s3" value={value} onChange={onChange} />
+ )}
+ </LemonField>
+ )}
+
{formValues.authorization_mode === 'IAMRole' && (
<LemonField name="redshift_iam_role" label="IAM Role ARN" className="flex-1">
<LemonInput placeholder="e.g. arn:aws:iam::<aws-account-id>:role/<role-name>" />
@@ -269,10 +442,7 @@ export const redshiftDefinition: DestinationDefinition = {
label="AWS Access Key ID"
className="flex-1"
>
- <LemonInput
- placeholder={isNew ? 'e.g. AKIAIOSFODNN7EXAMPLE' : 'Leave unchanged'}
- autoComplete="off"
- />
+ <LemonInput placeholder="Leave unchanged" autoComplete="off" />
</LemonField>
<LemonField
@@ -281,7 +451,7 @@ export const redshiftDefinition: DestinationDefinition = {
className="flex-1"
>
<LemonInput
- placeholder={isNew ? 'e.g. secret-key' : 'Leave unchanged'}
+ placeholder="Leave unchanged"
type="password"
autoComplete="new-password"
/>
diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts b/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts
index 4defc3678696..c6b202be09f9 100644
--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts
+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/types.ts
@@ -1,13 +1,16 @@
import type React from 'react'
import type { DatabaseSchemaField } from '~/queries/schema/schema-general'
-import type { BatchExportService } from '~/types'
+import type { BatchExportService, IntegrationType } from '~/types'
export type BatchExportServiceType = BatchExportService['type']
export interface DestinationContext {
isNew: boolean
formValues: Record<string, any>
+ // The Integration currently picked in the form, when the destination uses one. Null while
+ // integrations are still loading, or when the picked one no longer exists.
+ selectedIntegration?: IntegrationType | null
}
// Overrides applied to the events table preview shown in the HogQL model picker.
@@ -40,5 +43,5 @@ export interface DestinationDefinition {
eventTableOverrides?: EventTableOverrides
// Lift integration_id from destination.integration during deserialize and push it back during save.
usesIntegration?: boolean
- Fields: React.FC<{ isNew: boolean; formValues: Record<string, any> }>
+ Fields: React.FC<DestinationContext>
}
diff --git a/frontend/src/scenes/integrations/aws-s3/AwsS3SetupModal.tsx b/frontend/src/scenes/integrations/aws-s3/AwsS3SetupModal.tsx
index 95aed9fbf795..6b61085da876 100644
--- a/frontend/src/scenes/integrations/aws-s3/AwsS3SetupModal.tsx
+++ b/frontend/src/scenes/integrations/aws-s3/AwsS3SetupModal.tsx
@@ -4,27 +4,15 @@ import { Form } from 'kea-forms'
import { LemonBanner, LemonButton, LemonInput, LemonModal, LemonTabs } from '@posthog/lemon-ui'
import { LemonField } from 'lib/lemon-ui/LemonField'
-import { organizationLogic } from 'scenes/organizationLogic'
-import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
-
-import { Region } from '~/types'
+import { AwsRoleRequirements } from 'scenes/integrations/components/AwsRoleRequirements'
import { AwsS3SetupModalLogicProps, awsS3SetupModalLogic } from './awsS3SetupModalLogic'
-const POSTHOG_ROLE_ARN_BY_REGION: Partial<Record<Region, string>> = {
- [Region.US]: 'arn:aws:iam::309986977637:role/posthog-external-batch-exports',
- [Region.EU]: 'arn:aws:iam::623789312881:role/posthog-external-batch-exports',
-}
-
export const AwsS3SetupModal = (props: AwsS3SetupModalLogicProps): JSX.Element => {
const logic = awsS3SetupModalLogic(props)
- const { currentOrganization } = useValues(organizationLogic)
- const { preflight } = useValues(preflightLogic)
const { authMode, isAwsS3IntegrationSubmitting } = useValues(logic)
const { setAuthMode, submitAwsS3Integration } = useActions(logic)
- const posthogRoleArn = preflight?.region ? POSTHOG_ROLE_ARN_BY_REGION[preflight.region] : undefined
-
return (
<LemonModal
isOpen={props.isOpen}
@@ -72,47 +60,15 @@ export const AwsS3SetupModal = (props: AwsS3SetupModalLogicProps): JSX.Element =
autoComplete="off"
/>
</LemonField>
- <div className="border border-border rounded p-4 bg-bg-light flex flex-col gap-3 text-sm">
- <p className="font-semibold m-0">Requirements</p>
- <div className="flex gap-3 items-start">
- <span className="bg-primary-highlight text-primary-alt rounded-full w-5 h-5 flex items-center justify-center text-xs font-semibold shrink-0 mt-0.5">
- 1
- </span>
- <p className="m-0 text-secondary">
- {posthogRoleArn ? (
- <>
- Create an IAM role with a trust policy that allows PostHog's role{' '}
- <code>{posthogRoleArn}</code> to assume it.
- </>
- ) : (
- <>
- Create an IAM role with a trust policy that allows PostHog's role to assume
- it. Check with your instance administrator to obtain the role to trust.
- </>
- )}
- </p>
- </div>
- <div className="flex gap-3 items-start">
- <span className="bg-primary-highlight text-primary-alt rounded-full w-5 h-5 flex items-center justify-center text-xs font-semibold shrink-0 mt-0.5">
- 2
- </span>
- <p className="m-0 text-secondary">
- The trust policy must require an <code>sts:ExternalId</code> condition equal to{' '}
- <code>posthog-{currentOrganization?.id}</code>. PostHog verifies this condition is
- enforced and exports will fail without it.
- </p>
- </div>
- <div className="flex gap-3 items-start">
- <span className="bg-primary-highlight text-primary-alt rounded-full w-5 h-5 flex items-center justify-center text-xs font-semibold shrink-0 mt-0.5">
- 3
- </span>
- <p className="m-0 text-secondary">
+ <AwsRoleRequirements
+ permissions={
+ <>
Grant the role <code>s3:PutObject</code> and <code>s3:AbortMultipartUpload</code> on
the destination bucket and prefix. If the bucket uses KMS encryption, also grant{' '}
<code>kms:GenerateDataKey</code> and <code>kms:Decrypt</code> on the key.
- </p>
- </div>
- </div>
+ </>
+ }
+ />
</>
) : (
<>
diff --git a/frontend/src/scenes/integrations/components/AwsRoleRequirements.tsx b/frontend/src/scenes/integrations/components/AwsRoleRequirements.tsx
new file mode 100644
index 000000000000..9cdb9e3aeeea
--- /dev/null
+++ b/frontend/src/scenes/integrations/components/AwsRoleRequirements.tsx
@@ -0,0 +1,59 @@
+import { useValues } from 'kea'
+
+import { organizationLogic } from 'scenes/organizationLogic'
+import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'
+
+import { Region } from '~/types'
+
+// PostHog's own role, which a customer's trust policy has to name. Mirrors
+// BATCH_EXPORT_S3_EXTERNAL_ROLE_ARN per region, the role every AWS role integration assumes from.
+const POSTHOG_ROLE_ARN_BY_REGION: Partial<Record<Region, string>> = {
+ [Region.US]: 'arn:aws:iam::309986977637:role/posthog-external-batch-exports',
+ [Region.EU]: 'arn:aws:iam::623789312881:role/posthog-external-batch-exports',
+}
+
+/**
+ * The trust-policy checklist shown on the "assume IAM role" tab of an AWS integration setup modal.
+ * The first two steps are the same for every AWS service, so callers only supply the permissions
+ * their service needs.
+ */
+export function AwsRoleRequirements({ permissions }: { permissions: JSX.Element }): JSX.Element {
+ const { currentOrganization } = useValues(organizationLogic)
+ const { preflight } = useValues(preflightLogic)
+
+ const posthogRoleArn = preflight?.region ? POSTHOG_ROLE_ARN_BY_REGION[preflight.region] : undefined
+
+ const steps: JSX.Element[] = [
+ posthogRoleArn ? (
+ <>
+ Create an IAM role with a trust policy that allows PostHog's role <code>{posthogRoleArn}</code> to
+ assume it.
+ </>
+ ) : (
+ <>
+ Create an IAM role with a trust policy that allows PostHog's role to assume it. Check with your instance
+ administrator to obtain the role to trust.
+ </>
+ ),
+ <>
+ The trust policy must require an <code>sts:ExternalId</code> condition equal to{' '}
+ <code>posthog-{currentOrganization?.id}</code>. PostHog verifies this condition is enforced and exports will
+ fail without it.
+ </>,
+ permissions,
+ ]
+
+ return (
+ <div className="border border-border rounded p-4 bg-bg-light flex flex-col gap-3 text-sm">
+ <p className="font-semibold m-0">Requirements</p>
+ {steps.map((step, index) => (
+ <div key={index} className="flex gap-3 items-start">
+ <span className="bg-primary-highlight text-primary-alt rounded-full w-5 h-5 flex items-center justify-center text-xs font-semibold shrink-0 mt-0.5">
+ {index + 1}
+ </span>
+ <p className="m-0 text-secondary">{step}</p>
+ </div>
+ ))}
+ </div>
+ )
+}
diff --git a/frontend/src/scenes/integrations/redshift/RedshiftSetupModal.tsx b/frontend/src/scenes/integrations/redshift/RedshiftSetupModal.tsx
new file mode 100644
index 000000000000..2a0ff26932c3
--- /dev/null
+++ b/frontend/src/scenes/integrations/redshift/RedshiftSetupModal.tsx
@@ -0,0 +1,262 @@
+import { useActions, useValues } from 'kea'
+import { Form } from 'kea-forms'
+
+import {
+ LemonBanner,
+ LemonButton,
+ LemonCheckbox,
+ LemonInput,
+ LemonModal,
+ LemonSelect,
+ LemonTabs,
+ lemonToast,
+} from '@posthog/lemon-ui'
+
+import { LemonCollapse } from 'lib/lemon-ui/LemonCollapse'
+import { LemonField } from 'lib/lemon-ui/LemonField'
+import { LemonFileInput } from 'lib/lemon-ui/LemonFileInput/LemonFileInput'
+import { LemonInputSelect } from 'lib/lemon-ui/LemonInputSelect'
+import { AwsRoleRequirements } from 'scenes/integrations/components/AwsRoleRequirements'
+
+import { RedshiftSetupModalLogicProps, redshiftSetupModalLogic } from './redshiftSetupModalLogic'
+
+export const RedshiftSetupModal = (props: RedshiftSetupModalLogicProps): JSX.Element => {
+ const logic = redshiftSetupModalLogic(props)
+ const { authMode, redshiftIntegration, isRedshiftIntegrationSubmitting } = useValues(logic)
+ const { setAuthMode, submitRedshiftIntegration, setRedshiftIntegrationValue } = useActions(logic)
+
+ return (
+ <LemonModal
+ isOpen={props.isOpen}
+ width={680}
+ title="Configure Redshift connection"
+ description="Connect PostHog to your Redshift cluster. Connections can be reused across exports."
+ onClose={() => props.onComplete()}
+ footer={
+ <>
+ <LemonButton type="secondary" onClick={() => props.onComplete()}>
+ Cancel
+ </LemonButton>
+ <LemonButton
+ type="primary"
+ loading={isRedshiftIntegrationSubmitting}
+ onClick={submitRedshiftIntegration}
+ data-attr="redshift-integration-save"
+ >
+ Save
+ </LemonButton>
+ </>
+ }
+ >
+ <Form
+ logic={redshiftSetupModalLogic}
+ props={props}
+ formKey="redshiftIntegration"
+ className="flex flex-col gap-4"
+ >
+ <LemonTabs
+ activeKey={authMode}
+ onChange={setAuthMode}
+ tabs={[
+ { key: 'role', label: 'IAM role' },
+ { key: 'access_key', label: 'Access keys' },
+ { key: 'password', label: 'Username and password' },
+ ]}
+ />
+
+ {authMode === 'password' ? (
+ <>
+ <LemonField name="host" label="Host">
+ <LemonInput placeholder="e.g. my-cluster.abc123.us-east-1.redshift.amazonaws.com" />
+ </LemonField>
+
+ <LemonField name="port" label="Port">
+ <LemonInput type="number" min="0" max="65535" placeholder="5439" />
+ </LemonField>
+
+ <LemonField name="user" label="User">
+ <LemonInput placeholder="e.g. posthog" autoComplete="off" />
+ </LemonField>
+
+ <LemonField name="password" label="Password">
+ <LemonInput type="password" autoComplete="new-password" />
+ </LemonField>
+
+ <LemonField
+ name="sslMode"
+ label="Verify server identity?"
+ info={
+ <>
+ Verifies that the certificate presented by the cluster is signed by a trusted
+ certificate authority, and optionally that its hostname matches the host you
+ entered. This guards against man-in-the-middle attacks.
+ <br />
+ <br />
+ The connection is always encrypted regardless of this setting, because PostHog
+ requires TLS. These options only add verification of the server certificate.
+ </>
+ }
+ >
+ <LemonSelect
+ options={[
+ { value: 'require', label: 'No' },
+ { value: 'verify-ca', label: 'Verify certificate authority' },
+ { value: 'verify-full', label: 'Verify certificate authority and server hostname' },
+ ]}
+ />
+ </LemonField>
+
+ {redshiftIntegration.sslMode !== 'require' && (
+ <>
+ <LemonField name="useSystemCa">
+ {({ value, onChange }) => (
+ <LemonCheckbox
+ bordered
+ checked={!!value}
+ onChange={onChange}
+ label="Use the system certificate authorities"
+ />
+ )}
+ </LemonField>
+
+ {!redshiftIntegration.useSystemCa && (
+ <LemonField name="sslRootCert" label="Root certificate">
+ {() => (
+ <LemonFileInput
+ accept=".crt,.pem,.cer,.ca-bundle"
+ multiple={false}
+ onChange={(files) => {
+ if (!files[0]) {
+ setRedshiftIntegrationValue('sslRootCert', '')
+ return
+ }
+ void files[0]
+ .text()
+ .then((text) =>
+ setRedshiftIntegrationValue('sslRootCert', text)
+ )
+ .catch(() => {
+ lemonToast.error('Failed to read the certificate file')
+ setRedshiftIntegrationValue('sslRootCert', '')
+ })
+ }}
+ />
+ )}
+ </LemonField>
+ )}
+ </>
+ )}
+ </>
+ ) : (
+ <>
+ <LemonField name="name" label="Name" info="A name to identify this connection across exports.">
+ <LemonInput placeholder="e.g. Production cluster" />
+ </LemonField>
+
+ {authMode === 'role' ? (
+ <>
+ <LemonField
+ name="awsRoleArn"
+ label="IAM role ARN"
+ info="The ARN of an IAM role in your AWS account that PostHog assumes to get temporary Redshift credentials."
+ >
+ <LemonInput
+ placeholder="e.g. arn:aws:iam::123456789012:role/posthog-batch-exports"
+ autoComplete="off"
+ />
+ </LemonField>
+ <AwsRoleRequirements
+ permissions={
+ <>
+ Grant the role <code>redshift:GetClusterCredentials</code> on the cluster,
+ the database and the database user. On Redshift Serverless, grant{' '}
+ <code>redshift-serverless:GetCredentials</code> on the workgroup instead.
+ </>
+ }
+ />
+ </>
+ ) : (
+ <>
+ <LemonBanner type="warning">
+ Access keys are long-lived credentials stored by PostHog (encrypted). Prefer letting
+ PostHog assume an IAM role to avoid creating and storing long-lived credentials.
+ </LemonBanner>
+ <LemonField name="awsAccessKeyId" label="AWS Access Key ID">
+ <LemonInput placeholder="e.g. AKIAIOSFODNN7EXAMPLE" autoComplete="off" />
+ </LemonField>
+ <LemonField name="awsSecretAccessKey" label="AWS Secret Access Key">
+ <LemonInput
+ type="password"
+ placeholder="e.g. secret-key"
+ autoComplete="new-password"
+ />
+ </LemonField>
+ </>
+ )}
+
+ <LemonField
+ name="user"
+ label="User"
+ info="The Redshift user to connect as. PostHog requests temporary credentials for this user on every run, so there is no database password to store."
+ >
+ <LemonInput placeholder="e.g. posthog" autoComplete="off" />
+ </LemonField>
+
+ <LemonCollapse
+ panels={[
+ {
+ key: 'advanced',
+ header: 'Advanced options',
+ content: (
+ <div className="flex flex-col gap-4">
+ <LemonField
+ name="groups"
+ label="Database groups"
+ showOptional
+ info="Groups the user joins for the duration of each run. Leave empty to keep the user's existing groups."
+ >
+ {({ value, onChange }) => (
+ <LemonInputSelect
+ mode="multiple"
+ allowCustomValues
+ options={[]}
+ value={value ?? []}
+ onChange={onChange}
+ placeholder="Enter a group name"
+ />
+ )}
+ </LemonField>
+
+ <LemonField name="autoCreate">
+ {({ value, onChange }) => (
+ <LemonCheckbox
+ bordered
+ checked={!!value}
+ onChange={onChange}
+ label="Create the user if it does not exist"
+ />
+ )}
+ </LemonField>
+
+ <LemonField
+ name="workgroupArn"
+ label="Serverless workgroup ARN"
+ showOptional
+ info="Only needed for Redshift Serverless. Leave empty for a provisioned cluster."
+ >
+ <LemonInput
+ placeholder="e.g. arn:aws:redshift-serverless:us-east-1:123456789012:workgroup/my-workgroup"
+ autoComplete="off"
+ />
+ </LemonField>
+ </div>
+ ),
+ },
+ ]}
+ />
+ </>
+ )}
+ </Form>
+ </LemonModal>
+ )
+}
diff --git a/frontend/src/scenes/integrations/redshift/redshiftSetupModalLogic.ts b/frontend/src/scenes/integrations/redshift/redshiftSetupModalLogic.ts
new file mode 100644
index 000000000000..01a022c73d33
--- /dev/null
+++ b/frontend/src/scenes/integrations/redshift/redshiftSetupModalLogic.ts
@@ -0,0 +1,419 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, props, reducers } from 'kea'
+import { forms } from 'kea-forms'
+import type { DeepPartial, DeepPartialMap, FieldName, ValidationErrorType } from 'kea-forms'
+
+import api from 'lib/api'
+import { integrationsLogic } from 'lib/integrations/integrationsLogic'
+import { lemonToast } from 'lib/lemon-ui/LemonToast'
+
+import { IntegrationType } from '~/types'
+
+/**
+ * The `aws-redshift` integration kind covers three backend classes, told apart only by which config
+ * keys the create request carries: `aws_role_arn` picks the role-based one, an access key pair picks
+ * the credentials one, and host/port/user/password picks the plain Postgres-wire one. Each mode
+ * below must send exactly its own keys, or the wrong class handles the request.
+ */
+export type RedshiftAuthMode = 'role' | 'access_key' | 'password'
+
+// Partition suffixes (aws-cn, aws-us-gov) are allowed, matching AWS_ROLE_ARN_RE on the backend.
+const IAM_ROLE_ARN_REGEX = /^arn:aws(-[a-z-]+)?:iam::\d{12}:role\/.+$/
+const SERVERLESS_WORKGROUP_ARN_REGEX = /^arn:aws(-[a-z-]+)?:redshift-serverless:[a-z0-9-]+:\d{12}:workgroup\/.+$/
+
+export interface RedshiftSetupModalLogicProps {
+ isOpen: boolean
+ integration?: IntegrationType | null
+ onComplete: (integrationId?: number) => void
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface redshiftSetupModalLogicValues {
+ authMode: RedshiftAuthMode
+ isRedshiftIntegrationSubmitting: boolean
+ isRedshiftIntegrationValid: boolean
+ redshiftIntegration: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }
+ redshiftIntegrationAllErrors: Record<string, any>
+ redshiftIntegrationChanged: boolean
+ redshiftIntegrationErrors: DeepPartialMap<
+ {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ },
+ ValidationErrorType
+ >
+ redshiftIntegrationHasErrors: boolean
+ redshiftIntegrationManualErrors: Record<string, any>
+ redshiftIntegrationTouched: boolean
+ redshiftIntegrationTouches: Record<string, boolean>
+ redshiftIntegrationValidationErrors: DeepPartialMap<
+ {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ },
+ ValidationErrorType
+ >
+ showRedshiftIntegrationErrors: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface redshiftSetupModalLogicActions {
+ loadIntegrations: () => any // integrationsLogic
+ resetRedshiftIntegration: (values?: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }) => {
+ values?: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }
+ }
+ setAuthMode: (mode: RedshiftAuthMode) => {
+ mode: RedshiftAuthMode
+ }
+ setRedshiftIntegrationManualErrors: (errors: Record<string, any>) => {
+ errors: Record<string, any>
+ }
+ setRedshiftIntegrationValue: (
+ key: FieldName,
+ value: any
+ ) => {
+ name: FieldName
+ value: any
+ }
+ setRedshiftIntegrationValues: (
+ values: DeepPartial<{
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }>
+ ) => {
+ values: DeepPartial<{
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }>
+ }
+ submitRedshiftIntegration: () => {
+ value: boolean
+ }
+ submitRedshiftIntegrationFailure: (
+ error: Error,
+ errors: Record<string, any>
+ ) => {
+ error: Error
+ errors: Record<string, any>
+ }
+ submitRedshiftIntegrationRequest: (redshiftIntegration: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }) => {
+ redshiftIntegration: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }
+ }
+ submitRedshiftIntegrationSuccess: (redshiftIntegration: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }) => {
+ redshiftIntegration: {
+ autoCreate: boolean
+ awsAccessKeyId: string
+ awsRoleArn: string
+ awsSecretAccessKey: string
+ groups: string[]
+ host: string
+ name: string
+ password: string
+ port: number
+ sslMode: string
+ sslRootCert: string
+ user: string
+ useSystemCa: boolean
+ workgroupArn: string
+ }
+ }
+ touchRedshiftIntegrationField: (key: string) => {
+ key: string
+ }
+}
+
+export type redshiftSetupModalLogicType = MakeLogicType<
+ redshiftSetupModalLogicValues,
+ redshiftSetupModalLogicActions,
+ RedshiftSetupModalLogicProps
+>
+
+export const redshiftSetupModalLogic = kea<redshiftSetupModalLogicType>([
+ path(['integrations', 'redshift', 'redshiftSetupModalLogic']),
+ props({} as RedshiftSetupModalLogicProps),
+ connect(() => ({
+ actions: [integrationsLogic, ['loadIntegrations']],
+ })),
+ actions({
+ setAuthMode: (mode: RedshiftAuthMode) => ({ mode }),
+ }),
+ reducers({
+ authMode: [
+ 'role' as RedshiftAuthMode,
+ {
+ setAuthMode: (_, { mode }) => mode,
+ },
+ ],
+ }),
+ forms(({ props, actions, values }) => ({
+ redshiftIntegration: {
+ defaults: {
+ name: '',
+ user: '',
+ awsRoleArn: '',
+ awsAccessKeyId: '',
+ awsSecretAccessKey: '',
+ groups: [] as string[],
+ autoCreate: false as boolean,
+ workgroupArn: '',
+ host: '',
+ port: 5439,
+ password: '',
+ sslMode: 'require',
+ useSystemCa: true as boolean,
+ sslRootCert: '',
+ },
+ errors: ({
+ name,
+ user,
+ awsRoleArn,
+ awsAccessKeyId,
+ awsSecretAccessKey,
+ workgroupArn,
+ host,
+ port,
+ password,
+ sslMode,
+ useSystemCa,
+ sslRootCert,
+ }) => {
+ const isAws = values.authMode !== 'password'
+ return {
+ name: !isAws || name.trim() ? undefined : 'Name is required',
+ user: user.trim() ? undefined : 'User is required',
+ awsRoleArn:
+ values.authMode !== 'role'
+ ? undefined
+ : !awsRoleArn.trim()
+ ? 'IAM role ARN is required'
+ : !IAM_ROLE_ARN_REGEX.test(awsRoleArn.trim())
+ ? 'Enter a valid IAM role ARN, e.g. arn:aws:iam::123456789012:role/my-role'
+ : undefined,
+ awsAccessKeyId:
+ values.authMode !== 'access_key' || awsAccessKeyId.trim()
+ ? undefined
+ : 'Access key ID is required',
+ awsSecretAccessKey:
+ values.authMode !== 'access_key' || awsSecretAccessKey.trim()
+ ? undefined
+ : 'Secret access key is required',
+ workgroupArn:
+ !isAws || !workgroupArn.trim() || SERVERLESS_WORKGROUP_ARN_REGEX.test(workgroupArn.trim())
+ ? undefined
+ : 'Enter a valid workgroup ARN, e.g. arn:aws:redshift-serverless:us-east-1:123456789012:workgroup/my-workgroup',
+ host: isAws || host.trim() ? undefined : 'Host is required',
+ port: isAws || port ? undefined : 'Port is required',
+ password: isAws || password.trim() ? undefined : 'Password is required',
+ sslRootCert:
+ isAws || sslMode === 'require' || useSystemCa || sslRootCert.trim()
+ ? undefined
+ : 'Upload a root certificate, or use the system certificate authorities',
+ }
+ },
+ submit: async () => {
+ const {
+ name,
+ user,
+ awsRoleArn,
+ awsAccessKeyId,
+ awsSecretAccessKey,
+ groups,
+ autoCreate,
+ workgroupArn,
+ host,
+ port,
+ password,
+ sslMode,
+ useSystemCa,
+ sslRootCert,
+ } = values.redshiftIntegration
+
+ const awsConfig = {
+ name,
+ user: user.trim(),
+ auto_create: autoCreate,
+ ...(groups.length ? { groups } : {}),
+ ...(workgroupArn.trim() ? { workgroup_arn: workgroupArn.trim() } : {}),
+ }
+
+ const config =
+ values.authMode === 'role'
+ ? { ...awsConfig, aws_role_arn: awsRoleArn.trim() }
+ : values.authMode === 'access_key'
+ ? {
+ ...awsConfig,
+ aws_access_key_id: awsAccessKeyId.trim(),
+ aws_secret_access_key: awsSecretAccessKey,
+ }
+ : {
+ host: host.trim(),
+ port,
+ user: user.trim(),
+ password,
+ ssl_mode: sslMode,
+ ...(sslMode !== 'require'
+ ? { ssl_root_cert: useSystemCa ? 'system' : sslRootCert }
+ : {}),
+ }
+
+ try {
+ const integration = await api.integrations.create({ kind: 'aws-redshift', config })
+ actions.loadIntegrations()
+ lemonToast.success('Redshift connection created')
+ props.onComplete(integration.id)
+ } catch (error: any) {
+ lemonToast.error(error.detail || 'Failed to create the Redshift connection')
+ throw error
+ }
+ },
+ },
+ })),
+ listeners(({ actions }) => ({
+ setAuthMode: () => {
+ actions.setRedshiftIntegrationValues({
+ awsRoleArn: '',
+ awsAccessKeyId: '',
+ awsSecretAccessKey: '',
+ password: '',
+ sslRootCert: '',
+ })
+ },
+ })),
+])
diff --git a/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts b/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
index b0dcec5510e0..4a747c5510ea 100644
--- a/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
+++ b/frontend/src/scenes/settings/organization/organizationIntegrationsLogic.ts
@@ -16,6 +16,7 @@ export interface organizationIntegrationsLogicValues {
getOrganizationIntegrationsByKind: (
kinds: (
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -91,6 +92,7 @@ export interface organizationIntegrationsLogicActions {
installation_status?: InstallationStatusEnumApi | null | undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -148,6 +150,7 @@ export interface organizationIntegrationsLogicActions {
installation_status?: InstallationStatusEnumApi | null | undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -203,6 +206,7 @@ export interface organizationIntegrationsLogicMeta {
) => (
kinds: (
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts b/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts
index a5d8b29b3341..fa023ee3df8d 100644
--- a/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts
+++ b/frontend/src/scenes/settings/user/personalIntegrationsLogic.ts
@@ -131,6 +131,7 @@ export interface personalIntegrationsLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -191,6 +192,7 @@ export interface personalIntegrationsLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index 47f5b92bb2a3..1aa151541350 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -5606,6 +5606,7 @@ export const INTEGRATION_KINDS = [
'apns',
'postgresql',
'aws-s3',
+ 'aws-redshift',
's3-compatible',
'snowflake',
'youtube-analytics',
@@ -6851,6 +6852,9 @@ export type BatchExportServiceHTTP = {
export type BatchExportServiceRedshift = {
type: 'Redshift'
+ // Credentials live on the linked `aws-redshift` integration. Exports created before integrations
+ // keep their inline user/password.
+ integration?: number
config: {
user: string
password: string
@@ -6859,21 +6863,24 @@ export type BatchExportServiceRedshift = {
database: string
schema: string
table_name: string
- properties_data_type: boolean
+ properties_data_type: 'varchar' | 'super'
mode: 'COPY' | 'INSERT'
- authorization_mode: 'IAMRole' | 'Credentials'
+ // Form-only: derived from the shape of copy_inputs.authorization, never sent to the API.
+ authorization_mode: 'SameConnection' | 'DifferentConnection' | 'IAMRole' | 'Credentials'
copy_inputs: BatchExportServiceRedshiftCopyInputs | null
exclude_events: string[]
include_events: string[]
}
}
+// The two COPY credentials can each reference an `aws-s3` integration by id instead of holding
+// inline keys. `authorization` additionally accepts the ARN of a role attached to the cluster.
export type BatchExportServiceRedshiftCopyInputs = {
s3_bucket: string
s3_key_prefix: string
region_name: string
- bucket_credentials: AWSCredentials
- authorization: string | AWSCredentials
+ bucket_credentials: number | AWSCredentials
+ authorization: number | string | AWSCredentials
}
export type AWSCredentials = {
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 3f2aedd87414..94e8500cdc82 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -3038,6 +3038,7 @@ class IntegrationKind(StrEnum):
APNS = "apns"
POSTGRESQL = "postgresql"
AWS_S3 = "aws-s3"
+ AWS_REDSHIFT = "aws-redshift"
S3_COMPATIBLE = "s3-compatible"
SNOWFLAKE = "snowflake"
YOUTUBE_ANALYTICS = "youtube-analytics"
diff --git a/products/alerts/frontend/logic/alertNotificationLogic.ts b/products/alerts/frontend/logic/alertNotificationLogic.ts
index ec91ef21e97c..4da6fde460c3 100644
--- a/products/alerts/frontend/logic/alertNotificationLogic.ts
+++ b/products/alerts/frontend/logic/alertNotificationLogic.ts
@@ -83,6 +83,7 @@ export interface alertNotificationLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -143,6 +144,7 @@ export interface alertNotificationLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/products/batch_exports/backend/api/batch_export.py b/products/batch_exports/backend/api/batch_export.py
index 96e6f01d3fe9..205951e65b1d 100644
--- a/products/batch_exports/backend/api/batch_export.py
+++ b/products/batch_exports/backend/api/batch_export.py
@@ -736,10 +736,9 @@ class RedshiftDestinationRequestSerializer(serializers.Serializer):
type = serializers.ChoiceField(choices=["Redshift"])
integration_id = serializers.IntegerField(
- required=False,
help_text=(
- "ID of an aws-redshift-kind Integration providing connection credentials. Preferred over "
- "inline credentials. Use the integrations-list MCP tool to find one."
+ "ID of an aws-redshift-kind Integration providing connection credentials. Use the "
+ "integrations-list MCP tool to find one."
),
)
config = RedshiftDestinationConfigSerializer()
@@ -767,9 +766,9 @@ class BatchExportDestinationRequestField(serializers.JSONField):
Only integration-backed destinations (Databricks, AzureBlob, BigQuery, Postgres, AwsS3,
S3Compatible, Snowflake, Redshift) are exposed in the schema. integration_id is required for
- every one of those except Snowflake and Redshift, where inline credentials remain supported for
- the time being. Existing Postgres, Snowflake and Redshift exports created before integrations
- keep their inline credentials. Runtime validation remains
+ every one of those except Snowflake, where inline credentials remain supported for the time
+ being. Existing Postgres, Snowflake and Redshift exports created before integrations keep their
+ inline credentials. Runtime validation remains
`BatchExportDestinationSerializer.validate_destination`.
"""
@@ -929,9 +928,11 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):
# Some credential/connection fields are optional on the dataclass (integration-backed exports
# resolve them at run time), so they must be required here only when no Integration is linked.
# For the S3 family this is only possible when updating an export that predates integrations:
- # creating one without an Integration is rejected in `validate_destination`.
+ # creating one without an Integration is rejected in `validate_destination`. Redshift is
+ # absent for the same reason, and because this check runs first: leaving it in would report a
+ # missing 'user' instead of the missing integration that is the actual problem.
# TODO: remove this code once inline credentials are gone for S3 and integrations are enforced
- # for Snowflake and Redshift
+ # for Snowflake
conditionally_required: set[str] = set()
if attrs.get("integration") is None:
if export_type in S3_FAMILY_TYPES:
@@ -940,8 +941,6 @@ class BatchExportDestinationSerializer(serializers.ModelSerializer):
conditionally_required.add("endpoint_url")
elif export_type == BatchExportDestination.Destination.SNOWFLAKE:
conditionally_required = {"account", "user"}
- elif export_type == BatchExportDestination.Destination.REDSHIFT:
- conditionally_required = {"user", "password", "host"}
for destination_field in destination_fields:
is_required = (
@@ -1606,13 +1605,19 @@ class BatchExportSerializer(serializers.ModelSerializer):
integration = destination_attrs.get("integration")
# Sticky integration: an export that uses one cannot drop back to inline credentials.
- # TODO: remove this guard once integrations are mandatory for Redshift and inline credentials are gone.
+ # TODO: remove this guard once inline credentials are gone.
if instance is not None and instance.destination.integration is not None and integration is None:
raise serializers.ValidationError(
"Cannot remove the integration from a Redshift batch export that uses one. "
"Re-send its `integration` to keep it (or a different one to swap)."
)
+ # New Redshift exports must use an Integration for credentials. Exports created before
+ # integrations existed keep their inline credentials, so only require it on create
+ # (`instance is None`); existing inline-credential exports stay valid when edited.
+ if integration is None and instance is None:
+ raise serializers.ValidationError("Integration is required for Redshift batch exports")
+
if integration is not None:
# (Team ownership is already enforced by the team-scoped `integration` field.)
if integration.kind != Integration.IntegrationKind.AWS_REDSHIFT:
diff --git a/products/batch_exports/backend/tests/api/conftest.py b/products/batch_exports/backend/tests/api/conftest.py
index 6f4936153529..f3436d0045f8 100644
--- a/products/batch_exports/backend/tests/api/conftest.py
+++ b/products/batch_exports/backend/tests/api/conftest.py
@@ -105,6 +105,21 @@ def aws_s3_integration(team, user):
)
+def aws_redshift_integration(team, user):
+ return Integration.objects.create(
+ team=team,
+ kind=Integration.IntegrationKind.AWS_REDSHIFT,
+ integration_id="prod-redshift-role",
+ config={
+ "name": "prod-redshift-role",
+ "aws_role_arn": "arn:aws:iam::123456789012:role/posthog-batch-exports",
+ "user": "awsuser",
+ },
+ created_by=user,
+ )
+
+
@pytest.fixture
def s3_compatible_integration(team, user):
return Integration.objects.create(
diff --git a/products/batch_exports/backend/tests/api/test_create.py b/products/batch_exports/backend/tests/api/test_create.py
index 30834438c372..56ee522ad2b2 100644
--- a/products/batch_exports/backend/tests/api/test_create.py
+++ b/products/batch_exports/backend/tests/api/test_create.py
@@ -805,7 +805,7 @@ def test_creating_batch_export_with_filters(
],
)
def test_create_redshift_batch_export_fails_with_invalid_host(
- client: HttpClient, temporal, organization, team, user, host
+ client: HttpClient, temporal, organization, team, user, host, aws_redshift_integration
):
"""Test creating a BatchExport with Redshift destination validates inputs for 'COPY'.
@@ -816,13 +816,12 @@ def test_create_redshift_batch_export_fails_with_invalid_host(
destination_data = {
"type": "Redshift",
"config": {
- "user": "user",
- "password": "my-password",
"database": "my-db",
"host": host,
"schema": "public",
"table_name": "my_events",
},
+ "integration": aws_redshift_integration.pk,
}
batch_export_data = {
diff --git a/products/batch_exports/backend/tests/api/test_create_redshift.py b/products/batch_exports/backend/tests/api/test_create_redshift.py
index 9a8367a97e8c..4aed311a92e4 100644
--- a/products/batch_exports/backend/tests/api/test_create_redshift.py
+++ b/products/batch_exports/backend/tests/api/test_create_redshift.py
@@ -123,15 +123,13 @@ pytestmark = [
],
)
def test_create_redshift_batch_export_validates_copy_inputs(
- client: HttpClient, mode, copy_inputs, expected_status, temporal, organization, team, user
+ client: HttpClient, mode, copy_inputs, expected_status, temporal, organization, team, user, aws_redshift_integration
):
"""Test creating a BatchExport with Redshift destination validates inputs for 'COPY'."""
destination_data = {
"type": "Redshift",
"config": {
- "user": "user",
- "password": "my-password",
"database": "my-db",
"host": "localhost",
"schema": "public",
@@ -139,6 +137,7 @@ def test_create_redshift_batch_export_validates_copy_inputs(
"mode": mode,
"copy_inputs": copy_inputs,
},
+ "integration": aws_redshift_integration.pk,
}
batch_export_data = {
@@ -163,7 +162,7 @@ def test_create_redshift_batch_export_validates_copy_inputs(
@pytest.mark.parametrize("authorization", [["arn:aws:iam::123456789012:role/my-role"], True, 1.5])
def test_create_redshift_batch_export_rejects_invalid_authorization_type(
- client: HttpClient, authorization, temporal, organization, team, user
+ client: HttpClient, authorization, temporal, organization, team, user, aws_redshift_integration
):
"""Test 'authorization' values that are neither credentials, a role, nor an id are a 400.
@@ -172,8 +171,6 @@ def test_create_redshift_batch_export_rejects_invalid_authorization_type(
destination_data = {
"type": "Redshift",
"config": {
- "user": "user",
- "password": "my-password",
"database": "my-db",
"host": "localhost",
"mode": "COPY",
@@ -185,6 +182,7 @@ def test_create_redshift_batch_export_rejects_invalid_authorization_type(
"authorization": authorization,
},
},
+ "integration": aws_redshift_integration.pk,
}
batch_export_data = {
@@ -200,23 +198,9 @@ def test_create_redshift_batch_export_rejects_invalid_authorization_type(
assert "Authorization for 'COPY'" in response.json()["detail"]
-def create_aws_redshift_role_integration(team, user) -> Integration:
- return Integration.objects.create(
- team=team,
- kind=Integration.IntegrationKind.AWS_REDSHIFT,
- integration_id="prod-redshift-role",
- config={
- "name": "prod-redshift-role",
- "aws_role_arn": "arn:aws:iam::123456789012:role/posthog-batch-exports",
- "user": "awsuser",
- },
- created_by=user,
- )
-
-
-def test_create_redshift_batch_export_with_aws_integration(client: HttpClient, temporal, organization, team, user):
- integration = create_aws_redshift_role_integration(team, user)
-
+def test_create_redshift_batch_export_with_aws_integration(
+ client: HttpClient, temporal, organization, team, user, aws_redshift_integration
+):
batch_export_data = {
"name": "my-integration-backed-redshift-destination",
"interval": "hour",
@@ -225,7 +209,7 @@ def test_create_redshift_batch_export_with_aws_integration(client: HttpClient, t
# No user/password inline: credentials come from the integration. Only the
# cluster endpoint stays in the config.
"config": {"database": "my-db", "host": "8.8.8.8"},
- "integration": integration.pk,
+ "integration": aws_redshift_integration.pk,
},
}
@@ -267,11 +251,19 @@ def test_create_redshift_batch_export_with_plain_integration(client: HttpClient,
[
("wrong_kind", "not a Redshift integration"),
("aws_integration_without_host", "host"),
- ("no_integration_no_credentials", "missing required field"),
+ ("no_integration", "Integration is required for Redshift batch exports"),
],
)
def test_create_redshift_batch_export_validates_integration(
- client: HttpClient, failure, expected_error, temporal, organization, team, user, aws_s3_integration
+ client: HttpClient,
+ failure,
+ expected_error,
+ temporal,
+ organization,
+ team,
+ user,
+ aws_s3_integration,
+ aws_redshift_integration,
):
config: dict = {"database": "my-db"}
integration_pk = None
@@ -279,7 +271,7 @@ def test_create_redshift_batch_export_validates_integration(
if failure == "wrong_kind":
integration_pk = aws_s3_integration.pk
elif failure == "aws_integration_without_host":
- integration_pk = create_aws_redshift_role_integration(team, user).pk
+ integration_pk = aws_redshift_integration.pk
destination_data: dict = {"type": "Redshift", "config": config}
if integration_pk is not None:
@@ -303,7 +295,14 @@ def test_create_redshift_batch_export_validates_integration(
["own_integration", "other_team_integration", "wrong_kind_integration", "nonexistent_integration"],
)
def test_create_redshift_batch_export_validates_copy_integration_ids(
- client: HttpClient, copy_credential_source, temporal, organization, team, user, aws_s3_integration
+ client: HttpClient,
+ copy_credential_source,
+ temporal,
+ organization,
+ team,
+ user,
+ aws_s3_integration,
+ aws_redshift_integration,
):
# These ids live inside `config` rather than the team-scoped `integration` field, so
# tenant scoping is enforced by validation: a foreign or wrong-kind id must 400, not 500.
@@ -326,7 +325,7 @@ def test_create_redshift_batch_export_validates_copy_integration_ids(
integration_id = other_integration.pk
expected_status = status.HTTP_400_BAD_REQUEST
elif copy_credential_source == "wrong_kind_integration":
- integration_id = create_aws_redshift_role_integration(team, user).pk
+ integration_id = aws_redshift_integration.pk
expected_status = status.HTTP_400_BAD_REQUEST
else:
integration_id = 999999
@@ -335,8 +334,6 @@ def test_create_redshift_batch_export_validates_copy_integration_ids(
destination_data = {
"type": "Redshift",
"config": {
- "user": "user",
- "password": "my-password",
"database": "my-db",
"host": "localhost",
"mode": "COPY",
@@ -348,6 +345,7 @@ def test_create_redshift_batch_export_validates_copy_integration_ids(
"authorization": integration_id,
},
},
+ "integration": aws_redshift_integration.pk,
}
batch_export_data = {
diff --git a/products/batch_exports/backend/tests/api/test_update_redshift.py b/products/batch_exports/backend/tests/api/test_update_redshift.py
index cbe28a679b65..5b356ee7aacb 100644
--- a/products/batch_exports/backend/tests/api/test_update_redshift.py
+++ b/products/batch_exports/backend/tests/api/test_update_redshift.py
@@ -18,12 +18,10 @@ pytestmark = [
]
-def create_copy_batch_export(client: HttpClient, team, user, copy_inputs: dict) -> dict:
+def create_copy_batch_export(client: HttpClient, team, user, copy_inputs: dict, integration_pk: int) -> dict:
destination_data = {
"type": "Redshift",
"config": {
- "user": "user",
- "password": "my-password",
"database": "my-db",
"host": "localhost",
"schema": "public",
@@ -31,6 +29,7 @@ def create_copy_batch_export(client: HttpClient, team, user, copy_inputs: dict)
"mode": "COPY",
"copy_inputs": copy_inputs,
},
+ "integration": integration_pk,
}
batch_export_data = {
"name": "my-production-redshift-destination",
@@ -41,13 +40,13 @@ def create_copy_batch_export(client: HttpClient, team, user, copy_inputs: dict)
return create_batch_export_ok(client, team.pk, batch_export_data)
-def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organization, team, user):
+def test_can_patch_redshift_batch_export(
+ client: HttpClient, temporal, organization, team, user, aws_redshift_integration
+):
"""Test we can patch a Redshift batch export preserving credentials."""
destination_data = {
"type": "Redshift",
"config": {
- "user": "user",
- "password": "my-password",
"database": "my-db",
"host": "localhost",
"schema": "public",
@@ -61,6 +60,7 @@ def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organizat
"authorization": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
},
},
+ "integration": aws_redshift_integration.pk,
}
batch_export_data = {
@@ -77,7 +77,8 @@ def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organizat
batch_export_data,
)
- # Updates bucket name, leaves everything else untouched.
+ # Updates bucket name, leaves everything else untouched. The integration is re-sent because an
+ # export that has one cannot drop it, matching what the edit form submits.
new_destination_data = {
"type": "Redshift",
"config": {
@@ -85,6 +86,7 @@ def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organizat
"s3_bucket": "my-new-production-s3-bucket",
},
},
+ "integration": aws_redshift_integration.pk,
}
new_batch_export_data = {
@@ -101,7 +103,7 @@ def test_can_patch_redshift_batch_export(client: HttpClient, temporal, organizat
def test_can_patch_redshift_batch_export_switching_authorization_to_credentials(
- client: HttpClient, temporal, organization, team, user
+ client: HttpClient, temporal, organization, team, user, aws_redshift_integration
):
"""Test an update can switch 'authorization' from an IAM role to inline credentials.
@@ -118,6 +120,7 @@ def test_can_patch_redshift_batch_export_switching_authorization_to_credentials(
"bucket_credentials": {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
"authorization": "arn:aws:iam::123456789012:role/my-role",
},
+ aws_redshift_integration.pk,
)
new_batch_export_data = {
@@ -128,6 +131,7 @@ def test_can_patch_redshift_batch_export_switching_authorization_to_credentials(
"authorization": {"aws_access_key_id": "new-key", "aws_secret_access_key": "new-secret"},
},
},
+ "integration": aws_redshift_integration.pk,
},
}
@@ -140,7 +144,7 @@ def test_can_patch_redshift_batch_export_switching_authorization_to_credentials(
@pytest.mark.parametrize("field_name", ["authorization", "bucket_credentials"])
def test_patching_redshift_batch_export_rejects_switching_copy_integration_to_inline(
- client: HttpClient, temporal, organization, team, user, aws_s3_integration, field_name
+ client: HttpClient, temporal, organization, team, user, aws_s3_integration, aws_redshift_integration, field_name
):
"""Test COPY credentials backed by an integration cannot switch back to inline values."""
batch_export = create_copy_batch_export(
@@ -154,6 +158,7 @@ def test_patching_redshift_batch_export_rejects_switching_copy_integration_to_in
"bucket_credentials": aws_s3_integration.pk,
"authorization": aws_s3_integration.pk,
},
+ aws_redshift_integration.pk,
)
new_batch_export_data = {
@@ -164,6 +169,7 @@ def test_patching_redshift_batch_export_rejects_switching_copy_integration_to_in
field_name: {"aws_access_key_id": "abc123", "aws_secret_access_key": "secret"},
},
},
+ "integration": aws_redshift_integration.pk,
},
}
@@ -173,7 +179,7 @@ def test_patching_redshift_batch_export_rejects_switching_copy_integration_to_in
def test_can_patch_redshift_batch_export_swapping_copy_integration(
- client: HttpClient, temporal, organization, team, user, aws_s3_integration
+ client: HttpClient, temporal, organization, team, user, aws_s3_integration, aws_redshift_integration
):
"""Test COPY credentials backed by an integration can swap to a different integration."""
other_integration = Integration.objects.create(
@@ -195,6 +201,7 @@ def test_can_patch_redshift_batch_export_swapping_copy_integration(
"bucket_credentials": aws_s3_integration.pk,
"authorization": aws_s3_integration.pk,
},
+ aws_redshift_integration.pk,
)
new_batch_export_data = {
@@ -206,6 +213,7 @@ def test_can_patch_redshift_batch_export_swapping_copy_integration(
"authorization": other_integration.pk,
},
},
+ "integration": aws_redshift_integration.pk,
},
}
diff --git a/products/batch_exports/frontend/generated/api.schemas.ts b/products/batch_exports/frontend/generated/api.schemas.ts
index 3b1c111f3fc3..817b692c9bea 100644
--- a/products/batch_exports/frontend/generated/api.schemas.ts
+++ b/products/batch_exports/frontend/generated/api.schemas.ts
@@ -1425,8 +1425,8 @@ export const RedshiftDestinationRequestApiType = {
*/
export interface RedshiftDestinationRequestApi {
type: RedshiftDestinationRequestApiType
- /** ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one. */
- integration_id?: number
+ /** ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one. */
+ integration_id: number
config: RedshiftDestinationConfigApi
}
diff --git a/products/batch_exports/frontend/generated/api.zod.ts b/products/batch_exports/frontend/generated/api.zod.ts
index a5a26ccebc0a..4fba0d4c7c28 100644
--- a/products/batch_exports/frontend/generated/api.zod.ts
+++ b/products/batch_exports/frontend/generated/api.zod.ts
@@ -330,9 +330,8 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zod
type: zod.enum(['Redshift']),
integration_id: zod
.number()
- .optional()
.describe(
- 'ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.'
+ 'ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.'
),
config: zod
.object({
@@ -1028,9 +1027,8 @@ export const BatchExportsUpdateBody = /* @__PURE__ */ zod
type: zod.enum(['Redshift']),
integration_id: zod
.number()
- .optional()
.describe(
- 'ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.'
+ 'ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.'
),
config: zod
.object({
@@ -1481,9 +1479,8 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zod
type: zod.enum(['Redshift']),
integration_id: zod
.number()
- .optional()
.describe(
- 'ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.'
+ 'ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.'
),
config: zod
.object({
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index b7e5c0073c4b..63e725c0a492 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -5112,6 +5112,7 @@ export const IntegrationKindApi = {
Apns: 'apns',
Postgresql: 'postgresql',
AwsS3: 'aws-s3',
+ AwsRedshift: 'aws-redshift',
S3Compatible: 's3-compatible',
Snowflake: 'snowflake',
YoutubeAnalytics: 'youtube-analytics',
diff --git a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
index e4411dd5078e..0ff9241dbc60 100644
--- a/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
+++ b/products/logs/frontend/components/LogsAlerting/logsAlertNotificationLogic.ts
@@ -78,6 +78,7 @@ export interface logsAlertNotificationLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -138,6 +139,7 @@ export interface logsAlertNotificationLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts
index 49419db64fad..59366855986a 100644
--- a/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts
+++ b/products/posthog_ai/frontend/scenes/TaskTracker/taskTrackerSceneLogic.ts
@@ -176,6 +176,7 @@ export interface taskTrackerSceneLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -236,6 +237,7 @@ export interface taskTrackerSceneLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index 1938292befa0..f0e31e97f494 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -4167,6 +4167,7 @@ export const IntegrationKindApi = {
Apns: 'apns',
Postgresql: 'postgresql',
AwsS3: 'aws-s3',
+ AwsRedshift: 'aws-redshift',
S3Compatible: 's3-compatible',
Snowflake: 'snowflake',
YoutubeAnalytics: 'youtube-analytics',
diff --git a/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts b/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts
index 99c5f2b06785..2374aba3591a 100644
--- a/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts
+++ b/products/replay_vision/frontend/replay_scanners/scannerAlertNotificationLogic.ts
@@ -75,6 +75,7 @@ export interface scannerAlertNotificationLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -135,6 +136,7 @@ export interface scannerAlertNotificationLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts b/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts
index d0a6c4551f71..c1dd3151492b 100644
--- a/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts
+++ b/products/visual_review/frontend/scenes/visualReviewSettingsSceneLogic.ts
@@ -67,6 +67,7 @@ export interface visualReviewSettingsSceneLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
@@ -127,6 +128,7 @@ export interface visualReviewSettingsSceneLogicActions {
| undefined
kind:
| 'apns'
+ | 'aws-redshift'
| 'aws-s3'
| 'azure-blob'
| 'bing-ads'
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 53a0edebd857..acb32cf6b13c 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -6742,6 +6742,7 @@ export namespace Schemas {
Apns: 'apns',
Postgresql: 'postgresql',
AwsS3: 'aws-s3',
+ AwsRedshift: 'aws-redshift',
S3Compatible: 's3-compatible',
Snowflake: 'snowflake',
YoutubeAnalytics: 'youtube-analytics',
@@ -13211,8 +13212,8 @@ export namespace Schemas {
*/
export interface RedshiftDestinationRequest {
type: RedshiftDestinationRequestType;
- /** ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one. */
- integration_id?: number;
+ /** ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one. */
+ integration_id: number;
config: RedshiftDestinationConfig;
}
diff --git a/services/mcp/src/generated/batch_exports/api.ts b/services/mcp/src/generated/batch_exports/api.ts
index 43a6975f0190..53fbbf652eac 100644
--- a/services/mcp/src/generated/batch_exports/api.ts
+++ b/services/mcp/src/generated/batch_exports/api.ts
@@ -343,9 +343,8 @@ export const BatchExportsCreateBody = /* @__PURE__ */ zod
type: zod.enum(['Redshift']),
integration_id: zod
.number()
- .optional()
.describe(
- 'ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.'
+ 'ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.'
),
config: zod
.object({
@@ -796,9 +795,8 @@ export const BatchExportsPartialUpdateBody = /* @__PURE__ */ zod
type: zod.enum(['Redshift']),
integration_id: zod
.number()
- .optional()
.describe(
- 'ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.'
+ 'ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.'
),
config: zod
.object({
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json
index 925de3e8aa2f..4ecfb919d4c9 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-create.json
@@ -512,7 +512,7 @@
"type": "object"
},
"integration_id": {
- "description": "ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.",
+ "description": "ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.",
"type": "number"
},
"type": {
@@ -520,7 +520,7 @@
"type": "string"
}
},
- "required": ["type", "config"],
+ "required": ["type", "integration_id", "config"],
"type": "object"
}
],
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json
index fcbfbc7968fb..83d87c2497b0 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/batch-export-update.json
@@ -511,7 +511,7 @@
"type": "object"
},
"integration_id": {
- "description": "ID of an aws-redshift-kind Integration providing connection credentials. Preferred over inline credentials. Use the integrations-list MCP tool to find one.",
+ "description": "ID of an aws-redshift-kind Integration providing connection credentials. Use the integrations-list MCP tool to find one.",
"type": "number"
},
"type": {
@@ -519,7 +519,7 @@
"type": "string"
}
},
- "required": ["type", "config"],
+ "required": ["type", "integration_id", "config"],
"type": "object"
}
],