in src/tasks/SecretsManagerCreateOrUpdateSecret/TaskOperations.ts [36:86]
private async updateSecret(): Promise<void> {
console.log(tl.loc('UpdatingSecret', this.taskParameters.secretNameOrId))
// treat updating descrption et al about the secret as distinct from a value update
if (this.taskParameters.description || this.taskParameters.kmsKeyId) {
const updateMetaRequest: SecretsManager.UpdateSecretRequest = {
SecretId: this.taskParameters.secretNameOrId
}
if (this.taskParameters.description) {
updateMetaRequest.Description = this.taskParameters.description
}
if (this.taskParameters.kmsKeyId) {
updateMetaRequest.KmsKeyId = this.taskParameters.kmsKeyId
}
await this.secretsManagerClient.updateSecret(updateMetaRequest).promise()
}
const updateValueRequest: SecretsManager.PutSecretValueRequest = {
SecretId: this.taskParameters.secretNameOrId
}
if (this.taskParameters.secretValueSource === inlineSecretSource) {
updateValueRequest.SecretString = this.taskParameters.secretValue
} else {
switch (this.taskParameters.secretValueType) {
case stringSecretType: {
updateValueRequest.SecretString = fs.readFileSync(this.taskParameters.secretValueFile, 'utf8')
break
}
case binarySecretType: {
updateValueRequest.SecretBinary = fs.readFileSync(this.taskParameters.secretValueFile)
break
}
}
}
const response = await this.secretsManagerClient.putSecretValue(updateValueRequest).promise()
if (this.taskParameters.arnOutputVariable) {
console.log(tl.loc('SettingArnOutputVariable', this.taskParameters.arnOutputVariable))
tl.setVariable(this.taskParameters.arnOutputVariable, `${response.ARN}`)
}
if (this.taskParameters.versionIdOutputVariable) {
console.log(tl.loc('SettingVersionIdOutputVariable', this.taskParameters.versionIdOutputVariable))
tl.setVariable(this.taskParameters.versionIdOutputVariable, `${response.VersionId}`)
}
}