MCPcopy Index your code
hub / github.com/deliveredtechnologies/terraform-maven

github.com/deliveredtechnologies/terraform-maven @v0.12

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.12 ↗ · + Follow
337 symbols 1,015 edges 76 files 111 documented · 33%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

terraform-maven


License Build Status Coverage Status Maven Central

Terraform Maven Plugin

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!


Contents

Not finding what you are looking for? Try the Wiki!


Artifacts in This Repository

Artifact Name Version Latest Snapshot Description
tf-maven-plugin Maven Central Maven Snapshot Terraform Maven Plugin
tf-cmd-api Maven Central Maven Snapshot Terraform Command API
tf-s3-archetype Maven Central Maven Snapshot Maven Terraform S3 Archetype

Repository Directory Structure

  • examples - Terraform Maven example projects
  • tf-s3 - A Terraform Maven s3 example project
  • tf-s3-consumer - An example project that consumes the tf-s3 project as a dependency
  • tf-build-tools - The parent project of the tf-maven-plugin and tf-cmd-api projects
  • tf-maven-plugin - The Terraform Maven Plugin project
  • tf-cmd-api - A Java API for Terraform project
  • tf-test-groovy - A Java library that assists with Testing Terraform using Groovy (e.g. Spock)
  • tf-s3-archetype - An Archetype for a S3 Terraform Project

Benefits of the Terraform Maven Plugin

  • Dependency Management
  • Terraform really has no dependency management to speak of. Even when you use Terraform Cloud, Terraform Enterprise or some other private Terraform module registry, a version update to a module means editing the Terraform code in each and every place that module is sourced. The Terraform Maven Plugin allows you to specify your dependencies for Terraform the same way you specify your dependencies with Java: in an external Maven POM file. And because it's Maven, Terraform modules sourced from Maven repos can also take advantage of version ranges and Maven's SNAPSHOT functionality. It also resolves transitive dependencies. No more modifying code for version updates! No more sourcing obscure URLs! Hooray, Maven!
  • Packaging as Part of the Build Lifecycle
  • The package goal can package a Terraform root module for deployment into a Maven repo or it can package that same Terraform root module with its dependencies for deployment into an isolated environment or Terraform Enterprise. It's all part of a single Maven goal/command.
  • Deploying Terraform Artifacts to a Maven Repo with an Attached POM is a Snap
  • By default, the deploy goal deploys a zip artifact packaged by the package goal to a Maven repo along with the POM of the current Maven Terraform project. But if you want to point to a differnt POM or a different artifact for deployment, it can do that too. Easy peasy.
  • Terraform support for Java testing frameworks
  • The tf-cmd-api artifact provides Java support for Terraform, which can be used to easily integrate mature Java testing frameworks, like Spock, JUnit or TestNG. One example of this is the [tf-s3 example in this repo].
  • Simple Integration with CI Tools
  • Get rid of hundreds of lines of untested code in your CI tool and replace it with tested build lifecycle management using Maven! Most CI tools either have Maven included or have a Maven plugin available. Less Terraform build logic in your CI tool means more reliable builds and less CI code to maintain.
  • Build Terraform Maven Projects or Standalone Terraform Configurations and Anything In Between
  • You can use the Terraform Maven plugin for building any Terraform, not just Terraform Maven projects! The default configuration is opinionated around the Maven project structure. But that's available to override. Do you have a different folder containing Terraform modules that you want packaged into a Fat Zip? No problem. What about just running a Terraform configuration in some directory that you specify? That works too. You don't lose anything with the Terraform Maven plugin. You just gain a whole lot of packaged functionality and the build lifecycle power of Maven with Terraform!

Maven Goals

tf:get

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

tf:init

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

tf:plan

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

tf:apply

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

Extension points exported contracts — how you extend this code

TerraformOption (Interface)
Represents a Terraform parameter that is available to the TerraformCliOperation that it is associated with. [6 implementers]
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/TerraformOption.java
Compressable (Interface)
An interface for creating compressed files. [4 implementers]
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/io/Compressable.java
TfOptionFormatter (Interface)
Interface for formatting Terraform CommandLine Options. [5 implementers]
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/converters/TfOptionFormatter.java
Expandable (Interface)
Interface for a compressed artifact that can be expanded. [2 implementers]
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/io/Expandable.java
Executable (Interface)
Executable interface for defining process executions w/commands. [4 implementers]
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/io/Executable.java
Integration (Interface)
(no doc)
tf-build-tools/tf-maven-plugin/src/test/java/com/deliveredtechnologies/test/categories/Integration.java
TerraformOperation (Interface)
(no doc) [20 implementers]
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/TerraformOperation.java

Core symbols most depended-on inside this repo

toString
called by 152
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/TerraformCommand.java
execute
called by 70
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/io/Executable.java
getPropertyName
called by 55
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/TerraformOption.java
info
called by 24
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/logs/MavenSlf4jAdapter.java
getName
called by 23
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/logs/MavenSlf4jAdapter.java
getFieldsAsProperties
called by 13
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/terraform/mojo/TerraformMojo.java
getDefaultTerraformRootModuleDir
called by 10
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/TerraformUtils.java
convert
called by 9
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/converters/TfOptionFormatter.java

Shape

Method 253
Class 68
Enum 9
Interface 7

Languages

Java100%

Modules by API surface

tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/logs/MavenSlf4jAdapter.java13 symbols
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/logs/Slf4jMavenAdapter.java10 symbols
tf-build-tools/tf-maven-plugin/src/test/java/com/deliveredtechnologies/maven/terraform/TerraformGetTest.java9 symbols
tf-build-tools/tf-maven-plugin/src/test/java/com/deliveredtechnologies/maven/terraform/mojo/TerraformMojoTest.java8 symbols
tf-build-tools/tf-maven-plugin/src/main/java/com/deliveredtechnologies/maven/terraform/TerraformPackage.java8 symbols
tf-build-tools/tf-cmd-api/src/test/java/com/deliveredtechnologies/terraform/TerraformPlanFileUtilsTest.java8 symbols
tf-build-tools/tf-maven-plugin/src/test/java/com/deliveredtechnologies/maven/terraform/TerraformDeployTest.java7 symbols
tf-build-tools/tf-cmd-api/src/test/java/com/deliveredtechnologies/terraform/api/TerraformApplyTest.java7 symbols
tf-build-tools/tf-cmd-api/src/test/java/com/deliveredtechnologies/terraform/TerraformCommandLineDecoratorTest.java7 symbols
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/TerraformShow.java7 symbols
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/TerraformPlan.java7 symbols
tf-build-tools/tf-cmd-api/src/main/java/com/deliveredtechnologies/terraform/api/TerraformOutput.java7 symbols

For agents

$ claude mcp add terraform-maven \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact