[Terraform] When I try to build an Azure resource on a Windows machine, it will time out, so I solved it with Docker.

What happened

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

Cause

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.

Solution (workaround)

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.

Preparation of files, etc.

Folder structure

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

Run

#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

[Terraform] When I try to build an Azure resource on a Windows machine, it will time out, so I solved it with Docker.
When I tried to build an environment of PHP7.4 + Apache + MySQL with Docker, I got stuck [Windows & Mac]
I built a CentOS 8 environment with Vagrant and tried to sync_folder, but I got an error, so I solved it.
When I tried to run Azure Kinect DK with Docker, it was blocked by EULA
A memo to build Jitsi Meet on Azure with docker-compose
Memorandum: When I tried TensorFlow with Tribuo, it didn't work, so I went on a journey to find the head family and lost.
I made an app to scribble with PencilKit on a PDF file
I tried to build a Firebase application development environment with Docker in 2020
01. I tried to build an environment with SpringBoot + IntelliJ + MySQL (MyBatis) (Windows10)
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
Try Alfresco 6.0 on Windows (Docker will be introduced at the same time)
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
When I try to sign up with devise, it automatically redirects to root_path
When registering a new user, I got an error called ActiveRecord :: NotNullViolation and how to deal with it.
Build an environment with Docker on AWS
I tried to make a machine learning application with Dash (+ Docker) part3 ~ Practice ~
[First environment construction] I tried to create a Rails 6 + MySQL 8.0 + Docker environment on Windows 10.
[Error resolution] Occurs when trying to build an environment for spring with docker
Build a development environment to create Ruby on Jets + React apps with Docker
When I tried to use a Wacom tablet with ubuntu 20.04, I didn't recognize it.
Apple Silicon compatible version of Docker Desktop (Preview) has been released to the public, so I will try it
[Rails] How to build an environment with Docker
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (5)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (6)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (3)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (2)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (1)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (4)
I got an error when trying to install sbt to build a Scala development environment
A story that I had a hard time trying to build PHP 7.4 on GCE's CentOS 8