From 8fd462a533ee83cc15c2a5de92b85853f46be9b0 Mon Sep 17 00:00:00 2001 From: Daniel Piddock Date: Fri, 13 Mar 2020 15:30:55 +0100 Subject: [PATCH 1/2] Create an example with create_eks = false --- examples/create_false/main.tf | 30 ++++++++++++++++++++++++++++++ examples/create_false/variables.tf | 3 +++ 2 files changed, 33 insertions(+) create mode 100644 examples/create_false/main.tf create mode 100644 examples/create_false/variables.tf diff --git a/examples/create_false/main.tf b/examples/create_false/main.tf new file mode 100644 index 0000000000..86604aacdd --- /dev/null +++ b/examples/create_false/main.tf @@ -0,0 +1,30 @@ +provider "aws" { + region = var.region +} + +data "aws_eks_cluster" "cluster" { + count = 0 + name = module.eks.cluster_id +} + +data "aws_eks_cluster_auth" "cluster" { + count = 0 + name = module.eks.cluster_id +} + +provider "kubernetes" { + host = element(concat(data.aws_eks_cluster.cluster[*].endpoint, list("")), 0) + cluster_ca_certificate = base64decode(element(concat(data.aws_eks_cluster.cluster[*].certificate_authority.0.data, list("")), 0)) + token = element(concat(data.aws_eks_cluster_auth.cluster[*].token, list("")), 0) + load_config_file = false + version = "~> 1.11" +} + +module "eks" { + source = "../.." + create_eks = false + + vpc_id = "" + cluster_name = "" + subnets = [] +} diff --git a/examples/create_false/variables.tf b/examples/create_false/variables.tf new file mode 100644 index 0000000000..81b8dbe73e --- /dev/null +++ b/examples/create_false/variables.tf @@ -0,0 +1,3 @@ +variable "region" { + default = "us-west-2" +} From 40e6745dea1f4ed6831539770b9deeceb576a163 Mon Sep 17 00:00:00 2001 From: Daniel Piddock Date: Fri, 13 Mar 2020 15:34:45 +0100 Subject: [PATCH 2/2] fix: apply clean with no changes Otherwise it gets stuck forever waiting for a cluster that isn't there to respond. --- cluster.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cluster.tf b/cluster.tf index 2e0ca6862a..c558e52a66 100644 --- a/cluster.tf +++ b/cluster.tf @@ -46,7 +46,7 @@ resource "aws_eks_cluster" "this" { } resource "null_resource" "wait_for_cluster" { - count = var.manage_aws_auth ? 1 : 0 + count = var.create_eks && var.manage_aws_auth ? 1 : 0 depends_on = [ aws_eks_cluster.this[0]