When I try to build Microsoft Azure resources using Terraform on a Windows machine, terraform plan times out.
C:\path\to\terraform> terraform plan
Error: timeout while waiting for plugin to start
There was an issue. Error: Failed to instantiate provider "azurerm" to obtain schema: timeout while waiting for plugin to start
Does that happen when you are using a TREND MICRO product (such as OfficeScan) on Windows? And there is a cause in golang, it is not a countermeasure on the Terraform side.
It may be okay if you can take measures such as "procure mac / linux" and "turn off OfficeScan", but in my case it was not. I'm going to run a Linux-based Docker container on a Windows machine and run Terraform there.
your-folder-name/
 ├─ docker/
 │   └─ Dockerfile
 ├─ terraform/
 │   ├─ aaa.tf
 │   ├─ bbb.tf
 │   └ ...
 └─ docker-compose.yml
Dockerfile
FROM alpine:3.7
ARG terraform_version="0.13.1"
# install terraform.
RUN wget https://releases.hashicorp.com/terraform/${terraform_version}/terraform_${terraform_version}_linux_amd64.zip && \
    unzip ./terraform_${terraform_version}_linux_amd64.zip -d /usr/local/bin/
# set time-zone=JST
RUN apk --update add tzdata && \
    cp /usr/share/zoneinfo/Asia/Tokyo /etc/localtime && \
    apk del tzdata && \
    rm -rf /var/cache/apk/*
# create workspace.
COPY ./terraform /root/terraform
# move to workspace
WORKDIR /root/terraform
docker-compose.yml
version: "3"
services:
  terraform:
    container_name: "terraform"
    image: local/terraform
    build:
      context: ./
      dockerfile: docker/Dockerfile
    volumes:
      - ./terraform:/root/terraform
#Build a Docker image. Only the first time is OK.
> docker-compose build
#Container startup & login
> docker-compose run --rm terraform
###After that, the work will be done inside the Docker container.
#Run Terraform
$ terraform init
$ terraform plan
$ ...
#When finished. Exit from the Docker container.
$ exit
This solved (avoided) it.
Recommended Posts