Skip to content

Instantly share code, notes, and snippets.

@karl-johan-grahn
Last active April 25, 2022 18:42
Show Gist options
  • Save karl-johan-grahn/97681d5ffd3d25ebafff45105e41dfbc to your computer and use it in GitHub Desktop.
Save karl-johan-grahn/97681d5ffd3d25ebafff45105e41dfbc to your computer and use it in GitHub Desktop.

Terraform

Switch versions

Tools to switch local Terraform versions:

RDS connectivity issue

If you encounter an rds instance will try to connect to localhost:3306:

Error: Could not connect to server: dial tcp 127.0.0.1:3306: connect: connection refused
Error: Could not connect to server: dial tcp 127.0.0.1:3306: connect: connection refused

Try one of the following:

  • Update to terraform version 0.14.x.
  • Make sure resources are not tainted
  • Do a local plan to get more verbose output and pay attention to exactly what connection is being refused
  • It can also be because of this bug hashicorp/terraform#27785, then do a local targeted plan and apply on the RDS instance

AWS Security Groups

The AWS Terraform provider has a bug and cannot update inbound rules, so you need to manually update the CIDR for all affected inbound rules to avoid collision

Binaries into k8s secrets

For a long time, Terraform could not put binaries into k8s secrets, but that is resolved with v2.0.1 of the kubernetes provider: hashicorp/terraform-provider-kubernetes#704

Update modules in lock step

Make sure to update modules in lock step from v0.12 and onwards. If you jump straight to the latest version, you will most probably encounter error like:

To work with module... its original provider configuration at provider["registry.terraform.io/-/aws"]
is required, but it has been removed. This occurs when a provider
configuration is removed while objects created by that provider still exist in
the state. Re-add the provider configuration to destroy
module..., after which you can remove the provider configuration again.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment