Terraform apply Freezes

Hi

I am using Terraform for the first time on Windows 10. Unfortunately I have it freezing on a regular basis. Currently I am using the apply command, with the following output. It then goes no further.

Can anyone help please?

Andy

PS C:\Courses\getting-started-terraform\Code\m3> terraform init
2021/01/20 12:00:41 [INFO] Terraform version: 0.14.4
2021/01/20 12:00:41 [INFO] Go runtime version: go1.15.6
2021/01/20 12:00:41 [INFO] CLI args: string{“C:\Program Files\Terraform\terraform.exe”, “init”}
2021/01/20 12:00:41 [DEBUG] Attempting to open CLI config file: C:\Users\Andy.Brough\AppData\Roaming\terraform.rc
2021/01/20 12:00:41 [DEBUG] File doesn’t exist, but doesn’t need to. Ignoring.
2021/01/20 12:00:41 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/01/20 12:00:41 [DEBUG] ignoring non-existing provider search directory C:\Users\Andy.Brough\AppData\Roaming\terraform.d\plugins
2021/01/20 12:00:41 [DEBUG] ignoring non-existing provider search directory C:\Users\Andy.Brough\AppData\Roaming\HashiCorp\Terraform\plugins
2021/01/20 12:00:41 [INFO] CLI command args: string{“init”}

