AWS CLI 描述参数检索除描述值之外的所有 ssm 参数数据。
我正在尝试从 AWS 账户获取所有 ssm 参数,以将它们迁移到另一个 AWS 账户。
为了找出问题所在,我尝试运行以下命令来仅检索一个参数。它打印出除描述值之外的所有内容
aws ssm describe-parameters --filters Key=Name,Values=<your-parameter-name>
我还尝试了以下命令来检索所有参数。同样,他们返回除描述值之外的所有内容
aws ssm get-parameters-by-path --path "/" --recursive --region <region> --output text --query 'Parameters[].{Name:Name,Value:Value,Description:Description}'
上述命令返回名称和值,但打印出
null
作为描述。我还尝试不包含 query
cli 选项来查看命令打印出的内容。命令如下:
aws ssm get-parameters-by-path --path "/" --recursive --region <region>
它会打印除
Description
之外的所有内容。这证实了 AWS 没有读取 Description
值。
有没有办法也检索
Description
?因为迁移所有参数(除了描述)然后手动复制描述会很耗时。
我使用 shell 脚本来获取所有参数,然后将它们与描述值一起上传。但这个问题的重点是想办法得到
Description
。
我最近遇到了类似的问题,我需要下载 SSM 参数并将它们导入到我的 terraform 状态中,我还意识到没有包含描述。
为了检索 SSM 参数详细信息(包括描述),我结合了 aws ssm describe-parameters 来列出参数,并结合 aws ssm get-parameter 来获取每个参数的详细信息。
这是使用 shell 脚本的方法:
#!/bin/bash
# Replace <region> with your AWS region
region="<region>"
# Get a list of all parameter names
parameter_names=$(aws ssm describe-parameters --region $region --query "Parameters[].Name" --output text)
# Loop through each parameter name to fetch its details, including the description
for name in $parameter_names; do
echo "Details for parameter: $name"
aws ssm get-parameter --name "$name" --region $region --with-decryption --query "Parameter.{Name:Name,Value:Value,Description:Description}" --output text
done
希望这对您有用。