├── outputs.tf ├── backend.tf ├── access_entries.tf ├── kms.tf ├── oidc.tf ├── helm_metrics_server.tf ├── aws-auth.tf ├── providers.tf ├── data.tf ├── helm_kube_state_metrics.tf ├── eks.tf ├── iam_cluster.tf ├── nodes.tf ├── sg.tf ├── .gitignore ├── LICENSE ├── addons.tf ├── iam_nodes.tf ├── variables.tf ├── assets └── chip-primeira-aula.yml └── README.md /outputs.tf: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /backend.tf: -------------------------------------------------------------------------------- 1 | terraform { 2 | backend "s3" { 3 | 4 | } 5 | } -------------------------------------------------------------------------------- /access_entries.tf: -------------------------------------------------------------------------------- 1 | resource "aws_eks_access_entry" "nodes" { 2 | cluster_name = aws_eks_cluster.main.id 3 | principal_arn = aws_iam_role.eks_nodes_role.arn 4 | type = "EC2_LINUX" 5 | } -------------------------------------------------------------------------------- /kms.tf: -------------------------------------------------------------------------------- 1 | resource "aws_kms_key" "main" { 2 | description = var.project_name 3 | } 4 | 5 | resource "aws_kms_alias" "main" { 6 | name = format("alias/%s", var.project_name) 7 | target_key_id = aws_kms_key.main.id 8 | } -------------------------------------------------------------------------------- /oidc.tf: -------------------------------------------------------------------------------- 1 | data "tls_certificate" "eks" { 2 | url = aws_eks_cluster.main.identity[0].oidc[0].issuer 3 | } 4 | 5 | resource "aws_iam_openid_connect_provider" "eks" { 6 | client_id_list = ["sts.amazonaws.com"] 7 | thumbprint_list = [ 8 | data.tls_certificate.eks.certificates[0].sha1_fingerprint, 9 | "9e99a48a9960b14926bb7f3b02e22da2b0ab7280" 10 | ] 11 | url = flatten(concat(aws_eks_cluster.main[*].identity[*].oidc.0.issuer, [""]))[0] 12 | } -------------------------------------------------------------------------------- /helm_metrics_server.tf: -------------------------------------------------------------------------------- 1 | resource "helm_release" "metrics_server" { 2 | name = "metrics-server" 3 | repository = "https://charts.bitnami.com/bitnami" 4 | chart = "metrics-server" 5 | namespace = "kube-system" 6 | 7 | wait = false 8 | 9 | version = "7.2.16" 10 | 11 | set { 12 | name = "apiService.create" 13 | value = "true" 14 | } 15 | 16 | depends_on = [ 17 | aws_eks_cluster.main, 18 | aws_eks_node_group.main 19 | ] 20 | } -------------------------------------------------------------------------------- /aws-auth.tf: -------------------------------------------------------------------------------- 1 | # resource "kubernetes_config_map" "aws-auth" { 2 | # metadata { 3 | # name = "aws-auth" 4 | # namespace = "kube-system" 5 | # } 6 | 7 | # data = { 8 | # mapRoles = < 5 | ## Requirements 6 | 7 | No requirements. 8 | 9 | ## Providers 10 | 11 | | Name | Version | 12 | |------|---------| 13 | | [aws](#provider\_aws) | 5.80.0 | 14 | | [helm](#provider\_helm) | 2.16.1 | 15 | | [tls](#provider\_tls) | 4.0.6 | 16 | 17 | ## Modules 18 | 19 | No modules. 20 | 21 | ## Resources 22 | 23 | | Name | Type | 24 | |------|------| 25 | | [aws_eks_access_entry.nodes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_access_entry) | resource | 26 | | [aws_eks_addon.cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_addon) | resource | 27 | | [aws_eks_addon.coredns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_addon) | resource | 28 | | [aws_eks_addon.kubeproxy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_addon) | resource | 29 | | [aws_eks_cluster.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_cluster) | resource | 30 | | [aws_eks_node_group.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/eks_node_group) | resource | 31 | | [aws_iam_instance_profile.nodes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_instance_profile) | resource | 32 | | [aws_iam_openid_connect_provider.eks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_openid_connect_provider) | resource | 33 | | [aws_iam_role.eks_cluster_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 34 | | [aws_iam_role.eks_nodes_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | 35 | | [aws_iam_role_policy_attachment.cloudwatch](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 36 | | [aws_iam_role_policy_attachment.cni](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 37 | | [aws_iam_role_policy_attachment.ecr](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 38 | | [aws_iam_role_policy_attachment.eks_cluster_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 39 | | [aws_iam_role_policy_attachment.eks_service_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 40 | | [aws_iam_role_policy_attachment.nodes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 41 | | [aws_iam_role_policy_attachment.ssm](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | 42 | | [aws_kms_alias.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_alias) | resource | 43 | | [aws_kms_key.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/kms_key) | resource | 44 | | [aws_security_group_rule.coredns_tcp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource | 45 | | [aws_security_group_rule.coredns_udp](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource | 46 | | [aws_security_group_rule.nodeports](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/security_group_rule) | resource | 47 | | [helm_release.kube_state_metrics](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | 48 | | [helm_release.metrics_server](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | 49 | | [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | 50 | | [aws_eks_cluster_auth.default](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source | 51 | | [aws_iam_policy_document.cluster](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 52 | | [aws_iam_policy_document.nodes](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | 53 | | [aws_ssm_parameter.pod_subnets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | 54 | | [aws_ssm_parameter.private_subnets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | 55 | | [aws_ssm_parameter.public_subnets](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | 56 | | [aws_ssm_parameter.vpc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/ssm_parameter) | data source | 57 | | [tls_certificate.eks](https://registry.terraform.io/providers/hashicorp/tls/latest/docs/data-sources/certificate) | data source | 58 | 59 | ## Inputs 60 | 61 | | Name | Description | Type | Default | Required | 62 | |------|-------------|------|---------|:--------:| 63 | | [addon\_cni\_version](#input\_addon\_cni\_version) | Versão do Addon da VPC CNI | `string` | `"v1.18.3-eksbuild.2"` | no | 64 | | [addon\_coredns\_version](#input\_addon\_coredns\_version) | Versão do Addon do CoreDNS | `string` | `"v1.11.3-eksbuild.1"` | no | 65 | | [addon\_kubeproxy\_version](#input\_addon\_kubeproxy\_version) | Versão do Addon do Kube-Proxy | `string` | `"v1.31.2-eksbuild.3"` | no | 66 | | [auto\_scale\_options](#input\_auto\_scale\_options) | Configurações de Autoscaling do Cluster |
object({
min = number
max = number
desired = number
})
| n/a | yes | 67 | | [k8s\_version](#input\_k8s\_version) | Versão do kubernetes do projeto | `string` | n/a | yes | 68 | | [nodes\_instance\_sizes](#input\_nodes\_instance\_sizes) | Lista de tamanhos das instâncias do projeto | `list(string)` | n/a | yes | 69 | | [project\_name](#input\_project\_name) | Nome do projeto / cluster | `string` | n/a | yes | 70 | | [region](#input\_region) | Nome da região onde os recursos serão entregues | `string` | n/a | yes | 71 | | [ssm\_pod\_subnets](#input\_ssm\_pod\_subnets) | Lista dos ID's do SSM onde estão as subnets de pods do projeto | `list(string)` | n/a | yes | 72 | | [ssm\_private\_subnets](#input\_ssm\_private\_subnets) | Lista dos ID's do SSM onde estão as subnets privadas do projeto | `list(string)` | n/a | yes | 73 | | [ssm\_public\_subnets](#input\_ssm\_public\_subnets) | Lista dos ID's do SSM onde estão as subnets públicas do projeto | `list(string)` | n/a | yes | 74 | | [ssm\_vpc](#input\_ssm\_vpc) | ID do SSM onde está o id da VPC onde o projeto será criado | `string` | n/a | yes | 75 | 76 | ## Outputs 77 | 78 | No outputs. 79 | --------------------------------------------------------------------------------