private async createSecret()

in src/tasks/SecretsManagerCreateOrUpdateSecret/TaskOperations.ts [88:128]


    private async createSecret(): Promise<void> {
        console.log(tl.loc('SecretNotFoundAutoCreating'))

        const request: SecretsManager.CreateSecretRequest = {
            Name: this.taskParameters.secretNameOrId,
            KmsKeyId: this.taskParameters.kmsKeyId
        }

        if (this.taskParameters.description) {
            request.Description = this.taskParameters.description
        }
        if (this.taskParameters.secretValueSource === inlineSecretSource) {
            request.SecretString = this.taskParameters.secretValue
        } else {
            switch (this.taskParameters.secretValueType) {
                case stringSecretType:
                    request.SecretString = fs.readFileSync(this.taskParameters.secretValueFile, 'utf8')
                    break

                case binarySecretType:
                    request.SecretBinary = fs.readFileSync(this.taskParameters.secretValueFile)
                    break
            }
        }

        if (this.taskParameters.tags && this.taskParameters.tags.length > 0) {
            request.Tags = SdkUtils.getTags<SecretsManager.Tag[]>(this.taskParameters.tags)
        }

        const response = await this.secretsManagerClient.createSecret(request).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}`)
        }
    }