【问题标题】:How to securely pull code from an aws s3 bucket to a Codecommit repository using Cloudformation?如何使用 Cloudformation 将代码从 aws s3 存储桶安全地提取到 Codecommit 存储库?
【发布时间】:2019-10-25 12:18:18
【问题描述】:
在 AWS 中,在 Cloudformation 中创建管道堆栈后(使用 YAML 文件),我能够成功地将代码从现有 S3 存储桶提取到 Codecommit 内的新存储库中。
这很好用,但我希望确保 S3 存储桶本身是私有的而不是公开的,并且需要某种身份验证系统来确保用户正确地从我的 s3 存储桶中提取代码,他们需要提供更正 auth 到 cloudformation 以正确填充 Codecommit 存储库。
哪种 AWS 服务最适合我这样做?我正在考虑使用带有 Lambda 授权方的 API 网关,但我对其他可能使这更容易的 AWS 服务感兴趣。
【问题讨论】:
标签:
amazon-web-services
amazon-cloudformation
aws-api-gateway
aws-codepipeline
【解决方案1】:
AWS Roles 是否适合您的需求?您可以将角色附加到 S3 以允许用户下载代码:
{
"Version": "2008-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS: [
"arn:aws:iam::AWS-account-ID:user/user-name-1",
"arn:aws:iam::AWS-account-ID:user/user-name-2",
]
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::YOUR_BUCKET/SOME/PATH"
}
]
}
和/或如果您没有预定义的用户,您可以允许 Lambda 担任此类角色,如 here 所述,并通过 API 网关与 Lambda 授权方返回凭据。