mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-06 13:27:22 +00:00
Merge pull request #2559 from akhilmhdh/fix/ssm-integration-1-1
fix: resolved ssm failing for empty secret in 1-1 mapping
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
CreateSecretCommand,
|
CreateSecretCommand,
|
||||||
|
DeleteSecretCommand,
|
||||||
DescribeSecretCommand,
|
DescribeSecretCommand,
|
||||||
GetSecretValueCommand,
|
GetSecretValueCommand,
|
||||||
ResourceNotFoundException,
|
ResourceNotFoundException,
|
||||||
@@ -899,12 +900,21 @@ const syncSecretsAWSSecretManager = async ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!isEqual(secretToCompare, secretValue)) {
|
if (!isEqual(secretToCompare, secretValue)) {
|
||||||
await secretsManager.send(
|
if (secretValue) {
|
||||||
new UpdateSecretCommand({
|
await secretsManager.send(
|
||||||
SecretId: secretId,
|
new UpdateSecretCommand({
|
||||||
SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue)
|
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;
|
const secretAWSTag = metadata.secretAWSTag as { key: string; value: string }[] | undefined;
|
||||||
@@ -989,16 +999,21 @@ const syncSecretsAWSSecretManager = async ({
|
|||||||
} catch (err) {
|
} catch (err) {
|
||||||
// case 1: when AWS manager can't find the specified secret
|
// case 1: when AWS manager can't find the specified secret
|
||||||
if (err instanceof ResourceNotFoundException && secretsManager) {
|
if (err instanceof ResourceNotFoundException && secretsManager) {
|
||||||
await secretsManager.send(
|
if (secretValue) {
|
||||||
new CreateSecretCommand({
|
await secretsManager.send(
|
||||||
Name: secretId,
|
new CreateSecretCommand({
|
||||||
SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue),
|
Name: secretId,
|
||||||
...(metadata.kmsKeyId && { KmsKeyId: metadata.kmsKeyId }),
|
SecretString: typeof secretValue === "string" ? secretValue : JSON.stringify(secretValue),
|
||||||
Tags: metadata.secretAWSTag
|
...(metadata.kmsKeyId && { KmsKeyId: metadata.kmsKeyId }),
|
||||||
? metadata.secretAWSTag.map((tag: { key: string; value: string }) => ({ Key: tag.key, Value: tag.value }))
|
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
|
// case 2: something unexpected went wrong, so we'll throw the error to reflect the error in the integration sync status
|
||||||
} else {
|
} else {
|
||||||
throw err;
|
throw err;
|
||||||
|
|||||||
Reference in New Issue
Block a user