Skip to content

Commit

Permalink
update cluster role trust policy
Browse files Browse the repository at this point in the history
  • Loading branch information
kukushking committed Nov 11, 2024
1 parent 771e33b commit 6ee7404
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### **Changed**

- pin external gh actions to hash
- fix eks cluster admin role trust policy

### **Removed**

Expand Down
12 changes: 12 additions & 0 deletions modules/compute/eks/stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,6 +526,15 @@ def _create_eks_cluster(
],
)

# Grant kubectl handler role explicit assume of cluster admin role
cluster_admin_role.assume_role_policy.add_statements(
iam.PolicyStatement(
effect=iam.Effect.ALLOW,
actions=["sts:AssumeRole"],
principals=[eks_cluster.kubectl_lambda_role.role_arn],
)
)

# Whitelist traffic between Codebuild SG and EKS SG when the APIServer is private
if eks_compute_config.get("eks_api_endpoint_private") and codebuild_sg_id:
codebuild_sg = ec2.SecurityGroup.from_security_group_id(self, "eks-codebuild-sg", codebuild_sg_id)
Expand Down Expand Up @@ -628,6 +637,9 @@ def _create_cluster_admin_role(self, project_name, deployment_name, module_name,
conditions={
"ArnLike": {
"aws:PrincipalArn": (
# NOTE: this is known to cause issues when using long deployment names
# for resources with autogenerated names that may be truncated to not fit the pattern
# such as kubectl handler role
f"arn:{self._partition}:iam::{account}:role/{project_name}-{deployment_name}-*"
)
}
Expand Down

0 comments on commit 6ee7404

Please sign in to comment.