Skip to content

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

fix: resolved ssm failing for empty secret in 1-1 mapping

=4aaba3ef9f47
diff --git a/backend/src/services/integration-auth/integration-sync-secret.ts b/backend/src/services/integration-auth/integration-sync-secret.ts
index c9711c7df9..d9f0306e63 100644
--- a/backend/src/services/integration-auth/integration-sync-secret.ts
+++ b/backend/src/services/integration-auth/integration-sync-secret.ts
@@ -9,6 +9,7 @@
import {
CreateSecretCommand,
+ DeleteSecretCommand,
DescribeSecretCommand,
GetSecretValueCommand,
ResourceNotFoundException,
@@ -899,12 +900,21 @@ const syncSecretsAWSSecretManager = async ({
}
if (!isEqual(secretToCompare, secretValue)) {
- await secretsManager.send(
- new UpdateSecretCommand({
- SecretId: secretId,
- SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue)
- })
- );
+ if (secretValue) {
+ await secretsManager.send(
+ new UpdateSecretCommand({
+ SecretId: secretId,
+ SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue)
+ })
+ );
+ // delete it
+ } else {
+ await secretsManager.send(
+ new DeleteSecretCommand({
+ SecretId: secretId
+ })
+ );
+ }
}
const secretAWSTag = metadata.secretAWSTag as { key: string; value: string }[] | undefined;
@@ -989,16 +999,21 @@ const syncSecretsAWSSecretManager = async ({
} catch (err) {
// case 1: when AWS manager can't find the specified secret
if (err instanceof ResourceNotFoundException && secretsManager) {
- await secretsManager.send(
- new CreateSecretCommand({
- Name: secretId,
- SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue),
- ...(metadata.kmsKeyId && { KmsKeyId: metadata.kmsKeyId }),
- Tags: metadata.secretAWSTag
- ? metadata.secretAWSTag.map((tag: { key: string; value: string }) => ({ Key: tag.key, Value: tag.value }))
- : []
- })
- );
+ if (secretValue) {
+ await secretsManager.send(
+ new CreateSecretCommand({
+ Name: secretId,
+ SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue),
+ ...(metadata.kmsKeyId && { KmsKeyId: metadata.kmsKeyId }),
+ Tags: metadata.secretAWSTag
+ ? metadata.secretAWSTag.map((tag: { key: string; value: string }) => ({
+ Key: tag.key,
+ Value: tag.value
+ }))
+ : []
+ })
+ );
+ }
// case 2: something unexpected went wrong, so we'll throw the error to reflect the error in the integration sync status
} else {
throw err;