: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(batch-exports): resolve S3 export credentials only from integrations (#90958)
Ross17c1ed50eae7
diff --git a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py b/products/batch_exports/backend/temporal/destinations/s3_batch_export.pyindex 12092dc13f94..d3258ced3fbd 100644--- a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/s3_batch_export.py@@ -93,6 +93,8 @@ NON_RETRYABLE_ERROR_TYPES = ("UnsupportedCompressionError",# Invalid S3 credentials"InvalidCredentialsError",+ # The export has no linked Integration to authenticate with+ "MissingIntegrationError",# The linked Integration was deleted or doesn't belong to the team"S3IntegrationNotFoundError",# The linked Integration is the wrong kind or has invalid/missing credentials@@ -141,6 +143,16 @@ class S3IntegrationNotFoundError(Exception):super().__init__(f"S3 integration with ID '{integration_id}' not found for team '{team_id}'")+class MissingIntegrationError(Exception):+ """Raised when an S3-family export has no Integration to authenticate with."""++ def __init__(self, batch_export_id: str | None):+ super().__init__(+ f"S3 batch export '{batch_export_id}' has no integration. "+ "Link an AWS S3 or S3-compatible integration to it to resume exporting."+ )++async def _get_s3_integration(integration_id: int, team_id: int) -> AWSS3RoleBasedIntegration | AWSS3Integration | S3CompatibleIntegration:@@ -608,8 +620,9 @@ async def insert_into_s3_activity_from_stage(inputs: S3InsertInputs) -> S3BatchEraise UnsupportedCompressionError(inputs.compression)async with Heartbeater():- # Integration-backed exports resolve credentials at run time; legacy exports carry them inline.- # TODO: require integration+ # Customer exports resolve credentials from their linked integration. The internal+ # file-download export instead passes a `refresh_credentials` coroutine that mints+ # scoped credentials for PostHog's own bucket. One of the two must be present.endpoint_url = inputs.endpoint_urlrefresh_credentials = inputs.refresh_credentials@@ -685,17 +698,10 @@ async def insert_into_s3_activity_from_stage(inputs: S3InsertInputs) -> S3BatchE)endpoint_url = integration.endpoint_url+ elif refresh_credentials is not None:+ credentials = await refresh_credentials()else:- if refresh_credentials is not None:- credentials = await refresh_credentials()- else:- if not inputs.aws_access_key_id or not inputs.aws_secret_access_key:- raise InvalidCredentialsError("AWS access key ID and secret access key cannot be empty")- credentials = AWSCredentials(- aws_access_key_id=inputs.aws_access_key_id,- aws_secret_access_key=inputs.aws_secret_access_key,- aws_session_token=inputs.aws_session_token,- )+ raise MissingIntegrationError(inputs.batch_export_id)external_logger = EXTERNAL_LOGGER.bind()external_logger.info(diff --git a/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py b/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.pyindex ac3a2223a7a0..f6b8af9c1b4d 100644--- a/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py+++ b/products/batch_exports/backend/tests/temporal/backfills/test_backfill_workflow.py@@ -106,16 +106,15 @@ async def run_backfill_workflow(@pytest_asyncio.fixture-async def failing_s3_batch_export(ateam, temporal_client):+async def failing_s3_batch_export(ateam, temporal_client, s3_compatible_integration):destination_data = {- "type": "S3",+ "type": "S3Compatible",+ # Credentials and the endpoint URL come from the integration.+ "integration_id": s3_compatible_integration.id,"config": {"bucket_name": "this-bucket-doesn't-exist","region": "us-east-1","prefix": "/",- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,"file_format": "invalid",},}@@ -161,7 +160,9 @@ async def object_storage_client(bucket_name):@pytest_asyncio.fixture-async def events_batch_export(temporal_client, ateam, clickhouse_client, bucket_name, object_storage_client):+async def events_batch_export(+ temporal_client, ateam, clickhouse_client, bucket_name, object_storage_client, s3_compatible_integration+):"""Create a batch export for testing backfill info (defaults to events model)."""await truncate_events(clickhouse_client)@@ -169,14 +170,13 @@ async def events_batch_export(temporal_client, ateam, clickhouse_client, bucket_team_id=ateam.pk,name="events-export-for-backfill-info",destination_data={- "type": "S3",+ "type": "S3Compatible",+ # Credentials and the endpoint URL come from the integration.+ "integration_id": s3_compatible_integration.id,"config": {"bucket_name": bucket_name,"region": "us-east-1","prefix": "posthog-events/",- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,},},interval="hour",diff --git a/products/batch_exports/backend/tests/temporal/conftest.py b/products/batch_exports/backend/tests/temporal/conftest.pyindex b1bcbfb03d1b..baa78deab3ee 100644--- a/products/batch_exports/backend/tests/temporal/conftest.py+++ b/products/batch_exports/backend/tests/temporal/conftest.py@@ -18,6 +18,7 @@ from temporalio.testing import ActivityEnvironmentfrom posthog.conftest import create_clickhouse_tablesfrom posthog.models import Organization, Team+from posthog.models.integration import Integrationfrom posthog.models.team.util import delete_batch_exportsfrom posthog.models.utils import uuid7from posthog.temporal.common.clickhouse import ClickHouseClient@@ -136,6 +137,21 @@ async def another_ateam(aorganization):await sync_to_async(team.delete)()+@pytest_asyncio.fixture+async def s3_compatible_integration(ateam):+ """An s3-compatible Integration pointing at the local object storage used by these tests."""+ return await Integration.objects.acreate(+ team_id=ateam.pk,+ kind=Integration.IntegrationKind.S3_COMPATIBLE,+ integration_id=f"object-storage-{uuid.uuid4()}",+ config={"name": "object-storage-test", "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT},+ sensitive_config={+ "aws_access_key_id": "object_storage_root_user",+ "aws_secret_access_key": "object_storage_root_password",+ },+ )++@pytest.fixturedef activity_environment():"""Return a testing temporal ActivityEnvironment."""diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py b/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.pyindex 6fc17848e033..fd7013916dc0 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/conftest.py@@ -6,13 +6,12 @@ import collections.abcimport pytest-from django.conf import settings-import aioboto3import structlogimport pytest_asyncioimport botocore.exceptions+from posthog.models.integration import Integrationfrom posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_exportfrom products.batch_exports.backend.tests.temporal.utils.s3 import aws_role, create_test_client, delete_all_from_s3@@ -108,6 +107,21 @@ async def object_storage_client(bucket_name):await object_storage_client.delete_bucket(Bucket=bucket_name)+@pytest_asyncio.fixture+async def gcs_integration(ateam):+ """An s3-compatible Integration pointing at GCS, using the AWS credentials in the environment."""+ return await Integration.objects.acreate(+ team_id=ateam.pk,+ kind=Integration.IntegrationKind.S3_COMPATIBLE,+ integration_id=f"gcs-{uuid.uuid4()}",+ config={"name": "gcs-test", "endpoint_url": "https://storage.googleapis.com"},+ sensitive_config={+ "aws_access_key_id": os.getenv("AWS_ACCESS_KEY_ID"),+ "aws_secret_access_key": os.getenv("AWS_SECRET_ACCESS_KEY"),+ },+ )++@pytest_asyncio.fixtureasync def s3_compatible_batch_export(ateam,@@ -118,16 +132,16 @@ async def s3_compatible_batch_export(exclude_events,temporal_client,file_format,+ s3_compatible_integration,):destination_data = {"type": "S3Compatible",+ # Credentials and the endpoint URL come from the integration.+ "integration_id": s3_compatible_integration.id,"config": {"bucket_name": bucket_name,"region": "us-east-1","prefix": s3_key_prefix,- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT,"compression": compression,"exclude_events": exclude_events,"file_format": file_format,diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity.pyindex 5b7f035bf595..fe47966ed5c6 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity.py@@ -2,8 +2,6 @@ import uuidimport pytest-from django.conf import settings-from temporalio.testing._activity import ActivityEnvironmentfrom posthog.models.integration import Integration, IntegrationError@@ -16,6 +14,7 @@ from products.batch_exports.backend.temporal.destinations.s3_batch_export importSUPPORTED_COMPRESSIONS,S3InsertInputs,_get_s3_integration,+ insert_into_s3_activity_from_stage,s3_default_fields,)from products.batch_exports.backend.tests.temporal.destinations.s3.utils import (@@ -48,6 +47,31 @@ async def test_get_s3_integration_rejects_wrong_kind(ateam):assert "kind='slack'" in str(exc_info.value)+async def test_insert_into_s3_activity_fails_without_an_integration(activity_environment, ateam):+ """An export with no linked integration has no way to authenticate, so it fails without retrying.++ Not sure if this is reachable in practice, but it tests the activity's error handling in case it+ ever does occur.+ """+ insert_inputs = S3InsertInputs(+ bucket_name="my-bucket",+ region="us-east-1",+ prefix="events/",+ team_id=ateam.pk,+ data_interval_start="2023-04-20T14:00:00+00:00",+ data_interval_end="2023-04-20T15:00:00+00:00",+ integration_id=None,+ batch_export_id=str(uuid.uuid4()),+ destination_default_fields=s3_default_fields(),+ )++ result = await activity_environment.run(insert_into_s3_activity_from_stage, insert_inputs)++ # Non-retryable errors are returned on the result rather than raised, so the run fails once.+ assert result.error is not None+ assert result.error.type == "MissingIntegrationError"++@pytest.mark.parametrize("compression", COMPRESSION_EXTENSIONS.keys(), indirect=True)@pytest.mark.parametrize("model", TEST_S3_MODELS)@pytest.mark.parametrize("file_format", FILE_FORMAT_EXTENSIONS.keys())@@ -64,6 +88,7 @@ async def test_insert_into_s3_activity_puts_data_into_s3(model: BatchExportModel | BatchExportSchema | None,generate_test_data,ateam,+ s3_compatible_integration,):"""Test that the insert_into_s3_activity_from_stage function ends up with data into S3.@@ -100,9 +125,7 @@ async def test_insert_into_s3_activity_puts_data_into_s3(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id="object_storage_root_user",- aws_secret_access_key="object_storage_root_password",- endpoint_url=settings.OBJECT_STORAGE_ENDPOINT,+ integration_id=s3_compatible_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,@@ -169,21 +192,11 @@ async def test_insert_into_s3_activity_resolves_credentials_from_integration(model: BatchExportModel,generate_test_data,ateam,+ s3_compatible_integration,):"""An integration-backed S3-compatible export resolves credentials and endpoint_url from thelinked Integration at run time, with none of them present on the activity inputs."""- integration = await Integration.objects.acreate(- team_id=ateam.pk,- kind=Integration.IntegrationKind.S3_COMPATIBLE,- integration_id="object-storage-test",- config={"name": "object-storage-test", "endpoint_url": settings.OBJECT_STORAGE_ENDPOINT},- sensitive_config={- "aws_access_key_id": "object_storage_root_user",- "aws_secret_access_key": "object_storage_root_password",- },- )-prefix = str(uuid.uuid4())insert_inputs = S3InsertInputs(@@ -194,7 +207,7 @@ async def test_insert_into_s3_activity_resolves_credentials_from_integration(data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),# No inline credentials or endpoint_url — both are resolved from the integration.- integration_id=integration.id,+ integration_id=s3_compatible_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,@@ -243,6 +256,7 @@ async def test_insert_into_s3_activity_with_exclude_events(model: BatchExportModel | BatchExportSchema | None,generate_test_data,ateam,+ s3_compatible_integration,):"""Test that the insert_into_s3_activity_from_stage function does not export events that match the exclude_eventsfilter.@@ -266,9 +280,7 @@ async def test_insert_into_s3_activity_with_exclude_events(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id="object_storage_root_user",- aws_secret_access_key="object_storage_root_password",- endpoint_url=settings.OBJECT_STORAGE_ENDPOINT,+ integration_id=s3_compatible_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,@@ -335,6 +347,7 @@ async def test_insert_into_s3_activity_puts_splitted_files_into_s3(data_interval_end,model: BatchExportModel,ateam,+ s3_compatible_integration,):"""Test that the insert_into_s3_activity_from_stage function splits up large files intomultiple parts based on the max file size configuration.@@ -385,9 +398,7 @@ async def test_insert_into_s3_activity_puts_splitted_files_into_s3(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id="object_storage_root_user",- aws_secret_access_key="object_storage_root_password",- endpoint_url=settings.OBJECT_STORAGE_ENDPOINT,+ integration_id=s3_compatible_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,@@ -481,6 +492,7 @@ async def test_insert_into_s3_activity_fails_on_invalid_file_format(data_interval_end,model: BatchExportModel,ateam,+ s3_compatible_integration,):"""Test the insert_into_s3_activity_from_stage_activity function returns an error when an invalid file format is requested."""@@ -491,9 +503,7 @@ async def test_insert_into_s3_activity_fails_on_invalid_file_format(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id="object_storage_root_user",- aws_secret_access_key="object_storage_root_password",- endpoint_url=settings.OBJECT_STORAGE_ENDPOINT,+ integration_id=s3_compatible_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,@@ -524,6 +534,7 @@ async def test_insert_into_s3_activity_fails_on_invalid_compression(data_interval_end,model: BatchExportModel,ateam,+ s3_compatible_integration,):"""Test the insert_into_s3_activity_from_stage activity returns an error when an invalid compression is requested."""@@ -534,9 +545,7 @@ async def test_insert_into_s3_activity_fails_on_invalid_compression(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id="object_storage_root_user",- aws_secret_access_key="object_storage_root_password",- endpoint_url=settings.OBJECT_STORAGE_ENDPOINT,+ integration_id=s3_compatible_integration.id,compression=compression,exclude_events=exclude_events,file_format="JSONLines",diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity_with_gcs_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity_with_gcs_bucket.pyindex 8b47834ce000..d27d62f2a2b0 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity_with_gcs_bucket.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_activity_with_gcs_bucket.py@@ -69,6 +69,7 @@ async def test_insert_into_s3_activity_puts_data_into_gcs(model: BatchExportModel | BatchExportSchema | None,generate_test_data,ateam,+ gcs_integration,):"""Test that the insert_into_s3_activity_from_stage function ends up with data into GCS.@@ -105,9 +106,7 @@ async def test_insert_into_s3_activity_puts_data_into_gcs(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),- aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),- endpoint_url="https://storage.googleapis.com",+ integration_id=gcs_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,@@ -174,6 +173,7 @@ async def test_insert_into_s3_activity_puts_splitted_files_into_gcs(data_interval_end,model: BatchExportModel,ateam,+ gcs_integration,):"""Test that the insert_into_s3_activity_from_stage function splits up large files intomultiple parts based on the max file size configuration.@@ -224,9 +224,7 @@ async def test_insert_into_s3_activity_puts_splitted_files_into_gcs(team_id=ateam.pk,data_interval_start=data_interval_start.isoformat(),data_interval_end=data_interval_end.isoformat(),- aws_access_key_id=os.getenv("AWS_ACCESS_KEY_ID"),- aws_secret_access_key=os.getenv("AWS_SECRET_ACCESS_KEY"),- endpoint_url="https://storage.googleapis.com",+ integration_id=gcs_integration.id,compression=compression,exclude_events=exclude_events,file_format=file_format,diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.pyindex 70cd844d5f4b..d2b40c9e6279 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_error_handling.py@@ -63,6 +63,7 @@ async def test_s3_export_workflow_handles_unexpected_insert_activity_errors(batch_export_id=str(s3_compatible_batch_export.id),data_interval_end=data_interval_end.isoformat(),interval=interval,+ integration_id=s3_compatible_batch_export.destination.integration_id,**s3_compatible_batch_export.destination.config,)@@ -126,6 +127,7 @@ async def test_s3_export_workflow_handles_insert_activity_non_retryable_errors(batch_export_id=str(s3_compatible_batch_export.id),data_interval_end=data_interval_end.isoformat(),interval=interval,+ integration_id=s3_compatible_batch_export.destination.integration_id,**s3_compatible_batch_export.destination.config,)@@ -182,6 +184,7 @@ async def test_s3_export_workflow_handles_cancellation(ateam, s3_compatible_batcbatch_export_id=str(s3_compatible_batch_export.id),data_interval_end=data_interval_end.isoformat(),interval=interval,+ integration_id=s3_compatible_batch_export.destination.integration_id,**s3_compatible_batch_export.destination.config,)@@ -285,6 +288,7 @@ async def test_s3_export_workflow_with_request_timeouts(batch_export_model=batch_export_model,batch_export_schema=batch_export_schema,interval=interval,+ integration_id=s3_compatible_batch_export.destination.integration_id,**s3_compatible_batch_export.destination.config,)diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.pyindex 7ba3ca13a86a..1c66ddb54260 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_gcs_bucket.py@@ -55,17 +55,17 @@ async def gcs_batch_export(exclude_events,temporal_client,file_format,+ gcs_integration,):assert bucket_namedestination_data = {"type": "S3Compatible",+ # Credentials and the endpoint URL come from the integration.+ "integration_id": gcs_integration.id,"config": {"bucket_name": bucket_name,"region": "us-east-1","prefix": s3_key_prefix,- "aws_access_key_id": os.getenv("AWS_ACCESS_KEY_ID"),- "aws_secret_access_key": os.getenv("AWS_SECRET_ACCESS_KEY"),- "endpoint_url": "https://storage.googleapis.com","compression": compression,"exclude_events": exclude_events,"file_format": file_format,@@ -132,6 +132,7 @@ async def test_s3_export_workflow_with_gcs_bucket_with_various_file_formats(model=model,ateam=ateam,batch_export_id=str(gcs_batch_export.id),+ integration_id=gcs_batch_export.destination.integration_id,s3_destination_config=gcs_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_local_object_storage.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_local_object_storage.pyindex 92ce906ade69..4f8566c06514 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_local_object_storage.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_local_object_storage.py@@ -55,6 +55,7 @@ async def test_s3_export_workflow_with_local_object_storage_with_various_models(model=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -95,6 +96,7 @@ async def test_s3_export_workflow_with_local_object_storage_with_various_compresmodel=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -134,6 +136,7 @@ async def test_s3_export_workflow_with_local_object_storage_with_exclude_events(model=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -190,6 +193,7 @@ async def test_s3_export_workflow_backfill_earliest_persons_with_local_object_stmodel=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -229,6 +233,7 @@ async def test_s3_export_workflow_with_local_object_storage_without_events(model=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -272,6 +277,7 @@ async def test_s3_export_workflow_with_legacy_s3_destination_type(model=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -319,6 +325,7 @@ async def test_s3_export_workflow_with_local_object_storage_and_custom_key_prefimodel=model,ateam=ateam,batch_export_id=str(s3_compatible_batch_export.id),+ integration_id=s3_compatible_batch_export.destination.integration_id,s3_destination_config=s3_compatible_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.pyindex b09cc8699b11..20cc1da76a4f 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/test_workflow_with_s3_bucket.py@@ -1,10 +1,12 @@import os+import uuidimport pytestimport aioboto3import pytest_asyncio+from posthog.models.integration import Integrationfrom posthog.temporal.tests.utils.models import acreate_batch_export, adelete_batch_exportfrom products.batch_exports.backend.service import BatchExportModel, BatchExportSchema@@ -58,14 +60,24 @@ async def s3_batch_export(encryption,file_format,):+ integration = await Integration.objects.acreate(+ team_id=ateam.pk,+ kind=Integration.IntegrationKind.AWS_S3,+ integration_id=f"aws-s3-{uuid.uuid4()}",+ config={"name": "aws-s3-test"},+ sensitive_config={+ "aws_access_key_id": os.getenv("AWS_ACCESS_KEY_ID"),+ "aws_secret_access_key": os.getenv("AWS_SECRET_ACCESS_KEY"),+ },+ )destination_data = {"type": "AwsS3",+ # Credentials come from the integration.+ "integration_id": integration.id,"config": {"bucket_name": bucket_name,"region": "us-east-1","prefix": s3_key_prefix,- "aws_access_key_id": os.getenv("AWS_ACCESS_KEY_ID"),- "aws_secret_access_key": os.getenv("AWS_SECRET_ACCESS_KEY"),"compression": compression,"exclude_events": exclude_events,"encryption": encryption,@@ -136,6 +148,7 @@ async def test_s3_export_workflow_with_s3_bucket_with_various_intervals_and_modemodel=model,ateam=ateam,batch_export_id=str(s3_batch_export.id),+ integration_id=s3_batch_export.destination.integration_id,s3_destination_config=s3_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,@@ -181,6 +194,7 @@ async def test_s3_export_workflow_with_s3_bucket_with_various_file_formats(model=model,ateam=ateam,batch_export_id=str(s3_batch_export.id),+ integration_id=s3_batch_export.destination.integration_id,s3_destination_config=s3_batch_export.destination.config,interval=interval,data_interval_start=data_interval_start,diff --git a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.pyindex 65617c0a480a..d2fe00a99a1c 100644--- a/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py+++ b/products/batch_exports/backend/tests/temporal/destinations/s3/utils.py@@ -329,6 +329,7 @@ async def run_s3_batch_export_workflow(backfill_details: BackfillDetails | None = None,expect_no_data: bool = False,destination_type: str = "S3",+ integration_id: int | None = None,):"""Run the S3 batch export workflow and assert it completes successfully.@@ -372,6 +373,7 @@ async def run_s3_batch_export_workflow(batch_export_model=batch_export_model,batch_export_schema=batch_export_schema,backfill_details=backfill_details,+ integration_id=integration_id,**s3_destination_config,)workflow_inputs = S3BatchExportInputs(**dataclasses.asdict(per_destination_inputs))