Update version constraints of Terraform core, providers, and modules
Update all your Terraform configurations recursively under a given directory
Get the latest release version from the GitHub, GitLab, or Terraform Registry
Terraform v0.12+ support
If you integrate tfupdate with your favorite CI or job scheduler, you can check the latest release daily and create a Pull Request automatically.
Why?
It is a best practice to break your Terraform configuration and state into small pieces to minimize the impact of an accident.
It is also recommended to lock versions of Terraform core, providers and modules to avoid unexpected breaking changes.
If you decided to lock version constraints, you probably want to keep them up-to-date frequently to reduce the risk of version upgrade failures.
It's easy to update a single directory, but what if they are scattered across multiple directories?
That is why I wrote a tool which parses Terraform configurations and updates all version constraints at once.
Install
Homebrew
If you are macOS user:
$ brew install minamijoyo/tfupdate/tfupdate
Download
Download the latest compiled binaries and put it anywhere in your executable path.
https://github.com/minamijoyo/tfupdate/releases
Source
If you have Go 1.13+ development environment:
$ git clone https://github.com/minamijoyo/tfupdate
$ cd tfupdate/
$ make install
$ tfupdate --version
Docker
You can also run it with Docker:
$ docker run -it --rm minamijoyo/tfupdate --version
Available commands are:
module Update version constraints for module
provider Update version constraints for provider
release Get release version information
terraform Update version constraints for terraform
Arguments
PATH A path of file or directory to update
Options:
-v --version A new version constraint (default: latest)
If the version is omitted, the latest version is automatically checked and set.
-r --recursive Check a directory recursively (default: false)
-i --ignore-path A regular expression for path to ignore
If you want to ignore multiple directories, set the flag multiple times.
Arguments
PROVIDER_NAME A name of provider (e.g. aws, google, azurerm)
PATH A path of file or directory to update
Options:
-v --version A new version constraint (default: latest)
If the version is omitted, the latest version is automatically checked and set.
Getting the latest version automatically is supported only for official providers.
If you have an unofficial provider, use release latest command.
-r --recursive Check a directory recursively (default: false)
-i --ignore-path A regular expression for path to ignore
If you want to ignore multiple directories, set the flag multiple times.
$ cat main.tf
provider "aws" {
version = "2.39.0"
}
$ tfupdate provider aws -v 2.40.0 main.tf
$ cat main.tf
provider "aws" {
version = "2.40.0"
}
Arguments
MODULE_NAME A name of module
e.g.
terraform-aws-modules/vpc/aws
git::https://example.com/vpc.git
PATH A path of file or directory to update
Options:
-v --version A new version constraint (required)
Automatic latest version resolution is not currently supported for modules.
-r --recursive Check a directory recursively (default: false)
-i --ignore-path A regular expression for path to ignore
If you want to ignore multiple directories, set the flag multiple times.
Arguments
SOURCE A path of release data source.
Valid format depends on --source-type option.
- github or gitlab:
owner/repo
e.g. terraform-providers/terraform-provider-aws
- tfregistryModule
namespace/name/provider
e.g. terraform-aws-modules/vpc/aws
- tfregistryProvider (experimental)
namespace/type
e.g. hashicorp/aws
Options:
-s --source-type A type of release data source.
Valid values are
- github (default)
- gitlab
- tfregistryModule
- tfregistryProvider (experimental)
If you want to access private repositories on GitHub, export your access token to the
GITHUB_TOKEN
environment variable.
If you want to access public or private repositories on GitLab, export your access token with api permissions to the
GITLAB_TOKEN
environment variable. If you are using an instance that is not
https://gitlab.com
, set the correct base URL to the
GITLAB_BASE_URL
environment variable (defaults to
https://gitlab.com/api/v4/
).
$ tfupdate release list --help
Usage: tfupdate release list [options]
Arguments
SOURCE A path of release data source.
Valid format depends on --source-type option.
- github or gitlab:
owner/repo
e.g. terraform-providers/terraform-provider-aws
- tfregistryModule
namespace/name/provider
e.g. terraform-aws-modules/vpc/aws
- tfregistryProvider (experimental)
namespace/type
e.g. hashicorp/aws
Options:
-s --source-type A type of release data source.
Valid values are
- github (default)
- gitlab
- tfregistryModule
- tfregistryProvider (experimental)
We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.