| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import { z } from "zod";
- import api from "shared/api";
- export const connectToAwsAccount = async ({
- targetArn,
- externalId,
- projectId,
- }: {
- targetArn: string;
- externalId: string;
- projectId: number;
- }): Promise<void> => {
- await api.createAWSIntegration(
- "<token>",
- {
- aws_target_arn: targetArn,
- aws_external_id: externalId,
- },
- { id: projectId }
- );
- };
- export const connectToAzureAccount = async ({
- subscriptionId,
- clientId,
- tenantId,
- servicePrincipalKey,
- projectId,
- }: {
- subscriptionId: string;
- clientId: string;
- tenantId: string;
- servicePrincipalKey: string;
- projectId: number;
- }): Promise<string> => {
- const res = await api.createAzureIntegration(
- "<token",
- {
- azure_subscription_id: subscriptionId,
- azure_client_id: clientId,
- azure_tenant_id: tenantId,
- service_principal_key: servicePrincipalKey,
- },
- { id: projectId }
- );
- const parsed = await z
- .object({
- cloud_provider_credentials_id: z.string(),
- })
- .parseAsync(res.data);
- return parsed.cloud_provider_credentials_id;
- };
- export const connectToGCPAccount = async ({
- projectId,
- serviceAccountKey,
- gcpProjectId,
- }: {
- projectId: number;
- serviceAccountKey: string;
- gcpProjectId: string;
- }): Promise<string> => {
- const res = await api.createGCPIntegration(
- "<token",
- {
- gcp_key_data: serviceAccountKey,
- gcp_project_id: gcpProjectId,
- },
- { project_id: projectId }
- );
- const parsed = await z
- .object({
- cloud_provider_credentials_id: z.string(),
- })
- .parseAsync(res.data);
- return parsed.cloud_provider_credentials_id;
- };
|