Skip to content

Commit

Permalink
Update to support kubernetes provider v2 (cloudposse#93)
Browse files Browse the repository at this point in the history
  • Loading branch information
woz5999 authored Jan 22, 2021
1 parent 72a5458 commit bef1d41
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 32 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ Available targets:
|------|---------|
| terraform | >= 0.12.26 |
| aws | >= 2.0 |
| kubernetes | ~> 1.11 |
| kubernetes | >= 2.0 |
| local | >= 1.3 |
| null | >= 2.0 |
| template | >= 2.0 |
Expand All @@ -327,7 +327,7 @@ Available targets:
| Name | Version |
|------|---------|
| aws | >= 2.0 |
| kubernetes | ~> 1.11 |
| kubernetes | >= 2.0 |
| null | >= 2.0 |

## Inputs
Expand All @@ -344,7 +344,7 @@ Available targets:
| cluster\_encryption\_config\_kms\_key\_enable\_key\_rotation | Cluster Encryption Config KMS Key Resource argument - enable kms key rotation | `bool` | `true` | no |
| cluster\_encryption\_config\_kms\_key\_id | Specify KMS Key Id ARN to use for cluster encryption config | `string` | `""` | no |
| cluster\_encryption\_config\_kms\_key\_policy | Cluster Encryption Config KMS Key Resource argument - key policy | `string` | `null` | no |
| cluster\_encryption\_config\_resources | Cluster Encryption Config Resources to encrypt, e.g. ['secrets'] | `list` | <pre>[<br> "secrets"<br>]</pre> | no |
| cluster\_encryption\_config\_resources | Cluster Encryption Config Resources to encrypt, e.g. ['secrets'] | `list(any)` | <pre>[<br> "secrets"<br>]</pre> | no |
| cluster\_log\_retention\_period | Number of days to retain cluster logs. Requires `enabled_cluster_log_types` to be set. See https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. | `number` | `0` | no |
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
Expand All @@ -355,8 +355,6 @@ Available targets:
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
| kubernetes\_config\_map\_ignore\_role\_changes | Set to `true` to ignore IAM role changes in the Kubernetes Auth ConfigMap | `bool` | `true` | no |
| kubernetes\_config\_path | Path to the kube config file. Defaults to `~/.kube/config` | `string` | `"~/.kube/config"` | no |
| kubernetes\_load\_config\_file | Loads the default local config of ~/.kube/config for the provider, which is useful for resolving migration issues like `Error: configmaps "aws-auth" already exists` | `bool` | `false` | no |
| kubernetes\_version | Desired Kubernetes master version. If you do not specify a value, the latest available version is used | `string` | `"1.15"` | no |
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
| local\_exec\_interpreter | shell to use for local\_exec | `list(string)` | <pre>[<br> "/bin/sh",<br> "-c"<br>]</pre> | no |
Expand Down
2 changes: 0 additions & 2 deletions auth.tf
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,6 @@ provider "kubernetes" {
token = join("", data.aws_eks_cluster_auth.eks.*.token)
host = join("", data.aws_eks_cluster.eks.*.endpoint)
cluster_ca_certificate = base64decode(join("", data.aws_eks_cluster.eks.*.certificate_authority.0.data))
load_config_file = var.kubernetes_load_config_file
config_path = var.kubernetes_config_path
}

resource "kubernetes_config_map" "aws_auth_ignore_changes" {
Expand Down
8 changes: 3 additions & 5 deletions docs/terraform.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
|------|---------|
| terraform | >= 0.12.26 |
| aws | >= 2.0 |
| kubernetes | ~> 1.11 |
| kubernetes | >= 2.0 |
| local | >= 1.3 |
| null | >= 2.0 |
| template | >= 2.0 |
Expand All @@ -15,7 +15,7 @@
| Name | Version |
|------|---------|
| aws | >= 2.0 |
| kubernetes | ~> 1.11 |
| kubernetes | >= 2.0 |
| null | >= 2.0 |

## Inputs
Expand All @@ -32,7 +32,7 @@
| cluster\_encryption\_config\_kms\_key\_enable\_key\_rotation | Cluster Encryption Config KMS Key Resource argument - enable kms key rotation | `bool` | `true` | no |
| cluster\_encryption\_config\_kms\_key\_id | Specify KMS Key Id ARN to use for cluster encryption config | `string` | `""` | no |
| cluster\_encryption\_config\_kms\_key\_policy | Cluster Encryption Config KMS Key Resource argument - key policy | `string` | `null` | no |
| cluster\_encryption\_config\_resources | Cluster Encryption Config Resources to encrypt, e.g. ['secrets'] | `list` | <pre>[<br> "secrets"<br>]</pre> | no |
| cluster\_encryption\_config\_resources | Cluster Encryption Config Resources to encrypt, e.g. ['secrets'] | `list(any)` | <pre>[<br> "secrets"<br>]</pre> | no |
| cluster\_log\_retention\_period | Number of days to retain cluster logs. Requires `enabled_cluster_log_types` to be set. See https://docs.aws.amazon.com/en_us/eks/latest/userguide/control-plane-logs.html. | `number` | `0` | no |
| context | Single object for setting entire context at once.<br>See description of individual variables for details.<br>Leave string and numeric variables as `null` to use default value.<br>Individual variable settings (non-null) override settings in context object,<br>except for attributes, tags, and additional\_tag\_map, which are merged. | <pre>object({<br> enabled = bool<br> namespace = string<br> environment = string<br> stage = string<br> name = string<br> delimiter = string<br> attributes = list(string)<br> tags = map(string)<br> additional_tag_map = map(string)<br> regex_replace_chars = string<br> label_order = list(string)<br> id_length_limit = number<br> })</pre> | <pre>{<br> "additional_tag_map": {},<br> "attributes": [],<br> "delimiter": null,<br> "enabled": true,<br> "environment": null,<br> "id_length_limit": null,<br> "label_order": [],<br> "name": null,<br> "namespace": null,<br> "regex_replace_chars": null,<br> "stage": null,<br> "tags": {}<br>}</pre> | no |
| delimiter | Delimiter to be used between `namespace`, `environment`, `stage`, `name` and `attributes`.<br>Defaults to `-` (hyphen). Set to `""` to use no delimiter at all. | `string` | `null` | no |
Expand All @@ -43,8 +43,6 @@
| environment | Environment, e.g. 'uw2', 'us-west-2', OR 'prod', 'staging', 'dev', 'UAT' | `string` | `null` | no |
| id\_length\_limit | Limit `id` to this many characters.<br>Set to `0` for unlimited length.<br>Set to `null` for default, which is `0`.<br>Does not affect `id_full`. | `number` | `null` | no |
| kubernetes\_config\_map\_ignore\_role\_changes | Set to `true` to ignore IAM role changes in the Kubernetes Auth ConfigMap | `bool` | `true` | no |
| kubernetes\_config\_path | Path to the kube config file. Defaults to `~/.kube/config` | `string` | `"~/.kube/config"` | no |
| kubernetes\_load\_config\_file | Loads the default local config of ~/.kube/config for the provider, which is useful for resolving migration issues like `Error: configmaps "aws-auth" already exists` | `bool` | `false` | no |
| kubernetes\_version | Desired Kubernetes master version. If you do not specify a value, the latest available version is used | `string` | `"1.15"` | no |
| label\_order | The naming order of the id output and Name tag.<br>Defaults to ["namespace", "environment", "stage", "name", "attributes"].<br>You can omit any of the 5 elements, but at least one must be present. | `list(string)` | `null` | no |
| local\_exec\_interpreter | shell to use for local\_exec | `list(string)` | <pre>[<br> "/bin/sh",<br> "-c"<br>]</pre> | no |
Expand Down
2 changes: 1 addition & 1 deletion examples/complete/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ terraform {
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 1.11"
version = ">= 2.0"
}
}
}
4 changes: 1 addition & 3 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ clean:
all: module examples/complete

