Skip to content

Commit

Permalink
adding prefix in policy name
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavan Shukla authored and Pavan Shukla committed Aug 19, 2024
1 parent 306af01 commit b998db2
Showing 1 changed file with 76 additions and 8 deletions.
84 changes: 76 additions & 8 deletions emp/emp_role_cftemplate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ Parameters:
RoleName:
Type: String
Description: The name of the IAM role and instance profile.
Default: 'pf9-emp-role'
Default: 'pf9emp'

Resources:
# CAPA Policies
AWSIAMManagedPolicyCloudProviderControlPlane:
Properties:
Description: For the Kubernetes Cloud Provider AWS Control Plane
ManagedPolicyName: control-plane.cluster-api-provider-aws.sigs.k8s.io
ManagedPolicyName: !Sub "${RoleName}-control-plane.cluster-api-provider-aws.sigs.k8s.io"
PolicyDocument:
Statement:
- Action:
Expand Down Expand Up @@ -74,11 +74,13 @@ Resources:
Resource:
- '*'
Version: 2012-10-17
Roles:
- Ref: AWSIAMRoleControlPlane
Type: AWS::IAM::ManagedPolicy
AWSIAMManagedPolicyCloudProviderNodes:
Properties:
Description: For the Kubernetes Cloud Provider AWS nodes
ManagedPolicyName: nodes.cluster-api-provider-aws.sigs.k8s.io
ManagedPolicyName: !Sub "${RoleName}-nodes.cluster-api-provider-aws.sigs.k8s.io"
PolicyDocument:
Statement:
- Action:
Expand Down Expand Up @@ -116,11 +118,14 @@ Resources:
Resource:
- '*'
Version: 2012-10-17
Roles:
- Ref: AWSIAMRoleControlPlane
- Ref: AWSIAMRoleNodes
Type: AWS::IAM::ManagedPolicy
AWSIAMManagedPolicyControllers:
Properties:
Description: For the Kubernetes Cluster API Provider AWS Controllers
ManagedPolicyName: controllers.cluster-api-provider-aws.sigs.k8s.io
ManagedPolicyName: !Sub "${RoleName}-controllers.cluster-api-provider-aws.sigs.k8s.io"
PolicyDocument:
Statement:
- Action:
Expand Down Expand Up @@ -277,11 +282,14 @@ Resources:
Resource:
- arn:*:secretsmanager:*:*:secret:aws.cluster.x-k8s.io/*
Version: 2012-10-17
Roles:
- Ref: AWSIAMRoleControllers
- Ref: AWSIAMRoleControlPlane
Type: AWS::IAM::ManagedPolicy
AWSIAMManagedPolicyControllersEKS:
Properties:
Description: For the Kubernetes Cluster API Provider AWS Controllers
ManagedPolicyName: controllers-eks.cluster-api-provider-aws.sigs.k8s.io
ManagedPolicyName: !Sub "${RoleName}-controllers-eks.cluster-api-provider-aws.sigs.k8s.io"
PolicyDocument:
Statement:
- Action:
Expand Down Expand Up @@ -381,7 +389,67 @@ Resources:
Resource:
- '*'
Version: 2012-10-17
Roles:
- Ref: AWSIAMRoleControllers
- Ref: AWSIAMRoleControlPlane
Type: AWS::IAM::ManagedPolicy
AWSIAMRoleControlPlane:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Version: 2012-10-17
RoleName: !Sub "${RoleName}-control-plane.cluster-api-provider-aws.sigs.k8s.io"
Type: AWS::IAM::Role
AWSIAMRoleControllers:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Version: 2012-10-17
RoleName: !Sub "${RoleName}-controllers.cluster-api-provider-aws.sigs.k8s.io"
Type: AWS::IAM::Role
AWSIAMRoleEKSControlPlane:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- eks.amazonaws.com
Version: 2012-10-17
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonEKSClusterPolicy
RoleName: !Sub "${RoleName}-eks-controlplane.cluster-api-provider-aws.sigs.k8s.io"
Type: AWS::IAM::Role
AWSIAMRoleNodes:
Properties:
AssumeRolePolicyDocument:
Statement:
- Action:
- sts:AssumeRole
Effect: Allow
Principal:
Service:
- ec2.amazonaws.com
Version: 2012-10-17
ManagedPolicyArns:
- arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy
- arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy
RoleName: !Sub "${RoleName}-nodes.cluster-api-provider-aws.sigs.k8s.io"
Type: AWS::IAM::Role
# PF9 Role and Policies
EKSRole:
Type: 'AWS::IAM::Role'
Expand All @@ -392,7 +460,7 @@ Resources:
Statement:
- Effect: 'Allow'
Principal:
Service:
Service:
- 'ec2.amazonaws.com'
AWS:
- 'arn:aws:iam::617350239289:root'
Expand All @@ -410,7 +478,7 @@ Resources:
PF9EMPPolicy:
Properties:
Description: EMP PF9 Policy
ManagedPolicyName: emp-policy
ManagedPolicyName: !Sub "${RoleName}-emp-policy"
PolicyDocument:
Statement:
- Action:
Expand Down Expand Up @@ -450,7 +518,7 @@ Resources:
Effect: Allow
- Action:
- 'iam:PassRole'
Resource:
Resource:
- !Sub 'arn:aws:iam::${AWS::AccountId}:role/${EKSRole}'
Effect: Allow
- Action:
Expand Down

0 comments on commit b998db2

Please sign in to comment.