github.com/hugorut/terraform@v1.1.3/website/docs/cli/commands/0.13upgrade.mdx (about) 1 --- 2 page_title: 'Command: 0.13upgrade' 3 description: >- 4 The 0.13upgrade subcommand updates existing configurations to use the new 5 provider source features from Terraform 0.13. 6 --- 7 8 # Command: 0.13upgrade 9 10 The `terraform 0.13upgrade` command updates existing configuration to add an 11 explicit `source` attribute for each provider used in a given module. The 12 provider source settings are stored in a `required_providers` block. 13 14 -> **This command is available only in Terraform v0.13 releases.** For more information, see [the Terraform v0.13 upgrade guide](/language/upgrade-guides/0-13). 15 16 ## Usage 17 18 Usage: `terraform 0.13upgrade [options] [dir]` 19 20 The primary purpose of the `0.13upgrade` command is to determine which 21 providers are in use for a module, detect the source address for those 22 providers where possible, and record this information in a 23 [`required_providers` block][required-providers]. 24 25 [required-providers]: /language/providers/requirements 26 27 ~> Note: the command ignores `.tf.json` files and override files in the module. 28 29 If the module already has a `required_providers` block, the command updates it 30 in-place. Otherwise, a new block is added to the `versions.tf` file. 31 32 By default, `0.13upgrade` changes configuration files in the current working 33 directory. However, you can provide an explicit path to another directory if 34 desired, which may be useful for automating migrations of several modules in 35 the same repository. 36 37 When run with no other options, the command will first explain what it is 38 going to do and prompt for confirmation: 39 40 ``` 41 $ terraform 0.13upgrade 42 43 This command will update the configuration files in the given directory to use 44 the new provider source features from Terraform v0.13. It will also highlight 45 any providers for which the source cannot be detected, and advise how to 46 proceed. 47 48 We recommend using this command in a clean version control work tree, so that 49 you can easily see the proposed changes as a diff against the latest commit. 50 If you have uncommited changes already present, we recommend aborting this 51 command and dealing with them before running this command again. 52 53 Would you like to upgrade the module in the current directory? 54 Only 'yes' will be accepted to confirm. 55 56 Enter a value: yes 57 ``` 58 59 We recommend running this command with a clean version control work tree so 60 that you can use VCS tools to review the proposed changes, including any 61 `TF-UPGRADE-TODO` comments, and make any revisions required before committing 62 the change. 63 64 There is one command-line option: 65 66 * `-yes` - Skip the initial introduction messages and interactive confirmation. 67 Use this when running the command in batch from a script. 68 69 ## Batch Usage 70 71 After you've experimented with the `0.13upgrade` command in some confined 72 situations, if you have a repository containing multiple modules you may 73 wish to batch-upgrade them all and review them together. Recursive upgrades 74 are not supported by the tool itself, but if you are on a Unix-style system 75 you can achieve this using the `find` command as follows: 76 77 ``` 78 $ find . -name '*.tf' | xargs -n1 dirname | uniq | xargs -n1 terraform 0.13upgrade -yes 79 ``` 80 81 On a Windows system with PowerShell, you can use this command: 82 83 ``` 84 Get-Childitem -Recurse -Include *.tf | Split-Path | ` 85 Select-Object -Unique | ForEach-Object { terraform 0.13upgrade -yes $_.FullName } 86 ``` 87 88 Note that the above commands include the `-yes` option to override the 89 interactive prompt, so be sure you have a clean work tree before running it.