[英]Create Secrets Manager using CloudFormation but keeping values not visible
我有一個 CloudFormation 模板,用於在 Secrets Manager 中創建 Secret。 我當前的模板與此類似(基於 aws 文檔https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-secretsmanager-secret.html ):
{
"Resources": {
"MyCredentials": {
"Type": "AWS::SecretsManager::Secret",
"Properties": {
"Name": "prod/web/api",
"Description": "",
"SecretString": "{
\"Client_id\":\"my_client_id\",
\"Client_secret\":\"a_super_secret_value\"
}"
}
}
}
}
我的問題是我不能使用 GenerateSecretString 屬性,因為密碼是從外部組織定義的,所以我不能自己更改或創建值,這樣可以從 CloudFormation 中的模板查看秘密值。
有可能實現這一點,還是我需要手動創建秘密?
您可以使用AWS SSM Parameter ,其中外部組織已授予在那里添加/更新密碼的權限,或者團隊中的某人也這樣做。
密碼存在后,您可以通過如下動態引用讀取您的 cloudformation 模板,
以下示例使用 ssm-secure 動態引用將 IAM 用戶的密碼設置為存儲在 Systems Manager Parameter Store 中的安全字符串。 按照指定,CloudFormation 將使用版本 10 的 IAMUserPassword 參數進行堆棧和更改集操作。
"MyIAMUser": {
"Type": "AWS::IAM::User",
"Properties": {
"UserName": "MyUserName",
"LoginProfile": {
"Password": "{{resolve:ssm-secure:IAMUserPassword:10}}"
}
}
}
或者static 參考如下:
此處訪問存儲在 SSM 中的AvailabilityZone參數。
"AvailabilityZone": {
"Description": "Amazon EC2 instance Availablity Zone",
"Type": "AWS::SSM::Parameter::Value<String>",
"Default": "AvailabilityZone"
}
在 AWS CloudFormation 模板中使用 AWS Systems Manager Parameter Store 安全字符串參數中的更多示例
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.