## Run basic sanity checks against the module itself
# module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions
# The kubernetes provider needs to be pinned because 2.x has breaking changes
module: export TESTS ?= installed lint get-modules module-pinning get-plugins validate terraform-docs input-descriptions output-descriptions
module: export TESTS ?= installed lint get-modules module-pinning get-plugins provider-pinning validate terraform-docs input-descriptions output-descriptions
module: deps
$(call RUN_TESTS, ../)

Expand Down
14 changes: 1 addition & 13 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,6 @@ variable "kubernetes_version" {
description = "Desired Kubernetes master version. If you do not specify a value, the latest available version is used"
}

variable "kubernetes_config_path" {
type = string
default = "~/.kube/config"
description = "Path to the kube config file. Defaults to `~/.kube/config`"
}

variable "kubernetes_load_config_file" {
type = bool
default = false
description = "Loads the default local config of ~/.kube/config for the provider, which is useful for resolving migration issues like `Error: configmaps \"aws-auth\" already exists`"
}

variable "oidc_provider_enabled" {
type = bool
default = false
Expand Down Expand Up @@ -176,7 +164,7 @@ variable "cluster_encryption_config_kms_key_policy" {
}

variable "cluster_encryption_config_resources" {
type = list
type = list(any)
default = ["secrets"]
description = "Cluster Encryption Config Resources to encrypt, e.g. ['secrets']"
}
4 changes: 1 addition & 3 deletions versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,8 @@ terraform {
version = ">= 1.3"
}
kubernetes = {
# Version 2.0 has breaking changes, this module needs conversion to use it.
# After converting to 2.0, restore the provider-pinning Bats test in test/Makefile
source = "hashicorp/kubernetes"
version = "~> 1.11"
version = ">= 2.0"
}
}
}

0 comments on commit bef1d41

Please sign in to comment.