Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding IRSA for load balancer controller #29

Merged
merged 1 commit into from
Jun 12, 2024

Conversation

caiocsgomes
Copy link
Owner

No description provided.

Copy link

Terraform plan

Click to see the plan
[command]/home/runner/work/_temp/89c69e12-a41b-4648-9056-5bf33e3a3c3c/terraform-bin show -no-color plan.tmp

Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # aws_iam_policy.load_balancer_controller_iam_policy will be created
  + resource "aws_iam_policy" "load_balancer_controller_iam_policy" {
      + arn         = (known after apply)
      + description = "IAM policy for the AWS Load Balancer Controller"
      + id          = (known after apply)
      + name        = "AWSLoadBalancerControllerIAMPolicy"
      + name_prefix = (known after apply)
      + path        = "/"
      + policy      = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = [
                          + "iam:CreateServiceLinkedRole",
                        ]
                      + Condition = {
                          + StringEquals = {
                              + "iam:AWSServiceName" = "elasticloadbalancing.amazonaws.com"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "*"
                    },
                  + {
                      + Action   = [
                          + "ec2:DescribeAccountAttributes",
                          + "ec2:DescribeAddresses",
                          + "ec2:DescribeAvailabilityZones",
                          + "ec2:DescribeInternetGateways",
                          + "ec2:DescribeVpcs",
                          + "ec2:DescribeVpcPeeringConnections",
                          + "ec2:DescribeSubnets",
                          + "ec2:DescribeSecurityGroups",
                          + "ec2:DescribeInstances",
                          + "ec2:DescribeNetworkInterfaces",
                          + "ec2:DescribeTags",
                          + "ec2:GetCoipPoolUsage",
                          + "ec2:DescribeCoipPools",
                          + "elasticloadbalancing:DescribeLoadBalancers",
                          + "elasticloadbalancing:DescribeLoadBalancerAttributes",
                          + "elasticloadbalancing:DescribeListeners",
                          + "elasticloadbalancing:DescribeListenerCertificates",
                          + "elasticloadbalancing:DescribeSSLPolicies",
                          + "elasticloadbalancing:DescribeRules",
                          + "elasticloadbalancing:DescribeTargetGroups",
                          + "elasticloadbalancing:DescribeTargetGroupAttributes",
                          + "elasticloadbalancing:DescribeTargetHealth",
                          + "elasticloadbalancing:DescribeTags",
                          + "elasticloadbalancing:DescribeTrustStores",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                  + {
                      + Action   = [
                          + "cognito-idp:DescribeUserPoolClient",
                          + "acm:ListCertificates",
                          + "acm:DescribeCertificate",
                          + "iam:ListServerCertificates",
                          + "iam:GetServerCertificate",
                          + "waf-regional:GetWebACL",
                          + "waf-regional:GetWebACLForResource",
                          + "waf-regional:AssociateWebACL",
                          + "waf-regional:DisassociateWebACL",
                          + "wafv2:GetWebACL",
                          + "wafv2:GetWebACLForResource",
                          + "wafv2:AssociateWebACL",
                          + "wafv2:DisassociateWebACL",
                          + "shield:GetSubscriptionState",
                          + "shield:DescribeProtection",
                          + "shield:CreateProtection",
                          + "shield:DeleteProtection",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                  + {
                      + Action   = [
                          + "ec2:AuthorizeSecurityGroupIngress",
                          + "ec2:RevokeSecurityGroupIngress",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                  + {
                      + Action   = [
                          + "ec2:CreateSecurityGroup",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                  + {
                      + Action    = [
                          + "ec2:CreateTags",
                        ]
                      + Condition = {
                          + Null         = {
                              + "aws:RequestTag/elbv2.k8s.aws/cluster" = "false"
                            }
                          + StringEquals = {
                              + "ec2:CreateAction" = "CreateSecurityGroup"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "arn:aws:ec2:*:*:security-group/*"
                    },
                  + {
                      + Action    = [
                          + "ec2:CreateTags",
                          + "ec2:DeleteTags",
                        ]
                      + Condition = {
                          + Null = {
                              + "aws:RequestTag/elbv2.k8s.aws/cluster"  = "true"
                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "arn:aws:ec2:*:*:security-group/*"
                    },
                  + {
                      + Action    = [
                          + "ec2:AuthorizeSecurityGroupIngress",
                          + "ec2:RevokeSecurityGroupIngress",
                          + "ec2:DeleteSecurityGroup",
                        ]
                      + Condition = {
                          + Null = {
                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "*"
                    },
                  + {
                      + Action    = [
                          + "elasticloadbalancing:CreateLoadBalancer",
                          + "elasticloadbalancing:CreateTargetGroup",
                        ]
                      + Condition = {
                          + Null = {
                              + "aws:RequestTag/elbv2.k8s.aws/cluster" = "false"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "*"
                    },
                  + {
                      + Action   = [
                          + "elasticloadbalancing:CreateListener",
                          + "elasticloadbalancing:DeleteListener",
                          + "elasticloadbalancing:CreateRule",
                          + "elasticloadbalancing:DeleteRule",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                  + {
                      + Action    = [
                          + "elasticloadbalancing:AddTags",
                          + "elasticloadbalancing:RemoveTags",
                        ]
                      + Condition = {
                          + Null = {
                              + "aws:RequestTag/elbv2.k8s.aws/cluster"  = "true"
                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*",
                        ]
                    },
                  + {
                      + Action   = [
                          + "elasticloadbalancing:AddTags",
                          + "elasticloadbalancing:RemoveTags",
                        ]
                      + Effect   = "Allow"
                      + Resource = [
                          + "arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:listener/app/*/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:listener-rule/net/*/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/*/*/*",
                        ]
                    },
                  + {
                      + Action    = [
                          + "elasticloadbalancing:ModifyLoadBalancerAttributes",
                          + "elasticloadbalancing:SetIpAddressType",
                          + "elasticloadbalancing:SetSecurityGroups",
                          + "elasticloadbalancing:SetSubnets",
                          + "elasticloadbalancing:DeleteLoadBalancer",
                          + "elasticloadbalancing:ModifyTargetGroup",
                          + "elasticloadbalancing:ModifyTargetGroupAttributes",
                          + "elasticloadbalancing:DeleteTargetGroup",
                        ]
                      + Condition = {
                          + Null = {
                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = "*"
                    },
                  + {
                      + Action    = [
                          + "elasticloadbalancing:AddTags",
                        ]
                      + Condition = {
                          + Null         = {
                              + "aws:RequestTag/elbv2.k8s.aws/cluster" = "false"
                            }
                          + StringEquals = {
                              + "elasticloadbalancing:CreateAction" = [
                                  + "CreateTargetGroup",
                                  + "CreateLoadBalancer",
                                ]
                            }
                        }
                      + Effect    = "Allow"
                      + Resource  = [
                          + "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*",
                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*",
                        ]
                    },
                  + {
                      + Action   = [
                          + "elasticloadbalancing:RegisterTargets",
                          + "elasticloadbalancing:DeregisterTargets",
                        ]
                      + Effect   = "Allow"
                      + Resource = "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*"
                    },
                  + {
                      + Action   = [
                          + "elasticloadbalancing:SetWebAcl",
                          + "elasticloadbalancing:ModifyListener",
                          + "elasticloadbalancing:AddListenerCertificates",
                          + "elasticloadbalancing:RemoveListenerCertificates",
                          + "elasticloadbalancing:ModifyRule",
                        ]
                      + Effect   = "Allow"
                      + Resource = "*"
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + policy_id   = (known after apply)
      + tags_all    = (known after apply)
    }

  # module.iam_eks_role.aws_iam_role.this[0] will be created
  + resource "aws_iam_role" "this" {
      + arn                   = (known after apply)
      + assume_role_policy    = jsonencode(
            {
              + Statement = [
                  + {
                      + Action    = "sts:AssumeRoleWithWebIdentity"
                      + Condition = {
                          + StringEquals = {
                              + "oidc.eks.us-east-1.amazonaws.com/id/47830B9C8F914B59332C892E45B43FCB:aud" = "sts.amazonaws.com"
                              + "oidc.eks.us-east-1.amazonaws.com/id/47830B9C8F914B59332C892E45B43FCB:sub" = "system:serviceaccount:kube-system"
                            }
                        }
                      + Effect    = "Allow"
                      + Principal = {
                          + Federated = "arn:aws:iam::322620855520:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/47830B9C8F914B59332C892E45B43FCB"
                        }
                    },
                ]
              + Version   = "2012-10-17"
            }
        )
      + create_date           = (known after apply)
      + force_detach_policies = true
      + id                    = (known after apply)
      + managed_policy_arns   = (known after apply)
      + max_session_duration  = 3600
      + name                  = "aws-load-balancer-controller"
      + name_prefix           = (known after apply)
      + path                  = "/"
      + tags_all              = (known after apply)
      + unique_id             = (known after apply)
    }

  # module.iam_eks_role.aws_iam_role_policy_attachment.this["policy"] will be created
  + resource "aws_iam_role_policy_attachment" "this" {
      + id         = (known after apply)
      + policy_arn = (known after apply)
      + role       = "aws-load-balancer-controller"
    }

Plan: 3 to add, 0 to change, 0 to destroy.
::debug::Terraform exited with code 0.
::debug::stdout: %0ATerraform used the selected providers to generate the following execution%0Aplan. Resource actions are indicated with the following symbols:%0A  + create%0A%0ATerraform will perform the following actions:%0A%0A  # aws_iam_policy.load_balancer_controller_iam_policy will be created%0A  + resource "aws_iam_policy" "load_balancer_controller_iam_policy" {%0A      + arn         = (known after apply)%0A      + description = "IAM policy for the AWS Load Balancer Controller"%0A      + id          = (known after apply)%0A      + name        = "AWSLoadBalancerControllerIAMPolicy"%0A      + name_prefix = (known after apply)%0A      + path        = "/"%0A      + policy      = jsonencode(%0A            {%0A              + Statement = [%0A                  + {%0A                      + Action    = [%0A                          + "iam:CreateServiceLinkedRole",%0A                        ]%0A                      + Condition = {%0A                          + StringEquals = {%0A                              + "iam:AWSServiceName" = "elasticloadbalancing.amazonaws.com"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = "*"%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "ec2:DescribeAccountAttributes",%0A                          + "ec2:DescribeAddresses",%0A                          + "ec2:DescribeAvailabilityZones",%0A                          + "ec2:DescribeInternetGateways",%0A                          + "ec2:DescribeVpcs",%0A                          + "ec2:DescribeVpcPeeringConnections",%0A                          + "ec2:DescribeSubnets",%0A                          + "ec2:DescribeSecurityGroups",%0A                          + "ec2:DescribeInstances",%0A                          + "ec2:DescribeNetworkInterfaces",%0A                          + "ec2:DescribeTags",%0A                          + "ec2:GetCoipPoolUsage",%0A                          + "ec2:DescribeCoipPools",%0A                          + "elasticloadbalancing:DescribeLoadBalancers",%0A                          + "elasticloadbalancing:DescribeLoadBalancerAttributes",%0A                          + "elasticloadbalancing:DescribeListeners",%0A                          + "elasticloadbalancing:DescribeListenerCertificates",%0A                          + "elasticloadbalancing:DescribeSSLPolicies",%0A                          + "elasticloadbalancing:DescribeRules",%0A                          + "elasticloadbalancing:DescribeTargetGroups",%0A                          + "elasticloadbalancing:DescribeTargetGroupAttributes",%0A                          + "elasticloadbalancing:DescribeTargetHealth",%0A                          + "elasticloadbalancing:DescribeTags",%0A                          + "elasticloadbalancing:DescribeTrustStores",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "*"%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "cognito-idp:DescribeUserPoolClient",%0A                          + "acm:ListCertificates",%0A                          + "acm:DescribeCertificate",%0A                          + "iam:ListServerCertificates",%0A                          + "iam:GetServerCertificate",%0A                          + "waf-regional:GetWebACL",%0A                          + "waf-regional:GetWebACLForResource",%0A                          + "waf-regional:AssociateWebACL",%0A                          + "waf-regional:DisassociateWebACL",%0A                          + "wafv2:GetWebACL",%0A                          + "wafv2:GetWebACLForResource",%0A                          + "wafv2:AssociateWebACL",%0A                          + "wafv2:DisassociateWebACL",%0A                          + "shield:GetSubscriptionState",%0A                          + "shield:DescribeProtection",%0A                          + "shield:CreateProtection",%0A                          + "shield:DeleteProtection",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "*"%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "ec2:AuthorizeSecurityGroupIngress",%0A                          + "ec2:RevokeSecurityGroupIngress",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "*"%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "ec2:CreateSecurityGroup",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "*"%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "ec2:CreateTags",%0A                        ]%0A                      + Condition = {%0A                          + Null         = {%0A                              + "aws:RequestTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                          + StringEquals = {%0A                              + "ec2:CreateAction" = "CreateSecurityGroup"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = "arn:aws:ec2:*:*:security-group/*"%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "ec2:CreateTags",%0A                          + "ec2:DeleteTags",%0A                        ]%0A                      + Condition = {%0A                          + Null = {%0A                              + "aws:RequestTag/elbv2.k8s.aws/cluster"  = "true"%0A                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = "arn:aws:ec2:*:*:security-group/*"%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "ec2:AuthorizeSecurityGroupIngress",%0A                          + "ec2:RevokeSecurityGroupIngress",%0A                          + "ec2:DeleteSecurityGroup",%0A                        ]%0A                      + Condition = {%0A                          + Null = {%0A                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = "*"%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "elasticloadbalancing:CreateLoadBalancer",%0A                          + "elasticloadbalancing:CreateTargetGroup",%0A                        ]%0A                      + Condition = {%0A                          + Null = {%0A                              + "aws:RequestTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = "*"%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "elasticloadbalancing:CreateListener",%0A                          + "elasticloadbalancing:DeleteListener",%0A                          + "elasticloadbalancing:CreateRule",%0A                          + "elasticloadbalancing:DeleteRule",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "*"%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "elasticloadbalancing:AddTags",%0A                          + "elasticloadbalancing:RemoveTags",%0A                        ]%0A                      + Condition = {%0A                          + Null = {%0A                              + "aws:RequestTag/elbv2.k8s.aws/cluster"  = "true"%0A                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = [%0A                          + "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*",%0A                        ]%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "elasticloadbalancing:AddTags",%0A                          + "elasticloadbalancing:RemoveTags",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = [%0A                          + "arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:listener/app/*/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:listener-rule/net/*/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:listener-rule/app/*/*/*",%0A                        ]%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "elasticloadbalancing:ModifyLoadBalancerAttributes",%0A                          + "elasticloadbalancing:SetIpAddressType",%0A                          + "elasticloadbalancing:SetSecurityGroups",%0A                          + "elasticloadbalancing:SetSubnets",%0A                          + "elasticloadbalancing:DeleteLoadBalancer",%0A                          + "elasticloadbalancing:ModifyTargetGroup",%0A                          + "elasticloadbalancing:ModifyTargetGroupAttributes",%0A                          + "elasticloadbalancing:DeleteTargetGroup",%0A                        ]%0A                      + Condition = {%0A                          + Null = {%0A                              + "aws:ResourceTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = "*"%0A                    },%0A                  + {%0A                      + Action    = [%0A                          + "elasticloadbalancing:AddTags",%0A                        ]%0A                      + Condition = {%0A                          + Null         = {%0A                              + "aws:RequestTag/elbv2.k8s.aws/cluster" = "false"%0A                            }%0A                          + StringEquals = {%0A                              + "elasticloadbalancing:CreateAction" = [%0A                                  + "CreateTargetGroup",%0A                                  + "CreateLoadBalancer",%0A                                ]%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Resource  = [%0A                          + "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*",%0A                          + "arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*",%0A                        ]%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "elasticloadbalancing:RegisterTargets",%0A                          + "elasticloadbalancing:DeregisterTargets",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*"%0A                    },%0A                  + {%0A                      + Action   = [%0A                          + "elasticloadbalancing:SetWebAcl",%0A                          + "elasticloadbalancing:ModifyListener",%0A                          + "elasticloadbalancing:AddListenerCertificates",%0A                          + "elasticloadbalancing:RemoveListenerCertificates",%0A                          + "elasticloadbalancing:ModifyRule",%0A                        ]%0A                      + Effect   = "Allow"%0A                      + Resource = "*"%0A                    },%0A                ]%0A              + Version   = "2012-10-17"%0A            }%0A        )%0A      + policy_id   = (known after apply)%0A      + tags_all    = (known after apply)%0A    }%0A%0A  # module.iam_eks_role.aws_iam_role.this[0] will be created%0A  + resource "aws_iam_role" "this" {%0A      + arn                   = (known after apply)%0A      + assume_role_policy    = jsonencode(%0A            {%0A              + Statement = [%0A                  + {%0A                      + Action    = "sts:AssumeRoleWithWebIdentity"%0A                      + Condition = {%0A                          + StringEquals = {%0A                              + "oidc.eks.us-east-1.amazonaws.com/id/47830B9C8F914B59332C892E45B43FCB:aud" = "sts.amazonaws.com"%0A                              + "oidc.eks.us-east-1.amazonaws.com/id/47830B9C8F914B59332C892E45B43FCB:sub" = "system:serviceaccount:kube-system"%0A                            }%0A                        }%0A                      + Effect    = "Allow"%0A                      + Principal = {%0A                          + Federated = "arn:aws:iam::322620855520:oidc-provider/oidc.eks.us-east-1.amazonaws.com/id/47830B9C8F914B59332C892E45B43FCB"%0A                        }%0A                    },%0A                ]%0A              + Version   = "2012-10-17"%0A            }%0A        )%0A      + create_date           = (known after apply)%0A      + force_detach_policies = true%0A      + id                    = (known after apply)%0A      + managed_policy_arns   = (known after apply)%0A      + max_session_duration  = 3600%0A      + name                  = "aws-load-balancer-controller"%0A      + name_prefix           = (known after apply)%0A      + path                  = "/"%0A      + tags_all              = (known after apply)%0A      + unique_id             = (known after apply)%0A    }%0A%0A  # module.iam_eks_role.aws_iam_role_policy_attachment.this["policy"] will be created%0A  + resource "aws_iam_role_policy_attachment" "this" {%0A      + id         = (known after apply)%0A      + policy_arn = (known after apply)%0A      + role       = "aws-load-balancer-controller"%0A    }%0A%0APlan: 3 to add, 0 to change, 0 to destroy.%0A
::debug::stderr: 
::debug::exitcode: 0
 

@caiocsgomes caiocsgomes merged commit e52361f into main Jun 12, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant