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

terraform apply fails on default install on Windows #278

Closed
GPWebb opened this issue Jun 10, 2021 · 2 comments · Fixed by #296
Closed

terraform apply fails on default install on Windows #278

GPWebb opened this issue Jun 10, 2021 · 2 comments · Fixed by #296

Comments

@GPWebb
Copy link

GPWebb commented Jun 10, 2021

I have Terraform 0.14.11 installed with Jenkins-X 3.2.127 cli on Windows 10.

Following JX3's terraform quickstart guide (https://github.com/jx3-gitops-repositories/jx3-terraform-eks/blob/main/README.md), I've worked through to step 6 -

terraform init

terraform plan

terraform apply

(NB step 5 has already had to be specifically run via bash, it doesn't work on cmd.exe)

terraform apply appears to fail on Windows on the default install, either in cmd.exe or bash.exe (from Git).

Expected behavior

The command should run and return without error.

Actual behavior

Error: Error running command 'for i in `seq 1 60`; do if `command -v wget > /dev/null`; then wget --no-check-certificate -O - -q $ENDPOINT/healthz >/dev/null && exit 0 || true; else curl -k -s $ENDPOINT/healthz >/dev/null && exit 0 || true;fi; sleep 5; done; echo TIMEOUT && exit 1': exec: "/bin/sh": file does not exist. Output:
Error: timed out waiting for the condition
  on .terraform\modules\eks-jx\modules\vault\charts.tf line 1, in resource "helm_release" "vault-operator":
   1: resource "helm_release" "vault-operator" {

terraform-aws-modules/terraform-aws-eks#925 suggests adding an additional section, but doesn't specify where. By trial and error I've found it helps if in the module "eks" { section.

resource "null_resource" "kubeconfig" { also references /bin/bash

Terraform version

Terraform v0.14.11

  • provider registry.terraform.io/hashicorp/aws v3.42.0
  • provider registry.terraform.io/hashicorp/helm v2.1.2
  • provider registry.terraform.io/hashicorp/kubernetes v2.2.0
  • provider registry.terraform.io/hashicorp/local v2.1.0
  • provider registry.terraform.io/hashicorp/null v3.1.0
  • provider registry.terraform.io/hashicorp/random v3.1.0
  • provider registry.terraform.io/hashicorp/template v2.2.0

Operating system

Windows 10, 10.0.19041 N/A Build 19041

@GPWebb
Copy link
Author

GPWebb commented Jun 10, 2021

And, bang on cue, I've found the solution...

module "eks" {
...
  # ADD THIS FOR WINDOWS ONLY
  wait_for_cluster_interpreter = ["{{Your local path to sh.exe, usually installed with git}}", "-c"]
  wait_for_cluster_cmd         = "until curl -sk $ENDPOINT >/dev/null; do sleep 4; done"
resource "null_resource" "kubeconfig" {
  depends_on = [
    module.eks
  ]
  provisioner "local-exec" {
    command     = "aws eks update-kubeconfig --name ${var.cluster_name} --region=${var.region}"
   # CHANGE THIS FOR WINDOWS ONLY
    interpreter = ["{{Your local path to bash.exe, also usually installed with git}}", "-c"]
  }
}

(As an aside, why is one part depending on sh and another on bash?)

@ankitm123
Copy link
Member

This still needs to go into the module, else everytime you remove .terraform, the change is gone!

(As an aside, why is one part depending on sh and another on bash?)

One is from this module, and the other from community eks module 😬

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 a pull request may close this issue.

2 participants