diff --git a/backend/src/server/routes/v1/integration-router.ts b/backend/src/server/routes/v1/integration-router.ts index c1fcd6d1d0..40141e2c09 100644 --- a/backend/src/server/routes/v1/integration-router.ts +++ b/backend/src/server/routes/v1/integration-router.ts @@ -9,6 +9,7 @@ import { getTelemetryDistinctId } from "@app/server/lib/telemetry"; import { verifyAuth } from "@app/server/plugins/auth/verify-auth"; import { AuthMode } from "@app/services/auth/auth-type"; import { IntegrationMetadataSchema } from "@app/services/integration/integration-schema"; +import { Integrations } from "@app/services/integration-auth/integration-list"; import { PostHogEventTypes, TIntegrationCreatedEvent } from "@app/services/telemetry/telemetry-types"; import {} from "../sanitizedSchemas"; @@ -206,9 +207,18 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => { id: req.params.integrationId }); - if (integration.integration === "aws-secret-manager") { - // Fetch additional AWS integration details - const awsRoleDetails = await server.services.integration.getIntegrationAWSAssumeRoleArn({ + if (integration.region) { + integration.metadata = { + ...(integration.metadata || {}), + region: integration.region + }; + } + + if ( + integration.integration === Integrations.AWS_SECRET_MANAGER || + integration.integration === Integrations.AWS_PARAMETER_STORE + ) { + const awsRoleDetails = await server.services.integration.getIntegrationAWSIamRole({ actorId: req.permission.id, actor: req.permission.type, actorAuthMethod: req.permission.authMethod, @@ -216,22 +226,12 @@ export const registerIntegrationRouter = async (server: FastifyZodProvider) => { id: req.params.integrationId }); - if (integration.metadata) { + if (awsRoleDetails) { integration.metadata = { - ...integration.metadata, - awsRegion: integration.region, - awsIamRole: awsRoleDetails.role - }; - } else { - integration.metadata = { - awsRegion: integration.region, + ...(integration.metadata || {}), awsIamRole: awsRoleDetails.role }; } - } else { - integration.metadata = { - region: integration.region - }; } return { integration }; diff --git a/backend/src/services/integration/integration-service.ts b/backend/src/services/integration/integration-service.ts index 18808f3a0c..1db10405d7 100644 --- a/backend/src/services/integration/integration-service.ts +++ b/backend/src/services/integration/integration-service.ts @@ -262,7 +262,7 @@ export const integrationServiceFactory = ({ type: KmsDataKey.SecretManager, projectId: integration.projectId }); - let awsIamRole; + let awsIamRole: string | null = null; if (integrationAuth.encryptedAwsAssumeIamRoleArn) { const awsAssumeRoleArn = secretManagerDecryptor({ cipherTextBlob: Buffer.from(integrationAuth.encryptedAwsAssumeIamRoleArn) @@ -370,7 +370,7 @@ export const integrationServiceFactory = ({ deleteIntegration, listIntegrationByProject, getIntegration, - getIntegrationAWSAssumeRoleArn: getIntegrationAWSIamRole, + getIntegrationAWSIamRole, syncIntegration }; }; diff --git a/frontend/src/hooks/api/integrations/types.ts b/frontend/src/hooks/api/integrations/types.ts index 353c030e53..17e7265d69 100644 --- a/frontend/src/hooks/api/integrations/types.ts +++ b/frontend/src/hooks/api/integrations/types.ts @@ -59,7 +59,6 @@ export type TIntegration = { shouldEnableDelete?: boolean; awsIamRole?: string; - awsRegion?: string; region?: string; }; }; diff --git a/frontend/src/views/IntegrationsPage/IntegrationDetailsPage/components/IntegrationSettingsSection.tsx b/frontend/src/views/IntegrationsPage/IntegrationDetailsPage/components/IntegrationSettingsSection.tsx index 535f957460..ee30e39684 100644 --- a/frontend/src/views/IntegrationsPage/IntegrationDetailsPage/components/IntegrationSettingsSection.tsx +++ b/frontend/src/views/IntegrationsPage/IntegrationDetailsPage/components/IntegrationSettingsSection.tsx @@ -28,7 +28,6 @@ const metadataMappings: Record