0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

windows で docker image のterraformを使ってみる

0
Posted at

目的

TerraformをWindows上で実行したいけど、わざわざ、コマンドはインストールしたくないので、Dockerイメージですませられないかと思った。

そこでハマった。。。。

Docker Image

hashicorpが作成しているので安心

使い方として、

docker run -i -t hashicorp/terraform:latest plan

が記載されているが、これがミスリードを誘う。

実行する。

チュートリアルを見ながら実行する
https://learn.hashicorp.com/tutorials/terraform/install-cli?in=terraform/aws-get-started

適当なディレクトリでmain.tfを作成する。


C:\dev\test\teraform>docker run -i -t  hashicorp/terraform:latest init
Terraform initialized in an empty directory!

The directory has no Terraform configuration files. You may begin working
with Terraform immediately by creating Terraform configuration files.    

C:\dev\test\teraform>

失敗。。。汗

調べると、誰もハマっているようで。。。
https://stackoverflow.com/questions/62250930/terraform-official-docker-image-cant-see-my-files

C:\dev\test\teraform>docker run -v "c:\dev\test\teraform":/work -w /work hashicorp/terraform:latest init

Initializing the backend...

Initializing provider plugins...
- Reusing previous version of kreuzwerker/docker from the dependency lock file
- Using previously-installed kreuzwerker/docker v2.16.0

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see  
any changes that are required for your infrastructure. All Terraform commands  
should now work.

If you ever set or change modules or backend configuration for Terraform,      
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

C:\dev\test\teraform>

できた!

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?