gpt4 book ai didi

amazon-web-services - AWS 系统管理器 + CodeDeploy + Lightsail

转载 作者:行者123 更新时间:2023-12-04 11:39:12 30 4
gpt4 key购买 nike

我想在我的 CodeDeploy 管道中使用 AWS 系统管理器存储参数,删除我对 Lightsail 的最后一次提交。
✅ 1. 我创建了一个 SSM 参数:MySecureString .
参数设置在 SecureString KMS 加密设置为 Actual accountalias/aws/ssm作为身份证。
我的 SecureString设置为:postgres://user:password@endpoint.rds.amazonaws.com:5432/myDatabase ✅ 2. 我创建了一个供 CodeDeploy 实例使用的 IAM 策略
前往 IAM 并创建了附加到 MySpecificCodeDeployUser 的 JSON 策略:

{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"kms:Decrypt",
"ssm:GetParameter"
],
"Resource": [
"arn:aws:kms:*:<accountID>:key/alias/aws/ssm",
"arn:aws:ssm:us-east-1:<accountID>:parameter/MySecureString"
]
}
]
}
✅ 3. 测试 MySpecificFCodeDeployUser访问 SSM MySecureString :
打字 aws configure登录为 MySpecificFCodeDeployUser并尝试在我的本地计算机上运行此命令:
aws --region=us-east-1 ssm get-parameter --name MySecureString --with-decryption --query Parameter.Value
RETURN ==> "postgres://user:password@endpoint.rds.amazonaws.com:5432/myDatabase"
🆗 请注意,删除 IAM 策略会给我一个未经授权的请求,因此 IAM 策略是正确的。
🔥 4. 添加 MySecureString到 CodeDeploy 执行的脚本:
编辑我的 AfterInstall我的脚本 appspec.yml加上 :
aws --region=us-east-1 ssm get-parameter --name MySecureString --with-decryption --query Parameter.Value >> .env
给了我一个 FAILED Buildstderr :
[stderr] An error occurred (AccessDeniedException) when calling the GetParameter operation: User: arn:aws:sts::<id>:assumed-role/AmazonLightsailInstanceRole/<id> is not authorized to perform: ssm:GetParameter on resource: arn:aws:ssm:us-east-1:<id>:parameter/MySecureString
我看到 Lightsail 实例继承自服务相关角色 AWSServiceRoleForLightsail来自 https://lightsail.aws.amazon.com/ls/docs/en_us/articles/amazon-lightsail-using-service-linked-roles .
有没有办法向我的 Lightsail 实例添加新策略,因为它似乎不是 CodeDeploy 用户需要它?

最佳答案

Is there a way to add a new policy to my lightsail instance regarding the fact that it didn't seems to be CodeDeploy user needing it ?


可悲的是,你 不能这样做 .要使您在 Lightsail 实例上的应用程序与 AWS 服务交互,您必须自己完成,方法是设置 .aws凭证并让您的应用程序使用它(如果您使用 AWS 开发工具包,则会自动完成)。
Lightsail 实例 不支持基于用户的实例角色。为此,您需要常规 EC2 实例,如下所述:
  • Identity and Access Management for Amazon Lightsail
  • 关于amazon-web-services - AWS 系统管理器 + CodeDeploy + Lightsail,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68456891/

    30 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com