Skip to content

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

Improve terraform-cloud secret sync destination variables

carlosmonastyrskia84dddaf6fe4
diff --git a/backend/src/lib/api-docs/constants.ts b/backend/src/lib/api-docs/constants.ts
index 01d769eacd..3124cdb003 100644
--- a/backend/src/lib/api-docs/constants.ts
+++ b/backend/src/lib/api-docs/constants.ts
@@ -1815,8 +1815,10 @@ export const SecretSyncs = {
},
TERRAFORM_CLOUD: {
org: "The ID of the Terraform Cloud org to sync secrets to.",
- destinationName: "The name of the Terraform Cloud variable set / workspace to sync secrets to.",
- destinationId: "The ID of the Terraform Cloud variable set / workspace to sync secrets to.",
+ variableSetName: "The name of the Terraform Cloud Variable Set to sync secrets to.",
+ variableSetId: "The ID of the Terraform Cloud Variable Set to sync secrets to.",
+ workspaceName: "The name of the Terraform Cloud workspace to sync secrets to.",
+ workspaceId: "The ID of the Terraform Cloud workspace to sync secrets to.",
scope: "The Terraform Cloud scope that secrets should be synced to.",
category: "The Terraform Cloud category that secrets should be synced to."
}
diff --git a/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-fns.ts b/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-fns.ts
index af7169c853..4cfd7ec057 100644
--- a/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-fns.ts
+++ b/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-fns.ts
@@ -29,10 +29,10 @@ const getTerraformCloudVariables = async (
let source: TerraformCloudVariable["source"];
if (destinationConfig.scope === TerraformCloudSyncScope.VariableSet) {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.destinationId}/relationships/vars`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.variableSetId}/relationships/vars`;
source = "varset";
} else {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.destinationId}/vars`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.workspaceId}/vars`;
source = "workspace";
}
@@ -92,9 +92,9 @@ const deleteVariable = async (
let url;
if (destinationConfig.scope === TerraformCloudSyncScope.VariableSet) {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.destinationId}/relationships/vars/${variable.id}`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.variableSetId}/relationships/vars/${variable.id}`;
} else {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.destinationId}/vars/${variable.id}`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.workspaceId}/vars/${variable.id}`;
}
await request.delete(url, {
@@ -127,9 +127,9 @@ const createVariable = async (
let url;
if (destinationConfig.scope === TerraformCloudSyncScope.VariableSet) {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.destinationId}/relationships/vars`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.variableSetId}/relationships/vars`;
} else {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.destinationId}/vars`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.workspaceId}/vars`;
}
await request.post(
@@ -177,9 +177,9 @@ const updateVariable = async (
let url;
if (destinationConfig.scope === TerraformCloudSyncScope.VariableSet) {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.destinationId}/relationships/vars/${variable.id}`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/varsets/${destinationConfig.variableSetId}/relationships/vars/${variable.id}`;
} else {
- url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.destinationId}/vars/${variable.id}`;
+ url = `${IntegrationUrls.TERRAFORM_CLOUD_API_URL}/api/v2/workspaces/${destinationConfig.workspaceId}/vars/${variable.id}`;
}
await request.patch(
diff --git a/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-schemas.ts b/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-schemas.ts
index f19a942cd0..359d7f4c58 100644
--- a/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-schemas.ts
+++ b/backend/src/services/secret-sync/terraform-cloud/terraform-cloud-sync-schemas.ts
@@ -20,27 +20,27 @@ const TerraformCloudSyncDestinationConfigSchema = z.discriminatedUnion("scope",
.literal(TerraformCloudSyncScope.VariableSet)
.describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.scope),
org: z.string().min(1, "Org ID is required").describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.org),
- destinationName: z
+ variableSetName: z
.string()
.min(1, "Variable set name is required")
- .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.destinationName),
- destinationId: z
+ .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.variableSetName),
+ variableSetId: z
.string()
.min(1, "Variable set ID is required")
- .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.destinationId),
+ .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.variableSetId),
category: z.nativeEnum(TerraformCloudSyncCategory).describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.category)
}),
z.object({
scope: z.literal(TerraformCloudSyncScope.Workspace).describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.scope),
org: z.string().min(1, "Org ID is required").describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.org),
- destinationName: z
+ workspaceName: z
.string()
.min(1, "Workspace name is required")
- .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.destinationName),
- destinationId: z
+ .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.workspaceName),
+ workspaceId: z
.string()
.min(1, "Workspace ID is required")
- .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.destinationId),
+ .describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.workspaceId),
category: z.nativeEnum(TerraformCloudSyncCategory).describe(SecretSyncs.DESTINATION_CONFIG.TERRAFORM_CLOUD.category)
})
]);
diff --git a/docs/integrations/secret-syncs/terraform-cloud.mdx b/docs/integrations/secret-syncs/terraform-cloud.mdx
index 5de92ac239..80a087d2b6 100644
--- a/docs/integrations/secret-syncs/terraform-cloud.mdx
+++ b/docs/integrations/secret-syncs/terraform-cloud.mdx
@@ -94,8 +94,8 @@ description: "Learn how to configure a Terraform Cloud Sync for Infisical."
},
"destinationConfig": {
"scope": "variable-set",
- "destinationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
- "destinationName": "my-variable-set",
+ "variableSetId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
+ "variableSetName": "my-variable-set",
"org": "my-organization-id",
"category": "env"
}
@@ -149,8 +149,8 @@ description: "Learn how to configure a Terraform Cloud Sync for Infisical."
"destination": "terraform-cloud",
"destinationConfig": {
"scope": "workspace",
- "destinationId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
- "destinationName": "my-workspace",
+ "workspaceId": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
+ "workspaceName": "my-workspace",
"org": "my-organization-id",
"category": "terraform"
}
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/TerraformCloudSyncFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/TerraformCloudSyncFields.tsx
index de97bdba8e..70394cc768 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/TerraformCloudSyncFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncDestinationFields/TerraformCloudSyncFields.tsx
@@ -39,8 +39,10 @@ export const TerraformCloudSyncFields = () => {
<SecretSyncConnectionField
onChange={() => {
setValue("destinationConfig.org", "");
- setValue("destinationConfig.destinationId", "");
- setValue("destinationConfig.destinationName", "");
+ setValue("destinationConfig.variableSetId", "");
+ setValue("destinationConfig.workspaceId", "");
+ setValue("destinationConfig.variableSetName", "");
+ setValue("destinationConfig.workspaceName", "");
}}
/>
<Controller
@@ -60,8 +62,10 @@ export const TerraformCloudSyncFields = () => {
onChange(
(option as SingleValue<TTerraformCloudConnectionOrganization>)?.id ?? null
);
- setValue("destinationConfig.destinationId", "");
- setValue("destinationConfig.destinationName", "");
+ setValue("destinationConfig.variableSetId", "");
+ setValue("destinationConfig.workspaceId", "");
+ setValue("destinationConfig.variableSetName", "");
+ setValue("destinationConfig.workspaceName", "");
}}
options={organizations}
placeholder="Select an organization..."
@@ -155,8 +159,10 @@ export const TerraformCloudSyncFields = () => {
value={value}
onValueChange={(val) => {
onChange(val);
- setValue("destinationConfig.destinationId", "");
- setValue("destinationConfig.destinationName", "");
+ setValue("destinationConfig.variableSetId", "");
+ setValue("destinationConfig.workspaceId", "");
+ setValue("destinationConfig.variableSetName", "");
+ setValue("destinationConfig.workspaceName", "");
}}
className="w-full border border-mineshaft-500 capitalize"
position="popper"
@@ -174,7 +180,7 @@ export const TerraformCloudSyncFields = () => {
/>
{currentScope === TerraformCloudSyncScope.VariableSet && (
<Controller
- name="destinationConfig.destinationId"
+ name="destinationConfig.variableSetId"
control={control}
render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl isError={Boolean(error)} errorText={error?.message} label="Variable Set">
@@ -189,9 +195,9 @@ export const TerraformCloudSyncFields = () => {
onChange(selectedOption?.id ?? null);
if (selectedOption) {
- setValue("destinationConfig.destinationName", selectedOption.name);
+ setValue("destinationConfig.variableSetName", selectedOption.name);
} else {
- setValue("destinationConfig.destinationName", "");
+ setValue("destinationConfig.variableSetName", "");
}
}}
options={variableSets}
@@ -205,7 +211,7 @@ export const TerraformCloudSyncFields = () => {
)}
{currentScope === TerraformCloudSyncScope.Workspace && (
<Controller
- name="destinationConfig.destinationId"
+ name="destinationConfig.workspaceId"
control={control}
render={({ field: { value, onChange }, fieldState: { error } }) => (
<FormControl isError={Boolean(error)} errorText={error?.message} label="Workspace">
@@ -219,9 +225,9 @@ export const TerraformCloudSyncFields = () => {
onChange(selectedOption?.id ?? null);
if (selectedOption) {
- setValue("destinationConfig.destinationName", selectedOption.name);
+ setValue("destinationConfig.workspaceName", selectedOption.name);
} else {
- setValue("destinationConfig.destinationName", "");
+ setValue("destinationConfig.workspaceName", "");
}
}}
options={workspaces}
diff --git a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/TerraformCloudSyncReviewFields.tsx b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/TerraformCloudSyncReviewFields.tsx
index 5123986340..614e3e1807 100644
--- a/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/TerraformCloudSyncReviewFields.tsx
+++ b/frontend/src/components/secret-syncs/forms/SecretSyncReviewFields/TerraformCloudSyncReviewFields.tsx
@@ -8,7 +8,8 @@ import { SecretSync } from "@app/hooks/api/secretSyncs";
export const TerraformCloudSyncReviewFields = () => {
const { watch } = useFormContext<TSecretSyncForm & { destination: SecretSync.TerraformCloud }>();
const orgId = watch("destinationConfig.org");
- const destinationName = watch("destinationConfig.destinationName");
+ const variableSetName = watch("destinationConfig.variableSetName");
+ const workspaceName = watch("destinationConfig.workspaceName");
const scope = watch("destinationConfig.scope");
const category = watch("destinationConfig.category");
@@ -16,10 +17,10 @@ export const TerraformCloudSyncReviewFields = () => {
<>
<GenericFieldLabel label="Organization">{orgId}</GenericFieldLabel>
{scope === TerraformCloudSyncScope.VariableSet && (
- <GenericFieldLabel label="Variable Set">{destinationName}</GenericFieldLabel>
+ <GenericFieldLabel label="Variable Set">{variableSetName}</GenericFieldLabel>
)}
{scope === TerraformCloudSyncScope.Workspace && (
- <GenericFieldLabel label="Workspace">{destinationName}</GenericFieldLabel>
+ <GenericFieldLabel label="Workspace">{workspaceName}</GenericFieldLabel>
)}
<GenericFieldLabel label="Category">{category}</GenericFieldLabel>
</>
diff --git a/frontend/src/components/secret-syncs/forms/schemas/terraform-cloud-destination-schema.ts b/frontend/src/components/secret-syncs/forms/schemas/terraform-cloud-destination-schema.ts
index 51d904d104..d818fd29a5 100644
--- a/frontend/src/components/secret-syncs/forms/schemas/terraform-cloud-destination-schema.ts
+++ b/frontend/src/components/secret-syncs/forms/schemas/terraform-cloud-destination-schema.ts
@@ -14,15 +14,15 @@ export const TerraformCloudSyncDestinationSchema = BaseSecretSyncSchema().merge(
z.object({
scope: z.literal(TerraformCloudSyncScope.VariableSet),
org: z.string().trim().min(1, "Organization required"),
- destinationId: z.string().trim().min(1, "Variable Set required"),
- destinationName: z.string().trim().min(1, "Variable set name required"),
+ variableSetId: z.string().trim().min(1, "Variable Set required"),
+ variableSetName: z.string().trim().min(1, "Variable set name required"),
category: z.nativeEnum(TerraformCloudSyncCategory)
}),
z.object({
scope: z.literal(TerraformCloudSyncScope.Workspace),
org: z.string().trim().min(1, "Organization required"),
- destinationId: z.string().trim().min(1, "Workspace required"),
- destinationName: z.string().trim().min(1, "Workspace name required"),
+ workspaceId: z.string().trim().min(1, "Workspace required"),
+ workspaceName: z.string().trim().min(1, "Workspace name required"),
category: z.nativeEnum(TerraformCloudSyncCategory)
})
])
diff --git a/frontend/src/hooks/api/secretSyncs/types/terraform-cloud-sync.ts b/frontend/src/hooks/api/secretSyncs/types/terraform-cloud-sync.ts
index ffa224133e..a8ab23aeb5 100644
--- a/frontend/src/hooks/api/secretSyncs/types/terraform-cloud-sync.ts
+++ b/frontend/src/hooks/api/secretSyncs/types/terraform-cloud-sync.ts
@@ -11,15 +11,15 @@ export type TTerraformCloudSync = TRootSecretSync & {
scope: TerraformCloudSyncScope.VariableSet;
org: string;
category: TerraformCloudSyncCategory;
- destinationId: string;
- destinationName: string;
+ variableSetId: string;
+ variableSetName: string;
}
| {
scope: TerraformCloudSyncScope.Workspace;
org: string;
category: TerraformCloudSyncCategory;
- destinationId: string;
- destinationName: string;
+ workspaceId: string;
+ workspaceName: string;
};
connection: {
app: AppConnection.TerraformCloud;
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 6c0fef9cb0..e6d92352a4 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
@@ -1,3 +1,4 @@
+import { TerraformCloudSyncScope } from "@app/hooks/api/appConnections/terraform-cloud";
import { SecretSync, TSecretSync } from "@app/hooks/api/secretSyncs";
import {
GitHubSyncScope,
@@ -75,7 +76,11 @@ export const getSecretSyncDestinationColValues = (secretSync: TSecretSync) => {
break;
case SecretSync.TerraformCloud:
primaryText = destinationConfig.org;
- secondaryText = destinationConfig.destinationName;
+ if (destinationConfig.scope === TerraformCloudSyncScope.VariableSet) {
+ secondaryText = destinationConfig.variableSetName;
+ } else {
+ secondaryText = destinationConfig.workspaceName;
+ }
break;
default:
throw new Error(`Unhandled Destination Col Values ${destination}`);
diff --git a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/TerraformCloudSyncDestinationCol.tsx b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/TerraformCloudSyncDestinationCol.tsx
index 3498c0e1c3..c584cd3dcb 100644
--- a/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/TerraformCloudSyncDestinationCol.tsx
+++ b/frontend/src/pages/secret-manager/SecretSyncDetailsByIDPage/components/SecretSyncDestinationSection/TerraformCloudSyncDestinationCol.tsx
@@ -20,7 +20,7 @@ export const TerraformCloudSyncDestinationSection = ({ secretSync }: Props) => {
<>
<GenericFieldLabel label="Organization">{destinationConfig.org}</GenericFieldLabel>
<GenericFieldLabel label="Variable Set">
- {destinationConfig.destinationName}
+ {destinationConfig.variableSetName}
</GenericFieldLabel>
</>
);
@@ -29,9 +29,7 @@ export const TerraformCloudSyncDestinationSection = ({ secretSync }: Props) => {
Components = (
<>
<GenericFieldLabel label="Organization">{destinationConfig.org}</GenericFieldLabel>
- <GenericFieldLabel label="Workspace">
- {destinationConfig.destinationName}
- </GenericFieldLabel>
+ <GenericFieldLabel label="Workspace">{destinationConfig.workspaceName}</GenericFieldLabel>
</>
);
break;