【发布时间】:2017-11-20 00:51:00
【问题描述】:
我正在尝试使用我的 GitHub 设置 CodeDeploy,但我发现了一些问题。
我已经创建了 service role,如文档中所述,使用 AWSCodeDeployRole 策略。
在我的代码部署应用程序创建过程中,我遇到了一个问题:
Cannot assume role provided.
如我所见,我在AWSCodeDeployRole 中的角色有很多自动缩放权限,但我不希望这样做:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"autoscaling:CompleteLifecycleAction",
"autoscaling:DeleteLifecycleHook",
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribeLifecycleHooks",
"autoscaling:PutLifecycleHook",
"autoscaling:RecordLifecycleActionHeartbeat",
"autoscaling:CreateAutoScalingGroup",
"autoscaling:UpdateAutoScalingGroup",
"autoscaling:EnableMetricsCollection",
"autoscaling:DescribeAutoScalingGroups",
"autoscaling:DescribePolicies",
"autoscaling:DescribeScheduledActions",
"autoscaling:DescribeNotificationConfigurations",
"autoscaling:DescribeLifecycleHooks",
"autoscaling:SuspendProcesses",
"autoscaling:ResumeProcesses",
"autoscaling:AttachLoadBalancers",
"autoscaling:PutScalingPolicy",
"autoscaling:PutScheduledUpdateGroupAction",
"autoscaling:PutNotificationConfiguration",
"autoscaling:PutLifecycleHook",
"autoscaling:DescribeScalingActivities",
"autoscaling:DeleteAutoScalingGroup",
"ec2:DescribeInstances",
"ec2:DescribeInstanceStatus",
"ec2:TerminateInstances",
"tag:GetTags",
"tag:GetResources",
"sns:Publish",
"cloudwatch:DescribeAlarms",
"elasticloadbalancing:DescribeLoadBalancers",
"elasticloadbalancing:DescribeInstanceHealth",
"elasticloadbalancing:RegisterInstancesWithLoadBalancer",
"elasticloadbalancing:DeregisterInstancesFromLoadBalancer"
],
"Resource": "*"
}
]
}
在一些谷歌搜索过程中,我发现 CodeDeploy 应用程序可能期望类似于:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"codedeploy.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
但是当我尝试手动创建此策略时,它也会失败并出现错误:
This policy contains the following error: Has prohibited field Principal For more information about the IAM policy grammar, see AWS IAM Policies.
那么,Code Deploy Application 的预期服务角色是什么?
顺便说一句,代码部署正在我的 EC2 实例上运行。
【问题讨论】:
-
我相信您将权限策略与trust relationships policy 混淆了。它们都是策略,语法相似,但用途不同:前者指定角色允许或拒绝的操作(例如自动缩放操作),后者指定哪些实体(主体)可以承担角色(例如 @987654330 @服务主体)。
-
好吧,我的
Service role的信任关系如下:{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] } -
您是否发现此政策与您在谷歌搜索时发现的政策有相似之处?
codedeploy与ec2? -
@Michael-sqlbot 你可以发表你的建议,我会批准的。以前删除我的答案。
-
谢谢。我会这样做的。
标签: amazon-web-services amazon-ec2 aws-code-deploy