2021/01/20 12:00:41 [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2021/01/20 12:00:41 [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2021/01/20 12:00:41 [DEBUG] New state was assigned lineage “b4a7889f-491e-21a6-4e40-60915daa06b2”
2021/01/20 12:00:41 [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2021/01/20 12:00:41 [TRACE] Meta.Backend: instantiated backend of type
2021/01/20 12:00:41 [DEBUG] checking for provisioner in “.”
2021/01/20 12:00:41 [DEBUG] checking for provisioner in “C:\Program Files\Terraform”
Initializing th2021/01/20 12:00:41 [INFO] Failed to read plugin lock file .terraform\plugins\windows_amd64\lock.json: open .terraform\plugins\windows_amd64\lock.json: The system cannot find the path specified.
e 2021/01/20 12:00:41 [TRACE] Meta.Backend: backend does not support operations, so wrapping it in a local backend
backend…
2021/01/20 12:00:41 [TRACE] backend/local: state manager for workspace “default” will:

  • read initial snapshot from terraform.tfstate
  • write new snapshots to terraform.tfstate
  • create any backup at terraform.tfstate.backup
    2021/01/20 12:00:41 [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
    2021/01/20 12:00:41 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that’s okay

2021/01/20 12:00:41 [TRACE] statemgr.Filesystem: read nil snapshot
2021/01/20 12:00:41 [DEBUG] Service discovery for registry.terraform.io at https://registry.terraform.io/.well-known/terraform.json
Initializin2021/01/20 12:00:41 [TRACE] HTTP client GET request to https://registry.terraform.io/.well-known/terraform.json
g provider plugins…

Terraform has created a lock file .terraform.lock.hcl to record the provider
selections it made above. Include this file in your version control repository
so that Terraform can guarantee to make the same selections by default when
you run “terraform init” in the future.

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.
PS C:\Courses\getting-started-terraform\Code\m3> terraform apply m3.tfplan
2021/01/20 12:00:57 [INFO] Terraform version: 0.14.4
2021/01/20 12:00:57 [INFO] Go runtime version: go1.15.6
2021/01/20 12:00:57 [INFO] CLI args: string{“C:\Program Files\Terraform\terraform.exe”, “apply”, “m3.tfplan”}
2021/01/20 12:00:57 [DEBUG] Attempting to open CLI config file: C:\Users\Andy.Brough\AppData\Roaming\terraform.rc
2021/01/20 12:00:57 [DEBUG] File doesn’t exist, but doesn’t need to. Ignoring.
2021/01/20 12:00:57 [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2021/01/20 12:00:57 [DEBUG] ignoring non-existing provider search directory C:\Users\Andy.Brough\AppData\Roaming\terraform.d\plugins
2021/01/20 12:00:57 [DEBUG] ignoring non-existing provider search directory C:\Users\Andy.Brough\AppData\Roaming\HashiCorp\Terraform\plugins
2021/01/20 12:00:57 [INFO] CLI command args: string{“apply”, “m3.tfplan”}
2021/01/20 12:00:57 [TRACE] Meta.BackendForPlan: instantiated backend of type *local.Local
2021/01/20 12:00:57 [TRACE] providercache.fillMetaCache: scanning directory .terraform\providers
2021/01/20 12:00:57 [TRACE] getproviders.SearchLocalDirectory: .terraform\providers is a symlink to .terraform\providers
2021/01/20 12:00:57 [TRACE] getproviders.SearchLocalDirectory: found registry.terraform.io/hashicorp/aws v3.24.1 for windows_amd64 at .terraform\providers\registry.terraform.io\hashicorp\aws\3.24.1\windows_amd64
2021/01/20 12:00:57 [TRACE] providercache.fillMetaCache: including .terraform\providers\registry.terraform.io\hashicorp\aws\3.24.1\windows_amd64 as a candidate package for registry.terraform.io/hashicorp/aws 3.24.1
2021/01/20 12:00:57 [DEBUG] checking for provisioner in “.”
2021/01/20 12:00:57 [DEBUG] checking for provisioner in “C:\Program Files\Terraform”
2021/01/20 12:00:57 [INFO] Failed to read plugin lock file .terraform\plugins\windows_amd64\lock.json: open .terraform\plugins\windows_amd64\lock.json: The system cannot find the
path specified.
2021/01/20 12:00:57 [TRACE] Meta.BackendForPlan: backend *local.Local supports operations
2021/01/20 12:00:57 [INFO] backend/local: starting Apply operation
2021/01/20 12:00:57 [TRACE] backend/local: requesting state manager for workspace “default”
2021/01/20 12:00:57 [TRACE] backend/local: state manager for workspace “default” will:

  • read initial snapshot from terraform.tfstate
  • write new snapshots to terraform.tfstate
  • create any backup at terraform.tfstate.backup
    2021/01/20 12:00:57 [TRACE] backend/local: requesting state lock for workspace “default”
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: preparing to manage state snapshots at terraform.tfstate
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: no previously-stored snapshot exists
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: locking terraform.tfstate using LockFileEx
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: writing lock metadata to .terraform.tfstate.lock.info
    2021/01/20 12:00:57 [TRACE] backend/local: reading remote state for workspace “default”
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: reading latest snapshot from terraform.tfstate
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that’s okay
    2021/01/20 12:00:57 [TRACE] statemgr.Filesystem: read nil snapshot
    2021/01/20 12:00:57 [TRACE] backend/local: retrieving local state snapshot for workspace “default”
    2021/01/20 12:00:57 [TRACE] backend/local: building context from plan file
    2021/01/20 12:00:57 [TRACE] terraform.NewContext: starting
    2021/01/20 12:00:57 [TRACE] terraform.NewContext: loading provider schemas
    2021/01/20 12:00:57 [TRACE] LoadSchemas: retrieving schema for provider type “registry.terraform.io/hashicorp/aws
    2021-01-20T12:00:57.863Z [INFO] plugin: configuring client automatic mTLS

Sorry I didn’t find the terraform plan step.does it worked fine for you.I don’t find any errors as well in the logs shared.Can you try using git bash on windows if it’s a problem with windows.

Hi. There wasn’t any errors it just freezes and doesn’t progress any further no matter how long I wait. I tried git bash on windows but had the same problem. I then tried it on an Ubuntu Linux client and it worked perfectly. It would seem that the Windows version is a little unstable, but I’m happy to just use on Linux. Thanks for your help.

Are you perhaps on a (corporate) private network that has some end user process monitoring software? Its very odd, that your able to reach out and download your requested providers but when you move into a plan it freezes. Since your using windows I would destroy the terraform binary and remove it from your path. If you are going to stay on Windows I would recommend using [Chocolately]( Chocolatey Software | Chocolatey - The package manager for Windows for managing your software. Once installed you can perform any of these commands to manage Terraform binary:

  • choco install terraform
  • choco upgrade terraform
  • choco uninstall terraform

Im sure these commands above are self explanatory, but let us know what you discover. If you would like further documentation you can goto Chocolatey Software | Terraform 0.14.4

If you need help finding your terraform binary you can find it in the terminal:
CMD

where terraform

POWERSHELL

Get-Command terraform | Select Source