Skip to content

Commit b5a9e87

Browse files
authored
Attach EKS auto policies for Auto cluster only (#574)
1 parent 7b3bbf0 commit b5a9e87

File tree

2 files changed

+45
-20
lines changed

2 files changed

+45
-20
lines changed

internal/deployers/eksapi/infra.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,10 @@ func (m *InfrastructureManager) createInfrastructureStack(opts *deployerOptions)
128128
ParameterKey: aws.String("Subnet02AZ"),
129129
ParameterValue: aws.String(subnetAzs[1]),
130130
},
131+
{
132+
ParameterKey: aws.String("AutoMode"),
133+
ParameterValue: aws.String(fmt.Sprintf("%t", opts.AutoMode)),
134+
},
131135
},
132136
}
133137
if opts.ClusterRoleServicePrincipal != "" {

internal/deployers/eksapi/templates/infra.yaml

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ Parameters:
4242
Subnet02AZ:
4343
Type: String
4444

45+
AutoMode:
46+
Type: String
47+
AllowedValues:
48+
- "true"
49+
- "false"
50+
Default: "false"
51+
4552
Metadata:
4653
AWS::CloudFormation::Interface:
4754
ParameterGroups:
@@ -61,6 +68,8 @@ Conditions:
6168
- ""
6269
- !Ref AdditionalClusterRoleServicePrincipal
6370

71+
IsAutoMode: !Equals [!Ref AutoMode, "true"]
72+
6473
Resources:
6574
#
6675
# Public VPC
@@ -415,26 +424,38 @@ Resources:
415424
- - "arn:"
416425
- !Ref "AWS::Partition"
417426
- ":iam::aws:policy/AmazonEKSClusterPolicy"
418-
- !Join
419-
- ""
420-
- - "arn:"
421-
- !Ref "AWS::Partition"
422-
- ":iam::aws:policy/AmazonEKSBlockStoragePolicy"
423-
- !Join
424-
- ""
425-
- - "arn:"
426-
- !Ref "AWS::Partition"
427-
- ":iam::aws:policy/AmazonEKSComputePolicy"
428-
- !Join
429-
- ""
430-
- - "arn:"
431-
- !Ref "AWS::Partition"
432-
- ":iam::aws:policy/AmazonEKSLoadBalancingPolicy"
433-
- !Join
434-
- ""
435-
- - "arn:"
436-
- !Ref "AWS::Partition"
437-
- ":iam::aws:policy/AmazonEKSNetworkingPolicy"
427+
- !If
428+
- IsAutoMode
429+
- !Join
430+
- ""
431+
- - "arn:"
432+
- !Ref "AWS::Partition"
433+
- ":iam::aws:policy/AmazonEKSBlockStoragePolicy"
434+
- !Ref "AWS::NoValue"
435+
- !If
436+
- IsAutoMode
437+
- !Join
438+
- ""
439+
- - "arn:"
440+
- !Ref "AWS::Partition"
441+
- ":iam::aws:policy/AmazonEKSComputePolicy"
442+
- !Ref "AWS::NoValue"
443+
- !If
444+
- IsAutoMode
445+
- !Join
446+
- ""
447+
- - "arn:"
448+
- !Ref "AWS::Partition"
449+
- ":iam::aws:policy/AmazonEKSLoadBalancingPolicy"
450+
- !Ref "AWS::NoValue"
451+
- !If
452+
- IsAutoMode
453+
- !Join
454+
- ""
455+
- - "arn:"
456+
- !Ref "AWS::Partition"
457+
- ":iam::aws:policy/AmazonEKSNetworkingPolicy"
458+
- !Ref "AWS::NoValue"
438459

439460
NodeRole:
440461
Type: AWS::IAM::Role

0 commit comments

Comments
 (0)