File tree Expand file tree Collapse file tree 2 files changed +44
-3
lines changed
Expand file tree Collapse file tree 2 files changed +44
-3
lines changed Original file line number Diff line number Diff line change @@ -21,6 +21,31 @@ resource "aws_iam_role" "kubernetes_admin_role" {
2121 description = " Kubernetes administrator role (for AWS IAM Authenticator)"
2222}
2323
24+ # Allow kube admin to list and describe EKS clusters (through assumed role)
25+ data "aws_iam_policy_document" "eks_list_and_describe" {
26+ statement {
27+ actions = [
28+ " eks:ListUpdates" ,
29+ " eks:ListClusters" ,
30+ " eks:DescribeUpdate" ,
31+ " eks:DescribeCluster" ,
32+ ]
33+
34+ resources = [" *" ]
35+ }
36+ }
37+
38+ resource "aws_iam_policy" "eks_list_and_describe_policy" {
39+ name = " eks_list_and_describe"
40+ policy = data. aws_iam_policy_document . eks_list_and_describe . json
41+ }
42+
43+ resource "aws_iam_role_policy_attachment" "kube_admin_eks_access" {
44+ role = aws_iam_role. kubernetes_admin_role . id
45+ policy_arn = aws_iam_policy. eks_list_and_describe_policy . arn
46+ }
47+
48+
2449module "eks" {
2550 source = " terraform-aws-modules/eks/aws"
2651 version = " 10.0.0"
Original file line number Diff line number Diff line change @@ -4,6 +4,10 @@ locals {
44 kubernetes_cluster_name = " ${ var . project } -${ var . environment } -${ var . region } "
55}
66
7+ data "aws_iam_user" "ci_user" {
8+ user_name = " ${ var . project } -ci-user" # Should have been created in the bootstrap process
9+ }
10+
711module "vpc" {
812 source = " ../../modules/vpc"
913
@@ -26,6 +30,21 @@ data "aws_iam_policy_document" "assumerole_root_policy" {
2630 identifiers = [" arn:aws:iam::${ data . aws_caller_identity . current . account_id } :root" ]
2731 }
2832 }
33+
34+ # Allow the CI user to assume this role
35+ statement {
36+ actions = [" sts:AssumeRole" ]
37+
38+ principals {
39+ type = " AWS"
40+ identifiers = [data . aws_iam_user . ci_user . arn ]
41+ }
42+ }
43+ }
44+
45+ resource "aws_iam_user_policy_attachment" "circleci_ecr_access" {
46+ user = data. aws_iam_user . ci_user . user_name
47+ policy_arn = " arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser"
2948}
3049
3150#
@@ -50,9 +69,6 @@ module "eks" {
5069 worker_ami = var. eks_worker_ami # EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
5170}
5271
53- data "aws_iam_user" "ci_user" {
54- user_name = " ${ var . project } -ci-user" # Should have been created in the bootstrap process
55- }
5672
5773module "wildcard_domain" {
5874 source = " ../../modules/certificate"
You can’t perform that action at this time.
0 commit comments