Terraform Cloud integration

This commit is contained in:
Andrew Atimapre
2023-07-08 00:07:38 +01:00
parent e95eef2071
commit 3e975dc4f0
9 changed files with 105 additions and 1 deletions
+43
View File
@@ -38,6 +38,8 @@ import {
INTEGRATION_RENDER_API_URL,
INTEGRATION_SUPABASE,
INTEGRATION_SUPABASE_API_URL,
INTEGRATION_TERRAFORM_CLOUD,
INTEGRATION_TERRAFORM_CLOUD_API_URL,
INTEGRATION_TRAVISCI,
INTEGRATION_TRAVISCI_API_URL,
INTEGRATION_VERCEL,
@@ -185,6 +187,14 @@ const syncSecrets = async ({
accessToken,
});
break;
case INTEGRATION_TERRAFORM_CLOUD:
await syncSecretsTerraformCloud({
integration,
secrets,
accessId,
accessToken,
});
break;
case INTEGRATION_HASHICORP_VAULT:
await syncSecretsHashiCorpVault({
integration,
@@ -1806,6 +1816,39 @@ const syncSecretsCheckly = async ({
}
};
/**
* Sync/push [secrets] to Terraform Cloud projects with id [integration.appId]
* @param {Object} obj
* @param {IIntegration} obj.integration - integration details
* @param {Object} obj.secrets - secrets to push to integration (object where keys are secret keys and values are secret values)
* @param {String} obj.accessToken - access token for Terraform Cloud integration
*/
const syncSecretsTerraformCloud = async ({
integration,
secrets,
accessId,
accessToken,
}: {
integration: IIntegration;
secrets: any;
accessId: string | null;
accessToken: string;
}) => {
await standardRequest.put(
`${INTEGRATION_TERRAFORM_CLOUD_API_URL}/api/v2/organizations/${accessId}/${integration.app}`,
Object.keys(secrets).map((key) => ({
key,
value: secrets[key],
})),
{
headers: {
Authorization: `Bearer ${accessToken}`,
Accept: "application/json",
},
}
);
};
/**
* Sync/push [secrets] to HashiCorp Vault path
* @param {Object} obj