Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions terraform/modules/eks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@ resource "aws_iam_role" "kubernetes_admin_role" {
description = "Kubernetes administrator role (for AWS IAM Authenticator)"
}

# Allow kube admin to list and describe EKS clusters (through assumed role)
data "aws_iam_policy_document" "eks_list_and_describe" {
statement {
actions = [
"eks:ListUpdates",
"eks:ListClusters",
"eks:DescribeUpdate",
"eks:DescribeCluster",
]

resources = ["*"]
}
}

resource "aws_iam_policy" "eks_list_and_describe_policy" {
name = "eks_list_and_describe"
policy = data.aws_iam_policy_document.eks_list_and_describe.json
}

resource "aws_iam_role_policy_attachment" "kube_admin_eks_access" {
role = aws_iam_role.kubernetes_admin_role.id
policy_arn = aws_iam_policy.eks_list_and_describe_policy.arn
}


module "eks" {
source = "terraform-aws-modules/eks/aws"
version = "10.0.0"
Expand Down
22 changes: 19 additions & 3 deletions terraform/modules/environment/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ locals {
kubernetes_cluster_name = "${var.project}-${var.environment}-${var.region}"
}

data "aws_iam_user" "ci_user" {
user_name = "${var.project}-ci-user" # Should have been created in the bootstrap process
}

module "vpc" {
source = "../../modules/vpc"

Expand All @@ -26,6 +30,21 @@ data "aws_iam_policy_document" "assumerole_root_policy" {
identifiers = ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]
}
}

# Allow the CI user to assume this role
statement {
actions = ["sts:AssumeRole"]

principals {
type = "AWS"
identifiers = [data.aws_iam_user.ci_user.arn]
}
}
}

resource "aws_iam_user_policy_attachment" "circleci_ecr_access" {
user = data.aws_iam_user.ci_user.user_name
policy_arn = "arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryPowerUser"
}

#
Expand All @@ -50,9 +69,6 @@ module "eks" {
worker_ami = var.eks_worker_ami # EKS-Optimized AMI for your region: https://docs.aws.amazon.com/eks/latest/userguide/eks-optimized-ami.html
}

data "aws_iam_user" "ci_user" {
user_name = "${var.project}-ci-user" # Should have been created in the bootstrap process
}

module "wildcard_domain" {
source = "../../modules/certificate"
Expand Down