CodeDeploy設置中通常有兩種情況:'創建'部署(通常是您的CI服務器/構建代理)和在目標實例上運行的CodeDeploy代理,並執行實際部署。前半部分基本上是將推入CodeDeployment,後半部分是從中拉出 ......這就是我喜歡將它形象化的方式。對於CI服務器/構建代理程序,它們應該具有如下權限的IAM角色...這允許構建代理程序(1)訪問您爲部署指定的S3存儲區並(2)訪問CodeDeploy服務創造修訂等
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:ListAllMyBuckets"
],
"Resource": "arn:aws:s3:::*"
}, {
"Effect": "Allow",
"Action": [
"s3:PutObject"
],
"Resource": "arn:aws:s3:::YourDeploymentBucket"
},
{
"Effect": "Allow",
"Action": [
"codedeploy:*"
],
"Resource": "*"
}
]
}
在目標EC2實例,他們需要有這樣的事情......這給CodeDeploy代理服務(1)進入S3鬥拉修訂和(2)訪問所有通用代碼部署桶,以便代理可以自行更新。當然,這些實例需要滿足所有其他標準......通常,他們需要IAM角色並需要安裝代碼部署代理。
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"s3:Get*",
"s3:List*"
],
"Resource": [
"arn:aws:s3:::YourDeploymentBucket/*",
"arn:aws:s3:::aws-codedeploy-us-east-1/*",
"arn:aws:s3:::aws-codedeploy-us-west-1/*",
"arn:aws:s3:::aws-codedeploy-us-west-2/*",
"arn:aws:s3:::aws-codedeploy-ap-northeast-1/*",
"arn:aws:s3:::aws-codedeploy-ap-northeast-2/*",
"arn:aws:s3:::aws-codedeploy-ap-south-1/*",
"arn:aws:s3:::aws-codedeploy-ap-southeast-1/*",
"arn:aws:s3:::aws-codedeploy-ap-southeast-2/*",
"arn:aws:s3:::aws-codedeploy-eu-central-1/*",
"arn:aws:s3:::aws-codedeploy-eu-west-1/*",
"arn:aws:s3:::aws-codedeploy-sa-east-1/*"
]
}
]
}
你如何分配這些許可是你......如果你的生成代理的EC2實例,這將是最好分配這些作爲附加到與實例(S)相關的IAM角色的策略。對於目標部署機器,您可以執行相同的操作...創建策略並將其分配給與要定位的實例關聯的IAM角色。