Skip to content

Commit

Permalink
Allow service role some actions necessary for ELB (#2492)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbeaumont committed Jul 31, 2020
1 parent ce902f3 commit dc1cffe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
14 changes: 7 additions & 7 deletions pkg/cfn/builder/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2459,7 +2459,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(clusterTemplate.Resources).To(HaveKey("ServiceRole"))
Expect(clusterTemplate.Resources).To(HaveKey("PolicyCloudWatchMetrics"))
Expect(clusterTemplate.Resources).To(HaveKey("FargatePodExecutionRole"))
Expect(clusterTemplate.Resources).To(HaveLen(4))
Expect(clusterTemplate.Resources).To(HaveLen(5))
})
})

Expand Down Expand Up @@ -2509,7 +2509,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(clusterTemplate.Resources).To(HaveKey("ControlPlane"))
Expect(clusterTemplate.Resources).To(HaveKey("ServiceRole"))
Expect(clusterTemplate.Resources).To(HaveKey("PolicyCloudWatchMetrics"))
Expect(clusterTemplate.Resources).To(HaveLen(3))
Expect(clusterTemplate.Resources).To(HaveLen(4))
})

It("should have correct own IAM resources", func() {
Expand Down Expand Up @@ -2591,7 +2591,7 @@ var _ = Describe("CloudFormation template builder API", func() {
}
}

Expect(len(clusterTemplate.Resources)).To(Equal(31))
Expect(len(clusterTemplate.Resources)).To(Equal(32))
})

It("should use own VPC and subnets", func() {
Expand Down Expand Up @@ -2689,7 +2689,7 @@ var _ = Describe("CloudFormation template builder API", func() {
}
}

Expect(len(clusterTemplate.Resources)).To(Equal(38))
Expect(len(clusterTemplate.Resources)).To(Equal(39))
})

It("should use own VPC and subnets", func() {
Expand Down Expand Up @@ -2766,7 +2766,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(clusterTemplate.Resources).To(HaveKey("RouteTableAssociationPrivate" + region + zone))
}

Expect(len(clusterTemplate.Resources)).To(Equal(35))
Expect(len(clusterTemplate.Resources)).To(Equal(36))
})

It("should route Internet traffic from private subnets through their corresponding NAT gateways", func() {
Expand Down Expand Up @@ -2812,7 +2812,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(clusterTemplate.Resources).To(HaveKey("RouteTableAssociationPrivate" + region + zone))
}

Expect(len(clusterTemplate.Resources)).To(Equal(31))
Expect(len(clusterTemplate.Resources)).To(Equal(32))
})

It("should route Internet traffic from private subnets through the single NAT gateway", func() {
Expand Down Expand Up @@ -2855,7 +2855,7 @@ var _ = Describe("CloudFormation template builder API", func() {
Expect(clusterTemplate.Resources).To(HaveKey("RouteTableAssociationPrivate" + region + zone))
}

Expect(len(clusterTemplate.Resources)).To(Equal(26))
Expect(len(clusterTemplate.Resources)).To(Equal(27))

})

Expand Down
7 changes: 7 additions & 0 deletions pkg/cfn/builder/iam.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,13 @@ func (c *ClusterResourceSet) addResourcesForIAM() {
c.rs.attachAllowPolicy("PolicyCloudWatchMetrics", refSR, "*", []string{
"cloudwatch:PutMetricData",
})
// These are potentially required for creating load balancers but aren't included in the
// AmazonEKSClusterPolicy
// See https://docs.aws.amazon.com/elasticloadbalancing/latest/userguide/elb-api-permissions.html#required-permissions-v2
// and weaveworks/eksctl#2488
c.rs.attachAllowPolicy("PolicyELBPermissions", refSR, "*", []string{
"ec2:DescribeAccountAttributes",
})

c.rs.defineOutputFromAtt(outputs.ClusterServiceRoleARN, "ServiceRole", "Arn", true, func(v string) error {
c.spec.IAM.ServiceRoleARN = &v
Expand Down

0 comments on commit dc1cffe

Please sign in to comment.