Skip to content

Commit 9786b50

Browse files
authored
Remove cluster name from IAM resources (#53)
* Remove cluster name from IAM resources
1 parent faee8e9 commit 9786b50

File tree

4 files changed

+8
-12
lines changed

4 files changed

+8
-12
lines changed

operator/README.md

+2-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ KIT uses the [operator pattern](https://kubernetes.io/docs/concepts/extend-kuber
3030
aws cloudformation deploy \
3131
--template-file docs/kit.cloudformation.yaml \
3232
--capabilities CAPABILITY_NAMED_IAM \
33-
--stack-name kitControllerPolicy \
34-
--parameter-overrides ClusterName=${SUBSTRATE_CLUSTER_NAME}
33+
--stack-name kitControllerPolicy
3534
```
3635

3736
#### Associate the policy we just created to the kit-controller service account
@@ -41,7 +40,7 @@ KIT uses the [operator pattern](https://kubernetes.io/docs/concepts/extend-kuber
4140
--name kit-controller \
4241
--namespace kit \
4342
--cluster ${SUBSTRATE_CLUSTER_NAME} \
44-
--attach-policy-arn arn:aws:iam::${AWS_ACCOUNT_ID}:policy/KitControllerPolicy-${SUBSTRATE_CLUSTER_NAME}-cluster \
43+
--attach-policy-arn arn:aws:iam::${AWS_ACCOUNT_ID}:policy/KitControllerPolicy \
4544
--approve \
4645
--override-existing-serviceaccounts \
4746
--region=${AWS_REGION}

operator/docs/kit.cloudformation.yaml

+3-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
AWSTemplateFormatVersion: "2010-09-09"
22
Description: Resources used by https://github.com/awslabs/kit/operator
3-
Parameters:
4-
ClusterName:
5-
Type: String
6-
Description: "Desired cluster name"
73
Resources:
84
KitNodeInstanceProfile:
95
Type: "AWS::IAM::InstanceProfile"
106
Properties:
11-
InstanceProfileName: !Sub "KitNodeInstanceProfile-${ClusterName}"
7+
InstanceProfileName: "KitNodeInstanceProfile"
128
Path: "/"
139
Roles:
1410
- Ref: "KitNodeRole"
1511
KitNodeRole:
1612
Type: "AWS::IAM::Role"
1713
Properties:
18-
RoleName: !Sub "KitNodeRole-${ClusterName}-cluster"
14+
RoleName: "KitNodeRole"
1915
Path: /
2016
AssumeRolePolicyDocument:
2117
Version: "2012-10-17"
@@ -34,7 +30,7 @@ Resources:
3430
KitControllerPolicy:
3531
Type: "AWS::IAM::ManagedPolicy"
3632
Properties:
37-
ManagedPolicyName: !Sub "KitControllerPolicy-${ClusterName}-cluster"
33+
ManagedPolicyName: "KitControllerPolicy"
3834
PolicyDocument:
3935
Version: "2012-10-17"
4036
Statement:

operator/pkg/awsprovider/launchtemplate/reconciler.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"encoding/base64"
2020
"fmt"
2121

22+
"github.com/aws/aws-sdk-go/aws"
2223
"github.com/aws/aws-sdk-go/service/ec2"
2324
"github.com/aws/aws-sdk-go/service/ssm"
2425
cpv1alpha1 "github.com/awslabs/kit/operator/pkg/apis/controlplane/v1alpha1"
@@ -119,7 +120,7 @@ func (c *Controller) createLaunchTemplate(ctx context.Context, dataplane *v1alph
119120
InstanceType: ptr.String("t2.xlarge"), // TODO get this from dataplane spec
120121
ImageId: ptr.String(amiID),
121122
IamInstanceProfile: &ec2.LaunchTemplateIamInstanceProfileSpecificationRequest{
122-
Name: ptr.String(fmt.Sprintf("KitNodeInstanceProfile-%s", dataplane.Spec.ClusterName)),
123+
Name: aws.String(fmt.Sprintf("KitNodeInstanceProfile")),
123124
},
124125
Monitoring: &ec2.LaunchTemplatesMonitoringRequest{Enabled: ptr.Bool(true)},
125126
SecurityGroupIds: []*string{ptr.String(securityGroupID)},

operator/pkg/controllers/master/authenticatorconfig.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ data:
164164
- groups:
165165
- system:bootstrappers
166166
- system:nodes
167-
rolearn: arn:aws:iam::{{ .AWSAccountID }}:role/KitNodeRole-{{ .ClusterName }}-cluster
167+
rolearn: arn:aws:iam::{{ .AWSAccountID }}:role/KitNodeRole
168168
username: system:node:{{ .PrivateDNS}}
169169
# List of Account IDs to whitelist for authentication
170170
mapAccounts:

0 commit comments

Comments
 (0)