import { useEffect, useState } from "react"; import Head from "next/head"; import Image from "next/image"; import Link from "next/link"; import { useRouter } from "next/router"; import { faArrowUpRightFromSquare, faBookOpen, faBugs, faCircleInfo } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { motion } from "framer-motion"; import queryString from "query-string"; import { useCreateIntegration } from "@app/hooks/api"; import { useGetIntegrationAuthAwsKmsKeys } from "@app/hooks/api/integrationAuth/queries"; import { IntegrationMappingBehavior } from "@app/hooks/api/integrations/types"; import { Badge, Button, Card, CardTitle, FormControl, Input, Select, SelectItem, Switch, Tab, TabList, TabPanel, Tabs } from "../../../components/v2"; import { useGetIntegrationAuthById } from "../../../hooks/api/integrationAuth"; import { useGetWorkspaceById } from "../../../hooks/api/workspace"; enum TabSections { Connection = "connection", Options = "options" } const awsRegions = [ { name: "US East (Ohio)", slug: "us-east-2" }, { name: "US East (N. Virginia)", slug: "us-east-1" }, { name: "US West (N. California)", slug: "us-west-1" }, { name: "US West (Oregon)", slug: "us-west-2" }, { name: "Africa (Cape Town)", slug: "af-south-1" }, { name: "Asia Pacific (Hong Kong)", slug: "ap-east-1" }, { name: "Asia Pacific (Hyderabad)", slug: "ap-south-2" }, { name: "Asia Pacific (Jakarta)", slug: "ap-southeast-3" }, { name: "Asia Pacific (Melbourne)", slug: "ap-southeast-4" }, { name: "Asia Pacific (Mumbai)", slug: "ap-south-1" }, { name: "Asia Pacific (Osaka)", slug: "ap-northeast-3" }, { name: "Asia Pacific (Seoul)", slug: "ap-northeast-2" }, { name: "Asia Pacific (Singapore)", slug: "ap-southeast-1" }, { name: "Asia Pacific (Sydney)", slug: "ap-southeast-2" }, { name: "Asia Pacific (Tokyo)", slug: "ap-northeast-1" }, { name: "Canada (Central)", slug: "ca-central-1" }, { name: "Europe (Frankfurt)", slug: "eu-central-1" }, { name: "Europe (Ireland)", slug: "eu-west-1" }, { name: "Europe (London)", slug: "eu-west-2" }, { name: "Europe (Milan)", slug: "eu-south-1" }, { name: "Europe (Paris)", slug: "eu-west-3" }, { name: "Europe (Spain)", slug: "eu-south-2" }, { name: "Europe (Stockholm)", slug: "eu-north-1" }, { name: "Europe (Zurich)", slug: "eu-central-2" }, { name: "Middle East (Bahrain)", slug: "me-south-1" }, { name: "Middle East (UAE)", slug: "me-central-1" }, { name: "South America (Sao Paulo)", slug: "sa-east-1" }, { name: "AWS GovCloud (US-East)", slug: "us-gov-east-1" }, { name: "AWS GovCloud (US-West)", slug: "us-gov-west-1" } ]; const mappingBehaviors = [ { label: "Many to One (All Infisical secrets will be mapped to a single AWS secret)", value: IntegrationMappingBehavior.MANY_TO_ONE }, { label: "One to One - (Each Infisical secret will be mapped to its own AWS secret)", value: IntegrationMappingBehavior.ONE_TO_ONE } ]; export default function AWSSecretManagerCreateIntegrationPage() { const router = useRouter(); const { mutateAsync } = useCreateIntegration(); const { integrationAuthId } = queryString.parse(router.asPath.split("?")[1]); const { data: workspace } = useGetWorkspaceById(localStorage.getItem("projectData.id") ?? ""); const { data: integrationAuth, isLoading: isintegrationAuthLoading } = useGetIntegrationAuthById( (integrationAuthId as string) ?? "" ); const [selectedSourceEnvironment, setSelectedSourceEnvironment] = useState(""); const [secretPath, setSecretPath] = useState("/"); const [selectedAWSRegion, setSelectedAWSRegion] = useState(""); const [selectedMappingBehavior, setSelectedMappingBehavior] = useState( IntegrationMappingBehavior.MANY_TO_ONE ); const [targetSecretName, setTargetSecretName] = useState(""); const [targetSecretNameErrorText, setTargetSecretNameErrorText] = useState(""); const [tagKey, setTagKey] = useState(""); const [tagValue, setTagValue] = useState(""); const [kmsKeyId, setKmsKeyId] = useState(""); const [secretPrefix, setSecretPrefix] = useState(""); // const [path, setPath] = useState(''); // const [pathErrorText, setPathErrorText] = useState(''); const [isLoading, setIsLoading] = useState(false); const [shouldTag, setShouldTag] = useState(false); const { data: integrationAuthAwsKmsKeys, isLoading: isIntegrationAuthAwsKmsKeysLoading } = useGetIntegrationAuthAwsKmsKeys({ integrationAuthId: String(integrationAuthId), region: selectedAWSRegion }); useEffect(() => { if (workspace) { setSelectedSourceEnvironment(workspace.environments[0].slug); setSelectedAWSRegion(awsRegions[0].slug); } }, [workspace]); // const isValidAWSPath = (path: string) => { // const pattern = /^\/[\w./]+\/$/; // return pattern.test(path) && path.length <= 2048; // } const handleButtonClick = async () => { try { if (!selectedMappingBehavior) { return; } if ( selectedMappingBehavior === IntegrationMappingBehavior.MANY_TO_ONE && targetSecretName.trim() === "" ) { setTargetSecretName("Secret name cannot be blank"); return; } if (!integrationAuth?.id) return; setIsLoading(true); await mutateAsync({ integrationAuthId: integrationAuth?.id, isActive: true, app: targetSecretName.trim(), sourceEnvironment: selectedSourceEnvironment, region: selectedAWSRegion, secretPath, metadata: { ...(shouldTag ? { secretAWSTag: [ { key: tagKey, value: tagValue } ] } : {}), ...(secretPrefix && { secretPrefix }), ...(kmsKeyId && { kmsKeyId }), mappingBehavior: selectedMappingBehavior } }); setIsLoading(false); setTargetSecretNameErrorText(""); router.push(`/integrations/${localStorage.getItem("projectData.id")}`); } catch (err) { setIsLoading(false); console.error(err); } }; return integrationAuth && workspace && selectedSourceEnvironment && !isIntegrationAuthAwsKmsKeysLoading ? (
Set Up AWS Secrets Manager Integration
AWS logo
AWS Secrets Manager Integration
Docs
Connection Options
setSecretPath(evt.target.value)} placeholder="Provide a path, default is /" /> {selectedMappingBehavior === IntegrationMappingBehavior.MANY_TO_ONE && ( setTargetSecretName(e.target.value)} /> )}
setShouldTag(!shouldTag)} isChecked={shouldTag} > Tag in AWS Secrets Manager
{shouldTag && (
setTagKey(e.target.value)} /> setTagValue(e.target.value)} />
)} setSecretPrefix(e.target.value)} placeholder="INFISICAL_" />
{" "} Pro Tip
After creating an integration, your secrets will start syncing immediately. This might cause an unexpected override of current secrets in AWS Secrets Manager with secrets from Infisical.
) : (
Set Up AWS Secrets Manager Integration {isintegrationAuthLoading || isIntegrationAuthAwsKmsKeysLoading ? ( infisical loading indicator ) : (

Something went wrong. Please contact{" "} support@infisical.com {" "} if the issue persists.

)}
); } AWSSecretManagerCreateIntegrationPage.requireAuth = true;