mirror of https://github.com/kubernetes/kops.git
Consolidate IAM statements
This commit is contained in:
parent
23a313758b
commit
67007e1a0a
|
|
@ -767,25 +767,17 @@ func addNodeupPermissions(p *Policy, enableHookSupport bool) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addEtcdManagerPermissions(p *Policy) {
|
func addEtcdManagerPermissions(p *Policy) {
|
||||||
resource := stringorslice.Slice([]string{"*"})
|
|
||||||
p.unconditionalAction.Insert(
|
p.unconditionalAction.Insert(
|
||||||
"ec2:DescribeVolumes", // aws.go
|
"ec2:DescribeVolumes", // aws.go
|
||||||
)
|
)
|
||||||
|
|
||||||
p.Statement = append(p.Statement,
|
p.Statement = append(p.Statement,
|
||||||
&Statement{
|
|
||||||
Effect: StatementEffectAllow,
|
|
||||||
Action: stringorslice.Slice([]string{
|
|
||||||
"ec2:DescribeVolumes", // aws.go
|
|
||||||
}),
|
|
||||||
Resource: resource,
|
|
||||||
},
|
|
||||||
&Statement{
|
&Statement{
|
||||||
Effect: StatementEffectAllow,
|
Effect: StatementEffectAllow,
|
||||||
Action: stringorslice.Of(
|
Action: stringorslice.Of(
|
||||||
"ec2:AttachVolume",
|
"ec2:AttachVolume",
|
||||||
),
|
),
|
||||||
Resource: resource,
|
Resource: stringorslice.Slice([]string{"*"}),
|
||||||
Condition: Condition{
|
Condition: Condition{
|
||||||
"StringEquals": map[string]string{
|
"StringEquals": map[string]string{
|
||||||
"aws:ResourceTag/k8s.io/role/master": "1",
|
"aws:ResourceTag/k8s.io/role/master": "1",
|
||||||
|
|
@ -805,8 +797,6 @@ func AddLegacyCCMPermissions(p *Policy) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func AddCCMPermissions(p *Policy, cloudRoutes bool) {
|
func AddCCMPermissions(p *Policy, cloudRoutes bool) {
|
||||||
resource := stringorslice.Slice([]string{"*"})
|
|
||||||
|
|
||||||
p.unconditionalAction.Insert(
|
p.unconditionalAction.Insert(
|
||||||
"autoscaling:DescribeAutoScalingGroups",
|
"autoscaling:DescribeAutoScalingGroups",
|
||||||
"autoscaling:DescribeTags",
|
"autoscaling:DescribeTags",
|
||||||
|
|
@ -855,6 +845,13 @@ func AddCCMPermissions(p *Policy, cloudRoutes bool) {
|
||||||
"elasticloadbalancing:RegisterTargets",
|
"elasticloadbalancing:RegisterTargets",
|
||||||
"elasticloadbalancing:DeregisterTargets",
|
"elasticloadbalancing:DeregisterTargets",
|
||||||
"elasticloadbalancing:SetLoadBalancerPoliciesOfListener",
|
"elasticloadbalancing:SetLoadBalancerPoliciesOfListener",
|
||||||
|
"elasticloadbalancing:CreateLoadBalancer",
|
||||||
|
"elasticloadbalancing:CreateLoadBalancerPolicy",
|
||||||
|
"elasticloadbalancing:CreateLoadBalancerListeners",
|
||||||
|
"ec2:CreateSecurityGroup",
|
||||||
|
"ec2:CreateVolume",
|
||||||
|
"elasticloadbalancing:CreateListener",
|
||||||
|
"elasticloadbalancing:CreateTargetGroup",
|
||||||
)
|
)
|
||||||
|
|
||||||
p.Statement = append(p.Statement,
|
p.Statement = append(p.Statement,
|
||||||
|
|
@ -878,25 +875,6 @@ func AddCCMPermissions(p *Policy, cloudRoutes bool) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
&Statement{
|
|
||||||
Effect: StatementEffectAllow,
|
|
||||||
Action: stringorslice.Of(
|
|
||||||
"elasticloadbalancing:CreateLoadBalancer",
|
|
||||||
"elasticloadbalancing:CreateLoadBalancerPolicy",
|
|
||||||
"elasticloadbalancing:CreateLoadBalancerListeners",
|
|
||||||
"ec2:CreateSecurityGroup",
|
|
||||||
"ec2:CreateVolume",
|
|
||||||
"elasticloadbalancing:CreateListener",
|
|
||||||
"elasticloadbalancing:CreateTargetGroup",
|
|
||||||
),
|
|
||||||
Resource: resource,
|
|
||||||
|
|
||||||
Condition: Condition{
|
|
||||||
"StringEquals": map[string]string{
|
|
||||||
"aws:RequestTag/KubernetesCluster": p.clusterName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
)
|
)
|
||||||
if cloudRoutes {
|
if cloudRoutes {
|
||||||
p.clusterTaggedAction.Insert(
|
p.clusterTaggedAction.Insert(
|
||||||
|
|
@ -973,25 +951,12 @@ func AddAWSEBSCSIDriverPermissions(p *Policy, appendSnapshotPermissions bool) {
|
||||||
"ec2:ModifyVolume", // aws.go
|
"ec2:ModifyVolume", // aws.go
|
||||||
"ec2:ModifyInstanceAttribute", // aws.go
|
"ec2:ModifyInstanceAttribute", // aws.go
|
||||||
"ec2:AttachVolume", // aws.go
|
"ec2:AttachVolume", // aws.go
|
||||||
|
"ec2:CreateVolume", // aws.go
|
||||||
"ec2:DeleteVolume", // aws.go
|
"ec2:DeleteVolume", // aws.go
|
||||||
"ec2:DetachVolume", // aws.go
|
"ec2:DetachVolume", // aws.go
|
||||||
)
|
)
|
||||||
|
|
||||||
p.Statement = append(p.Statement,
|
p.Statement = append(p.Statement,
|
||||||
&Statement{
|
|
||||||
Effect: StatementEffectAllow,
|
|
||||||
Action: stringorslice.Slice([]string{
|
|
||||||
"ec2:CreateVolume", // aws.go
|
|
||||||
}),
|
|
||||||
|
|
||||||
Resource: stringorslice.String("*"),
|
|
||||||
Condition: Condition{
|
|
||||||
"StringEquals": map[string]string{
|
|
||||||
"aws:RequestTag/KubernetesCluster": p.clusterName,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
|
|
||||||
&Statement{
|
&Statement{
|
||||||
Effect: StatementEffectAllow,
|
Effect: StatementEffectAllow,
|
||||||
Action: stringorslice.String(
|
Action: stringorslice.String(
|
||||||
|
|
@ -1042,7 +1007,6 @@ func addSnapshotPersmissions(p *Policy) {
|
||||||
p.clusterTaggedAction.Insert(
|
p.clusterTaggedAction.Insert(
|
||||||
"ec2:DeleteSnapshot",
|
"ec2:DeleteSnapshot",
|
||||||
)
|
)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// AddDNSControllerPermissions adds IAM permissions used by the dns-controller.
|
// AddDNSControllerPermissions adds IAM permissions used by the dns-controller.
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue