You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过PowerShell获取AWS Secrets Manager中特定密钥的值

从AWS Secrets Manager提取特定密钥值的PowerShell方法

Get-SECSecretValue返回的SecretString本质是JSON格式的键值对字符串,直接输出会显示所有内容,要提取特定密钥值,只需先将JSON字符串转换为PowerShell对象,再指定键名即可。

分步实现

  1. 获取密钥并转换为PowerShell对象:
$secretObject = Get-SECSecretValue -SecretId "secret-arn" -Select SecretString | ConvertFrom-Json
  1. 提取目标密钥的值(假设目标键名为your-target-key):
$targetValue = $secretObject."your-target-key"
# 若键名无特殊字符,可简化为 $secretObject.your-target-key

一行式写法

如果想直接获取结果,可合并成一行:

(Get-SECSecretValue -SecretId "secret-arn" -Select SecretString | ConvertFrom-Json)."your-target-key"

注:AWS Secrets Manager默认存储的密钥字符串为JSON格式,若你的密钥是其他格式,需根据实际格式调整解析方式。

内容的提问来源于stack exchange,提问作者Lakshay Kashyap

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.06 09:25:44