简体   繁体   English

AWS Glue JOB 从 secretmanager 获取秘密值

[英]AWS Glue JOB to get secret value from secretmanager

I'm working on the AWS glue job, can someone please help me to give me a script in AWS Glue Job Spark that would retrieve my secrets from secret manager.我正在从事 AWS glue 工作,有人可以帮我在 AWS Glue Job Spark 中给我一个脚本,它可以从秘密管理器中检索我的秘密。 Help is appreciated.感谢帮助。

It is fairly simple (if you have all of the required IAM permissions) using boto3 and get_secret_value() function.使用 boto3 和get_secret_value() function 相当简单(如果您拥有所有必需的 IAM 权限)。

sm_client = boto3.client('secretsmanager')
response = sm_client.get_secret_value(
    SecretId=<your_secret_id>
)

If the value is a string, you can extract it like this:如果该值是一个字符串,您可以像这样提取它:

value = secret_value_response['SecretString']

If it is a binary value:如果是二进制值:

secret_value_response['SecretBinary']

Additionally, if the secret has multiple versions of the secret, you have to use VersionId and/or VersionStage as explained in the linked documentation.此外,如果密钥有多个版本,则必须按照链接文档中的说明使用VersionId和/或VersionStage

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM