File tree Expand file tree Collapse file tree 3 files changed +48
-5
lines changed
Expand file tree Collapse file tree 3 files changed +48
-5
lines changed Original file line number Diff line number Diff line change 1+ provider "kubernetes" {
2+ host = module. eks . cluster_endpoint
3+ cluster_ca_certificate = base64decode (module. eks . cluster_certificate_authority_data )
4+ token = data. aws_eks_cluster_auth . cluster . token
5+ }
6+ // This addon will also create a kubernetes service account with the necessary IAM role attached to managed EBS volumes
7+ resource "aws_eks_addon" "ebs" {
8+ depends_on = [ module . eks_managed_node_group ]
9+ cluster_name = module. eks . cluster_name
10+ addon_name = " aws-ebs-csi-driver"
11+ service_account_role_arn = aws_iam_role. eks-ebs . arn
12+ }
13+ resource "aws_iam_role" "eks-ebs" {
14+ name = " eks-ebs"
15+ assume_role_policy = data. aws_iam_policy_document . ebs_controller_assume_role_policy . json
16+ }
17+
18+ resource "aws_iam_role_policy_attachment" "ebs_controller_policy_attachment" {
19+ role = aws_iam_role. eks-ebs . name
20+ policy_arn = " arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy"
21+ }
22+
23+ # Define the IAM policy document for the AssumeRole policy
24+ data "aws_iam_policy_document" "ebs_controller_assume_role_policy" {
25+ statement {
26+ actions = [" sts:AssumeRoleWithWebIdentity" ]
27+ effect = " Allow"
28+ principals {
29+ type = " Federated"
30+ identifiers = [" arn:aws:iam::${ data . aws_caller_identity . current . account_id } :oidc-provider/${ module . eks . oidc_provider } " ]
31+ }
32+ condition {
33+ test = " StringEquals"
34+ variable = " ${ module . eks . oidc_provider } :aud"
35+ values = [" sts.amazonaws.com" ]
36+ }
37+ condition {
38+ test = " StringEquals"
39+ variable = " ${ module . eks . oidc_provider } :sub"
40+ values = [" system:serviceaccount:kube-system:ebs-csi-controller-sa" ]
41+ }
42+ }
43+ }
Original file line number Diff line number Diff line change @@ -13,6 +13,6 @@ terraform {
1313 backend "s3" {
1414 region = " us-east-1"
1515 bucket = " devops4solutions-terraform"
16- key = " eks_cluster_2 .tfstate"
16+ key = " eks_cluster_3 .tfstate"
1717 }
1818}
Original file line number Diff line number Diff line change 11module "vpc" {
22 source = " terraform-aws-modules/vpc/aws"
3- name = " eks-vpc1 "
4- cidr = " 11 .0.0.0/16"
3+ name = " eks-vpc "
4+ cidr = " 12 .0.0.0/16"
55
66 azs = [" us-east-1a" , " us-east-1b" , " us-east-1c" ]
7- private_subnets = [" 11 .0.1.0/24" , " 11 .0.2.0/24" , " 11 .0.3.0/24" ]
8- public_subnets = [" 11 .0.101.0/24" , " 11 .0.102.0/24" , " 11 .0.103.0/24" ]
7+ private_subnets = [" 12 .0.1.0/24" , " 12 .0.2.0/24" , " 12 .0.3.0/24" ]
8+ public_subnets = [" 12 .0.101.0/24" , " 12 .0.102.0/24" , " 12 .0.103.0/24" ]
99 enable_nat_gateway = true
1010 single_nat_gateway = true
1111 one_nat_gateway_per_az = false
You can’t perform that action at this time.
0 commit comments