Terraform: Error configuring the backend “s3”: RequestError: send request failed caused by: Post https://sts.amazonaws.com/: EOF

I recently got this when doing a terragrunt init(i.e. basically a terraform init):

Initializing the backend…

Error configuring the backend “s3”: RequestError: send request failed
caused by: Post https://sts.amazonaws.com/: EOF

Please update the configuration in your Terraform files to fix this error.
If you’d like to update the configuration interactively without storing
the values in your configuration, run “terraform init”.

Could be related to this?

https://github.com/hashicorp/terraform/issues/10779

Running it a second time was successful.

Here’s what happened when I repeated it 10 times:

1x

Error loading state: RequestError: send request failed
caused by: Get https://<s3 bucket name>.s3-us-west-2.amazonaws.com/?prefix=env%3A%2F: net/http: TLS handshake timeout

1x

Error loading state: RequestError: send request failed
caused by: Get https://<s3 bucket name>.s3-us-west-2.amazonaws.com/?prefix=env%3A%2F: EOF

8x

Terraform has been successfully initialized!

 

Curiously, I then ran it 100 times with no Errors.

 

Terragrunt Interpolation syntax

Terragrunt allows you to use Terraform interpolation syntax (i.e. ${...} ) to call Terragrunt-specific functions.

These only work within a terragrunt = { ... } block.

Also, these interpolations do not work in a .tfvars file.

Terragrunt functions:

  • get_env(NAME, DEFAULT)

get_envreturns the environment variable named NAMEif it exists. If it does not exist then it returns the value specified by DEFAULT. E.g. this would return $BUCKETif it exists otherwise it returns my-terraform-bucket.

Note also, Terraform will read in environment variables starting with TF_VAR_ so one way of sharing a variable named foo between Terraform and Terragrunt would be to set its value as the environment variable TF_VAR_foo and read it using this get_env function.

For others see: https://github.com/gruntwork-io/terragrunt