
The Terraform Maven Plugin brings Maven to Terraform, which greatly enhances Terraform’s project lifecycle and dependency management capability. Maven, in some form has been the standard for Java project management for over a decade. Now, all of that Maven goodness can be used with Terraform!
Integrate automtated tests (Spock, JUnit, TestNG) into your Terraform projects, use Maven's dependency management functionality with Terraform, combine Java and Terraform into the same project, and more!
Not finding what you are looking for? Try the Wiki!
| Artifact Name | Version | Latest Snapshot | Description |
|---|---|---|---|
| tf-maven-plugin | Terraform Maven Plugin | ||
| tf-cmd-api | Terraform Command API | ||
| tf-s3-archetype | Maven Terraform S3 Archetype |
Description:
Downloads Maven artifacts into a common modules directory and extracts each artifacts contents into a folder named for the artifact (version agnostic).
Optional Parameters:
| Name | Type | Description |
|---|---|---|
| tfModulesDir | String | The directory location where Terraform modules will be expanded; defaults to src/main/.tfmodules |
Description:
Executes the terraform init command. See https://www.terraform.io/docs/commands/init.html.
Optional Parameters:
| Name | Type | Description |
|---|---|---|
| tfRootDir | String | The root module directory location where terraform will be initialized; defaults to src/main/tf/{first dir found} |
| pluginDir | String | Skips plugin installation and loads plugins only from the specified directory |
| getPlugins | Boolean | Skips plugin installation |
| backendConfig | String | A comma delimited string of optional backend config (e.g. backendConfig="region=us-east-1,bucket=mybucket,key=/some/path") |
| verifyPlugins | Boolean | Skips release signature validation when installing downloaded plugins (not recommended) |
| skipTfGet | Boolean | If set to true, tf:init is done without running tf:get |
| artifact | String | Supplied in form {groupId}:{artifactId}:{versionId}; if present, the maven artifact is treated like a root module |
Description:
Executes the terraform plan command. See https://www.terraform.io/docs/commands/plan.html.
Optional Parameters:
| Name | Type | Description |
|---|---|---|
| tfVarFiles | String | A comma delimited string of tfvars files (e.g. -var-file=foo) |
| tfVars | String | A comma delimited string of tfvars (e.g. -var 'name=value') |
| lockTimeout | Number | Duration to retry a state lock |
| target | String | A resource address to target |
| planInput | Boolean | If set to "true", input variables not directly set will be requested; otherwise, the plan will fail |
| noColor | Any | If this property exists, the -no-color flag is set |
| destroyPlan | Any | If this property exists, a destroy plan is outputted |
| planOutputFile | String | The path to save the generated execution plan. To upload plan to S3 (e.g. -DplanOutputFile=s3:////) |
| kmsKeyId | String | To Upload plan to s3 with kms encrypted (e.g. -DkmsKeyId=) |
| tfRootDir | String | A terraform config directory to apply; defaults to src/main/tf/{first dir found}, then current directory |
| timeout | Number | The maximum time in milliseconds that the terraform apply command can run; defaults to 10min |
| refreshState | Boolean | If set to "true" then Terraform will refresh the state before generating the plan |
| tfState | String | The path to the state file; defaults to terraform.tfstate |
| artifact | String | Supplied in form {groupId}:{artifactId}:{versionId}; if present, the maven artifact is treated like a root module |
Description:
Executes the terraform apply command. See https://www.terraform.io/docs/commands/apply.html.
Optional Parameters:
| Name | Type | Description |
|---|---|---|
| tfVarFiles | String | A comma delimited string of tfvars files (e.g. -var-file=foo) |
| tfVars | String | A comma delimited string of tfvars (e.g. -var 'name=value') |
| lockTimeout | Number | Duration to retry a state lock |
| target | String | A resource address to target |
| noColor | Any | If this property exists, the -no-color flag is set |
| plan | String | A terraform plan to apply; if both plan and tfRootDir are specified, only plan is used |
| tfRootDir | String | A terraform config directory to apply; defaults to src/main/tf/{first dir found}, then current directory |
| refreshStat |
$ claude mcp add terraform-maven \
-- python -m otcore.mcp_server <graph>