Skip to content

Commit d7b0712

Browse files
authored
Update EKS basic components (cloudposse/terraform-aws-components#509)
1 parent afb68af commit d7b0712

File tree

6 files changed

+51
-67
lines changed

6 files changed

+51
-67
lines changed

src/README.md

Lines changed: 13 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Component: `external-dns`
1+
# Component: `eks/external-dns`
22

33
This component creates a Helm deployment for [external-dns](https://github.com/bitnami/bitnami-docker-external-dns) on a Kubernetes cluster. [external-dns](https://github.com/bitnami/bitnami-docker-external-dns) is a Kubernetes addon that configures public DNS servers with information about exposed Kubernetes services to make them discoverable.
44

@@ -20,22 +20,14 @@ The default catalog values `e.g. stacks/catalog/eks/external-dns.yaml`
2020
components:
2121
terraform:
2222
external-dns:
23-
backend:
24-
s3:
25-
workspace_key_prefix: external-dns
2623
vars:
2724
enabled: true
28-
chart_version: 5.4.7
29-
crd_enabled: false
30-
istio_enabled: false
31-
# txt_prefix will have -${STAGE}- appended
32-
txt_prefix: "external-dns"
33-
policy: "sync"
34-
# Teleport, for one, needs publishInternalServices: true
35-
publish_internal_services: true
36-
rbac_enabled: true
37-
# Must be "external-dns", IAM role will not work
38-
service_account_name: "external-dns"
25+
name: external-dns
26+
chart: external-dns
27+
chart_repository: https://charts.bitnami.com/bitnami
28+
chart_version: "6.7.5"
29+
create_namespace: true
30+
kubernetes_namespace: external-dns
3931

4032
# Resources
4133
limit_cpu: "200m"
@@ -59,31 +51,30 @@ components:
5951
| Name | Version |
6052
|------|---------|
6153
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
62-
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.0 |
54+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9.0 |
6355
| <a name="requirement_helm"></a> [helm](#requirement\_helm) | >= 2.0 |
56+
| <a name="requirement_kubernetes"></a> [kubernetes](#requirement\_kubernetes) | >= 2.7.1 |
6457
6558
## Providers
6659
6760
| Name | Version |
6861
|------|---------|
69-
| <a name="provider_aws"></a> [aws](#provider\_aws) | ~> 4.0 |
70-
| <a name="provider_kubernetes"></a> [kubernetes](#provider\_kubernetes) | n/a |
62+
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9.0 |
7163
7264
## Modules
7365
7466
| Name | Source | Version |
7567
|------|--------|---------|
76-
| <a name="module_dns_gbl_delegated"></a> [dns\_gbl\_delegated](#module\_dns\_gbl\_delegated) | cloudposse/stack-config/yaml//modules/remote-state | 0.22.4 |
77-
| <a name="module_eks"></a> [eks](#module\_eks) | cloudposse/stack-config/yaml//modules/remote-state | 0.22.4 |
78-
| <a name="module_external_dns"></a> [external\_dns](#module\_external\_dns) | cloudposse/helm-release/aws | 0.5.0 |
68+
| <a name="module_dns_gbl_delegated"></a> [dns\_gbl\_delegated](#module\_dns\_gbl\_delegated) | cloudposse/stack-config/yaml//modules/remote-state | 1.3.1 |
69+
| <a name="module_eks"></a> [eks](#module\_eks) | cloudposse/stack-config/yaml//modules/remote-state | 1.3.1 |
70+
| <a name="module_external_dns"></a> [external\_dns](#module\_external\_dns) | cloudposse/helm-release/aws | 0.7.0 |
7971
| <a name="module_iam_roles"></a> [iam\_roles](#module\_iam\_roles) | ../../account-map/modules/iam-roles | n/a |
8072
| <a name="module_this"></a> [this](#module\_this) | cloudposse/label/null | 0.25.0 |
8173
8274
## Resources
8375
8476
| Name | Type |
8577
|------|------|
86-
| [kubernetes_namespace.default](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/namespace) | resource |
8778
| [aws_eks_cluster_auth.eks](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/eks_cluster_auth) | data source |
8879
| [aws_partition.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/partition) | data source |
8980

src/default.auto.tfvars

Lines changed: 0 additions & 12 deletions
This file was deleted.

src/main.tf

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,31 +16,24 @@ data "aws_partition" "current" {
1616
count = local.enabled ? 1 : 0
1717
}
1818

19-
resource "kubernetes_namespace" "default" {
20-
count = local.enabled && var.create_namespace ? 1 : 0
21-
22-
metadata {
23-
name = var.kubernetes_namespace
24-
25-
labels = module.this.tags
26-
}
27-
}
28-
2919
module "external_dns" {
3020
source = "cloudposse/helm-release/aws"
31-
version = "0.5.0"
21+
version = "0.7.0"
22+
23+
name = module.this.name
24+
chart = var.chart
25+
repository = var.chart_repository
26+
description = var.chart_description
27+
chart_version = var.chart_version
28+
wait = var.wait
29+
atomic = var.atomic
30+
cleanup_on_fail = var.cleanup_on_fail
31+
timeout = var.timeout
32+
33+
create_namespace_with_kubernetes = var.create_namespace
34+
kubernetes_namespace = var.kubernetes_namespace
35+
kubernetes_namespace_labels = merge(module.this.tags, { name = var.kubernetes_namespace })
3236

33-
name = module.this.name
34-
chart = var.chart
35-
repository = var.chart_repository
36-
description = var.chart_description
37-
chart_version = var.chart_version
38-
kubernetes_namespace = join("", kubernetes_namespace.default.*.id)
39-
create_namespace = false
40-
wait = var.wait
41-
atomic = var.atomic
42-
cleanup_on_fail = var.cleanup_on_fail
43-
timeout = var.timeout
4437

4538
eks_cluster_oidc_issuer_url = replace(module.eks.outputs.eks_cluster_identity_oidc_issuer, "https://", "")
4639

src/provider-helm.tf

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
#
33
# This file is a drop-in to provide a helm provider.
44
#
5+
# It depends on 2 standard Cloud Posse data source modules to be already
6+
# defined in the same component:
7+
#
8+
# 1. module.iam_roles to provide the AWS profile or Role ARN to use to access the cluster
9+
# 2. module.eks to provide the EKS cluster information
10+
#
511
# All the following variables are just about configuring the Kubernetes provider
612
# to be able to modify EKS cluster. The reason there are so many options is
713
# because at various times, each one of them has had problems, so we give you a choice.
@@ -100,9 +106,11 @@ locals {
100106
"--role-arn", local.kube_exec_auth_role_arn
101107
] : []
102108

103-
certificate_authority_data = module.eks.outputs.eks_cluster_certificate_authority_data
104-
eks_cluster_id = module.eks.outputs.eks_cluster_id
105-
eks_cluster_endpoint = module.eks.outputs.eks_cluster_endpoint
109+
# Provide dummy configuration for the case where the EKS cluster is not available.
110+
certificate_authority_data = try(module.eks.outputs.eks_cluster_certificate_authority_data, "")
111+
# Use coalesce+try to handle both the case where the output is missing and the case where it is empty.
112+
eks_cluster_id = coalesce(try(module.eks.outputs.eks_cluster_id, ""), "missing")
113+
eks_cluster_endpoint = try(module.eks.outputs.eks_cluster_endpoint, "")
106114
}
107115

108116
data "aws_eks_cluster_auth" "eks" {
@@ -114,14 +122,14 @@ provider "helm" {
114122
kubernetes {
115123
host = local.eks_cluster_endpoint
116124
cluster_ca_certificate = base64decode(local.certificate_authority_data)
117-
token = local.kube_data_auth_enabled ? data.aws_eks_cluster_auth.eks[0].token : null
125+
token = local.kube_data_auth_enabled ? one(data.aws_eks_cluster_auth.eks[*].token) : null
118126
# The Kubernetes provider will use information from KUBECONFIG if it exists, but if the default cluster
119127
# in KUBECONFIG is some other cluster, this will cause problems, so we override it always.
120128
config_path = local.kubeconfig_file_enabled ? var.kubeconfig_file : ""
121129
config_context = var.kubeconfig_context
122130

123131
dynamic "exec" {
124-
for_each = local.kube_exec_auth_enabled ? ["exec"] : []
132+
for_each = local.kube_exec_auth_enabled && length(local.certificate_authority_data) > 0 ? ["exec"] : []
125133
content {
126134
api_version = local.kubeconfig_exec_auth_api_version
127135
command = "aws"
@@ -132,21 +140,21 @@ provider "helm" {
132140
}
133141
}
134142
experiments {
135-
manifest = var.helm_manifest_experiment_enabled
143+
manifest = var.helm_manifest_experiment_enabled && module.this.enabled
136144
}
137145
}
138146

139147
provider "kubernetes" {
140148
host = local.eks_cluster_endpoint
141149
cluster_ca_certificate = base64decode(local.certificate_authority_data)
142-
token = local.kube_data_auth_enabled ? data.aws_eks_cluster_auth.eks[0].token : null
150+
token = local.kube_data_auth_enabled ? one(data.aws_eks_cluster_auth.eks[*].token) : null
143151
# The Kubernetes provider will use information from KUBECONFIG if it exists, but if the default cluster
144152
# in KUBECONFIG is some other cluster, this will cause problems, so we override it always.
145153
config_path = local.kubeconfig_file_enabled ? var.kubeconfig_file : ""
146154
config_context = var.kubeconfig_context
147155

148156
dynamic "exec" {
149-
for_each = local.kube_exec_auth_enabled ? ["exec"] : []
157+
for_each = local.kube_exec_auth_enabled && length(local.certificate_authority_data) > 0 ? ["exec"] : []
150158
content {
151159
api_version = local.kubeconfig_exec_auth_api_version
152160
command = "aws"

src/remote-state.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module "eks" {
22
source = "cloudposse/stack-config/yaml//modules/remote-state"
3-
version = "0.22.4"
3+
version = "1.3.1"
44

55
component = var.eks_component_name
66

@@ -9,7 +9,7 @@ module "eks" {
99

1010
module "dns_gbl_delegated" {
1111
source = "cloudposse/stack-config/yaml//modules/remote-state"
12-
version = "0.22.4"
12+
version = "1.3.1"
1313

1414
component = "dns-delegated"
1515
environment = var.dns_gbl_delegated_environment_name

src/versions.tf

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@ terraform {
44
required_providers {
55
aws = {
66
source = "hashicorp/aws"
7-
version = "~> 4.0"
7+
version = ">= 4.9.0"
88
}
99
helm = {
1010
source = "hashicorp/helm"
1111
version = ">= 2.0"
1212
}
13+
kubernetes = {
14+
source = "hashicorp/kubernetes"
15+
version = ">= 2.7.1"
16+
}
1317
}
1418
}

0 commit comments

Comments
 (0)