View a markdown version of this page

Dapatkan nilai rahasia Manajer Rahasia menggunakan Ruby AWS SDK - AWS Secrets Manager

Terjemahan disediakan oleh mesin penerjemah. Jika konten terjemahan yang diberikan bertentangan dengan versi bahasa Inggris aslinya, utamakan versi bahasa Inggris.

Dapatkan nilai rahasia Manajer Rahasia menggunakan Ruby AWS SDK

Untuk aplikasi Ruby, panggil SDK secara langsung dengan get_secret_value atau batch_get_secret_value.

Contoh kode berikut menunjukkan cara mendapatkan nilai rahasia Manajer Rahasia.

Izin yang diperlukan: secretsmanager:GetSecretValue

# Use this code snippet in your app. # If you need more information about configurations or implementing the sample code, visit the AWS docs: # https://aws.amazon.com/developer/language/ruby/ require 'aws-sdk-secretsmanager' def get_secret client = Aws::SecretsManager::Client.new(region: '<<{{MyRegionName}}>>') begin get_secret_value_response = client.get_secret_value(secret_id: '<<{{MySecretName}}>>') rescue StandardError => e # For a list of exceptions thrown, see # https://<<{{DocsDomain}}>>/secretsmanager/latest/apireference/API_GetSecretValue.html raise e end secret = get_secret_value_response.secret_string # Your code goes here. end