Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

feat(secret-sync): support for syncing to vercel team with all custom environments enabled

Daniel8426541593cc
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 036afc7ed7..4f993ab128 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -2961,7 +2961,8 @@ export const SecretSyncs = {
teamId: "The ID of the Vercel team to sync secrets to.",
teamName:
"The name of the team to sync the secrets to. This is an optional field only intended for display purposes.",
- targetEnvironments: "An optional array of Vercel environments to add shared environment variables to.",
+ targetEnvironments:
+ 'An array of Vercel environments to add shared environment variables to. Include the value "all-custom-environments" to apply variables to all custom environments in the team.',
targetProjects: "An optional array of Vercel projects to add shared environment variables to.",
sensitive:
"Whether to create Vercel environment variables as Sensitive (cannot be read back). Not allowed when targeting the Development environment."
diff --git a/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts b/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts
index de6f2f127d..5de25d4577 100644
--- a/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts
+++ b/backend/src/services/secret-sync/vercel/vercel-sync-enums.ts
@@ -6,7 +6,8 @@ export enum VercelSyncScope {
export const VercelEnvironmentType = {
Development: "development",
Preview: "preview",
- Production: "production"
+ Production: "production",
+ AllCustomEnvironments: "all-custom-environments"
} as const;
export type VercelEnvironment = (typeof VercelEnvironmentType)[keyof typeof VercelEnvironmentType];
diff --git a/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts b/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts
index 05f24af57b..d2e13cb432 100644
--- a/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts
+++ b/backend/src/services/secret-sync/vercel/vercel-sync-fns.ts
@@ -451,13 +451,22 @@ const createTeamSharedEnvVar = async (
});
}
- // Vercel does not support sensitive env vars in the Development environment, so strip it
- // from the target list when sensitive is enabled.
- const effectiveTargetEnvironments = destinationConfig.sensitive
- ? destinationConfig.targetEnvironments?.filter((env) => env !== VercelEnvironmentType.Development)
- : destinationConfig.targetEnvironments;
+ // Derive applyToAllCustomEnvironments from the sentinel value in targetEnvironments.
+ const applyToAllCustomEnvironments = destinationConfig.targetEnvironments?.includes(
+ VercelEnvironmentType.AllCustomEnvironments
+ );
+
+ // Strip the sentinel and, when sensitive is enabled, the Development environment before
+ // sending to Vercel — neither is a valid value in the `target` array.
+ const effectiveTargetEnvironments = destinationConfig.targetEnvironments
+ ?.filter((env) => env !== VercelEnvironmentType.AllCustomEnvironments)
+ .filter((env) => !destinationConfig.sensitive || env !== VercelEnvironmentType.Development);
- if (destinationConfig.sensitive && (!effectiveTargetEnvironments || effectiveTargetEnvironments.length === 0)) {
+ if (
+ destinationConfig.sensitive &&
+ !applyToAllCustomEnvironments &&
+ (!effectiveTargetEnvironments || effectiveTargetEnvironments.length === 0)
+ ) {
throw new SecretSyncError({
message:
"Marking secrets as sensitive in Vercel is not supported for development environments. Add another target environment or disable Sensitive.",
@@ -476,7 +485,8 @@ const createTeamSharedEnvVar = async (
evs: [{ key, value }],
type: destinationConfig.sensitive ? "sensitive" : "encrypted",
...(effectiveTargetEnvironments?.length ? { target: effectiveTargetEnvironments } : {}),
- ...(destinationConfig.targetProjects !== undefined ? { projectId: destinationConfig.targetProjects } : {})
+ ...(destinationConfig.targetProjects !== undefined ? { projectId: destinationConfig.targetProjects } : {}),
+ applyToAllCustomEnvironments: Boolean(applyToAllCustomEnvironments)
},
{
headers: {
@@ -524,13 +534,22 @@ const updateTeamSharedEnvVar = async (
}
const isExistingSensitive = envVar.type === "sensitive";
- const effectiveTargetEnvironments =
- destinationConfig.sensitive || isExistingSensitive
- ? destinationConfig.targetEnvironments?.filter((env) => env !== VercelEnvironmentType.Development)
- : destinationConfig.targetEnvironments;
+
+ // Derive applyToAllCustomEnvironments from the sentinel value in targetEnvironments.
+ const applyToAllCustomEnvironments = destinationConfig.targetEnvironments?.includes(
+ VercelEnvironmentType.AllCustomEnvironments
+ );
+
+ // Strip the sentinel and, when sensitive is enabled, the Development environment.
+ const effectiveTargetEnvironments = destinationConfig.targetEnvironments
+ ?.filter((env) => env !== VercelEnvironmentType.AllCustomEnvironments)
+ .filter(
+ (env) => !(destinationConfig.sensitive || isExistingSensitive) || env !== VercelEnvironmentType.Development
+ );
if (
(destinationConfig.sensitive || isExistingSensitive) &&
+ !applyToAllCustomEnvironments &&
(!effectiveTargetEnvironments || effectiveTargetEnvironments.length === 0)
) {
throw new SecretSyncError({
@@ -552,7 +571,8 @@ const updateTeamSharedEnvVar = async (
[envVar.id]: {
value,
...(effectiveTargetEnvironments?.length ? { target: effectiveTargetEnvironments } : {}),
- ...(destinationConfig.targetProjects !== undefined ? { projectId: destinationConfig.targetProjects } : {})
+ ...(destinationConfig.targetProjects !== undefined ? { projectId: destinationConfig.targetProjects } : {}),
+ applyToAllCustomEnvironments: Boolean(applyToAllCustomEnvironments)
}
}
},
@@ -660,16 +680,17 @@ export const VercelSyncFns = {
const hasValueChanged = existingVar.value !== secretMap[key].value;
- // Sensitive secrets cannot target Development in Vercel, so compare against
- // the effective targets that will actually be sent.
+ // Sensitive secrets cannot target Development in Vercel, and the AllCustomEnvironments
+ // sentinel is not a real Vercel target — strip both before comparing against the existing var.
const isSensitive = sensitive || existingVar.type === "sensitive";
- const effectiveTargets = isSensitive
- ? targetEnvironments?.filter((env) => env !== VercelEnvironmentType.Development)
- : targetEnvironments;
+ const effectiveTargets = targetEnvironments
+ ?.filter((env) => env !== VercelEnvironmentType.AllCustomEnvironments)
+ .filter((env) => !isSensitive || env !== VercelEnvironmentType.Development);
+ const existingTarget = existingVar.target ?? [];
const hasTargetChanged = effectiveTargets?.length
- ? existingVar.target.length !== effectiveTargets.length ||
- !effectiveTargets.every((env) => existingVar.target.includes(env))
+ ? existingTarget.length !== effectiveTargets.length ||
+ !effectiveTargets.every((env) => existingTarget.includes(env))
: false;
const hasProjectsChanged = targetProjects
@@ -677,7 +698,10 @@ export const VercelSyncFns = {
!targetProjects.every((pid) => existingVar.projectId?.includes(pid))
: false;
- if (hasValueChanged || hasTargetChanged || hasProjectsChanged) {
+ const desiredAllCustom = targetEnvironments?.includes(VercelEnvironmentType.AllCustomEnvironments) ?? false;
+ const hasAllCustomChanged = desiredAllCustom !== (existingVar.applyToAllCustomEnvironments ?? false);
+
+ if (hasValueChanged || hasTargetChanged || hasProjectsChanged || hasAllCustomChanged) {
await updateTeamSharedEnvVar(secretSync, existingVar, secretMap[key].value);
}
}
diff --git a/backend/src/services/secret-sync/vercel/vercel-sync-types.ts b/backend/src/services/secret-sync/vercel/vercel-sync-types.ts
index 6d29e517ec..aef68f5dfd 100644
--- a/backend/src/services/secret-sync/vercel/vercel-sync-types.ts
+++ b/backend/src/services/secret-sync/vercel/vercel-sync-types.ts
@@ -44,8 +44,9 @@ export interface VercelSharedEnvVar {
key: string;
value: string;
type: string;
- target: string[];
+ target?: string[];
projectId?: string[];
+ applyToAllCustomEnvironments?: boolean;
decrypted?: boolean;
comment?: string;
createdAt?: number;
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx
index 9633e0decc..67b99a4c71 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/VercelSyncFields.tsx
@@ -20,12 +20,17 @@ import {
import { TSecretSyncForm } from "../schemas";
-const vercelEnvironments = [
+const standardVercelEnvironments = [
{ name: "Development", slug: "development" },
{ name: "Preview", slug: "preview" },
{ name: "Production", slug: "production" }
] as const;
+const teamVercelEnvironments = [
+ ...standardVercelEnvironments,
+ { name: "All Custom Environments", slug: "all-custom-environments" }
+] as const;
+
export const VercelSyncFields = () => {
const { control, watch, setValue } = useFormContext<
TSecretSyncForm & { destination: SecretSync.Vercel }
@@ -71,7 +76,7 @@ export const VercelSyncFields = () => {
}, [allApps, teamId]);
const environmentOptions = useMemo(() => {
- return vercelEnvironments
+ return standardVercelEnvironments
.map((env): { key: string; type: string; name: string } => ({
key: env.slug,
type: env.slug,
@@ -187,13 +192,15 @@ export const VercelSyncFields = () => {
>
<FilterableSelect
isMulti
- value={vercelEnvironments.filter((env) => (value || []).includes(env.slug))}
+ value={teamVercelEnvironments.filter((env) => (value || []).includes(env.slug))}
onChange={(option) =>
onChange(
- (option as MultiValue<(typeof vercelEnvironments)[number]>).map((o) => o.slug)
+ (option as MultiValue<(typeof teamVercelEnvironments)[number]>).map(
+ (o) => o.slug
+ )
)
}
- options={vercelEnvironments}
+ options={teamVercelEnvironments}
placeholder="Select target environments..."
getOptionLabel={(option) => option.name}
getOptionValue={(option) => option.slug}
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx
index a82686c1f1..48d1b901ee 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/VercelSyncReviewFields.tsx
@@ -48,7 +48,13 @@ export const VercelSyncReviewFields = () => {
<GenericFieldLabel label="Scope">Team</GenericFieldLabel>
<GenericFieldLabel label="Vercel Team">{selectedTeam?.name}</GenericFieldLabel>
<GenericFieldLabel label="Target Environments">
- {targetEnvironments?.join(", ")}
+ {targetEnvironments
+ ?.map((env) =>
+ env === VercelEnvironmentType.AllCustomEnvironments
+ ? "All Custom Environments"
+ : env.charAt(0).toUpperCase() + env.slice(1)
+ )
+ .join(", ")}
</GenericFieldLabel>
<GenericFieldLabel label="Target Projects">
{selectedProjects?.map((project) => project?.name).join(", ")}
diff --git a/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts b/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts
index 2655d547b1..d29081aa72 100644
--- a/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts
+++ b/frontend/src/hooks/api/secretSyncs/types/vercel-sync.ts
@@ -10,7 +10,8 @@ export enum VercelSyncScope {
export const VercelEnvironmentType = {
Development: "development",
Preview: "preview",
- Production: "production"
+ Production: "production",
+ AllCustomEnvironments: "all-custom-environments"
} as const;
export type VercelEnvironment = (typeof VercelEnvironmentType)[keyof typeof VercelEnvironmentType];
diff --git a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts
index 974fcc1051..2208b53538 100644
--- a/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts
+++ b/frontend/src/pages/secret-manager/IntegrationsListPage/components/SecretSyncsTab/SecretSyncTable/helpers/index.ts
@@ -10,7 +10,10 @@ import { GitLabSyncScope } from "@app/hooks/api/secretSyncs/types/gitlab-sync";
import { HumanitecSyncScope } from "@app/hooks/api/secretSyncs/types/humanitec-sync";
import { OctopusDeploySyncScope } from "@app/hooks/api/secretSyncs/types/octopus-deploy-sync";
import { RenderSyncScope } from "@app/hooks/api/secretSyncs/types/render-sync";
-import { VercelSyncScope } from "@app/hooks/api/secretSyncs/types/vercel-sync";
+import {
+ VercelEnvironmentType,
+ VercelSyncScope
+} from "@app/hooks/api/secretSyncs/types/vercel-sync";
// This functional ensures parity across what is displayed in the destination column
// and the values used when search filtering
@@ -96,7 +99,13 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
case SecretSync.Vercel:
if (destinationConfig.scope === VercelSyncScope.Team) {
primaryText = destinationConfig.teamName || destinationConfig.teamId;
- secondaryText = destinationConfig.targetEnvironments.join(", ");
+ secondaryText = destinationConfig.targetEnvironments
+ .map((env) =>
+ env === VercelEnvironmentType.AllCustomEnvironments
+ ? "All Custom Environments"
+ : env.charAt(0).toUpperCase() + env.slice(1)
+ )
+ .join(", ");
} else {
primaryText = destinationConfig.appName || destinationConfig.app;
secondaryText = destinationConfig.env;
diff --git a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx
index 1365c06d7a..edf5056ec2 100644
--- a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx
+++ b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/VercelSyncDestinationSection.tsx
@@ -43,7 +43,13 @@ export const VercelSyncDestinationSection = ({ secretSync }: Props) => {
<GenericFieldLabel label="Scope">Team</GenericFieldLabel>
<GenericFieldLabel label="Vercel Team">{selectedTeam?.name}</GenericFieldLabel>
<GenericFieldLabel label="Target Environments">
- {destinationConfig.targetEnvironments?.join(", ")}
+ {destinationConfig.targetEnvironments
+ ?.map((env) =>
+ env === VercelEnvironmentType.AllCustomEnvironments
+ ? "All Custom Environments"
+ : env.charAt(0).toUpperCase() + env.slice(1)
+ )
+ .join(", ")}
</GenericFieldLabel>
<GenericFieldLabel label="Target Projects">
{selectedProjects?.map((project) => project?.name).join(", ")}