Giter VIP home page Giter VIP logo

ayltai__terraform-plugin's Introduction

Terraform Gradle plugin

GitHub workflow status Codacy grade Sonar quality gate Sonar violations (short format) Sonar Test Success Rate Code Coverage Sonar Coverage Maintainability Rating Reliability Rating Sonar Tech Debt Vulnerabilities Maintenance Release License

Supports for executing Terraform command-line tools.

https://plugins.gradle.org/plugin/com.github.ayltai.terraform-plugin

Buy me a coffee

Quick start

Apply Gradle plugin

Groovy

Using the plugins DSL:

plugins {
    id 'com.github.ayltai.terraform-plugin' version '0.2.13'
}

Using legacy plugin application:

buildscript {
    repositories {
        maven {
            url 'https://plugins.gradle.org/m2/'
        }
    }

    dependencies {
        classpath 'gradle.plugin.com.github.ayltai:terraform-plugin:0.2.13'
    }
}

apply plugin: 'com.github.ayltai.terraform-plugin'

Kotlin

Using the plugins DSL:

plugins {
    id('com.github.ayltai.terraform-plugin') version '0.2.13'
}

Using legacy plugin application:

buildscript {
    repositories {
        maven {
            url = uri('https://plugins.gradle.org/m2/')
        }
    }

    dependencies {
        classpath('gradle.plugin.com.github.ayltai:terraform-plugin:0.2.13')
    }
}

Specify options

Example:

terraform {
    toolVersion = '0.12.29'
    backend     = 'app.terraform.io'
    apiToken    = System.getenv('TERRAFORM_API_TOKEN')
    workspace   = 'main'

    variables {
        var 'access_key', System.getenv('TERRAFORM_ACCESS_KEY')
        var 'secret key', System.getenv('TERRAFORM_SECRET_KEY')
    }
}

Sample project

HKVPN is a Terraform project that uses this plugin. Check build.gradle for a sample configuration, and README for usage instructions.

Supported tasks

Task Description
tfDownload Download and cache a copy of Terraform command-line tools
tfFmt Rewrite Terraform source scripts to a canonical format and style
tfInit Initialize Terraform source scripts
tfValidate Validate the Terraform source scripts to verify whether they are syntactically valid and internally consistent
tfPlan Create a Terraform execution plan
tfApply Apply the changes required to reach the desired state of the configuration, or the pre-determined set of actions generated by an execution plan
tfDestroy Destroy the Terraform-managed infrastructure
tfWorkspaceList List all existing workspaces
tfWorkspaceSelect Choose a different workspace to use for further
tfWorkspaceNew Create a new workspace
tfWorkspaceDelete Delete an existing workspace
tfWorkspaceShow Output the current workspace

Configurations

General

Property Type Default Description
backend String The endpoint of remote state
apiToken String The API token to authenticate with the remote state endpoint
toolVersion String The version of the Terraform command-line tools to be downloaded
forceDownload boolean false Terraform command-line tools will be re-downloaded even if they are already downloaded
source String src/main/terraform The path to the Terraform source set
configFile java.io.File The path to the Terraform configuration file
init See init
fmt See fmt
validate See validate
plan See plan
apply See apply
destroy See destroy
variables See variables
workspace String default The name of the workspace to select, create or delete

init

Property Type Default Description
noColor boolean false Disables color codes in the command output.
input boolean true Asks for input if necessary
lock boolean true Disables locking of state files during state-related operations
lockTimeout int 0 Overrides the time Terraform will wait to acquire a state lock
useBackend boolean true Initializes a working directory for validation without accessing any configured remote backend
upgrade boolean true Opts to upgrade modules and plugins as part of their respective installation steps

fmt

Property Type Default Description
noColor boolean false Disables color codes in the command output.
list boolean false Lists the files containing formatting inconsistencies
write boolean false Overwrites the input files
diff boolean false Displays diffs of formatting changes
check boolean false Checks if the input is formatted
recursive boolean false Processes files in subdirectories

validate

Property Type Default Description
noColor boolean false Disables color codes in the command output.
json boolean false Produces output in a machine-readable JSON format, suitable for use in text editor integrations and other automated systems

plan

Property Type Default Description
noColor boolean false Disables color codes in the command output.
input boolean true Asks for input if necessary
lock boolean true Disables locking of state files during state-related operations
lockTimeout int 0 Overrides the time Terraform will wait to acquire a state lock
compactWarnings boolean false If the warnings Terraform produces are not accompanied by errors, shows warning in a more compact form that includes only the summary messages
parallelism int 10 Limits the number of concurrent operation as Terraform walks the graph
state String terraform.tfstate The path to the state file
targets java.util.List Resource Addresses to target
destroy boolean false Generates a plan to destroy all the known resources
detailedExitCode boolean false Returns a detailed exit code when the command exits
out String The path to save the generated execution plan
refresh boolean true Updates the state prior to checking for differences

apply

Property Type Default Description
noColor boolean false Disables color codes in the command output.
input boolean true Asks for input if necessary
lock boolean true Disables locking of state files during state-related operations
lockTimeout int 0 Overrides the time Terraform will wait to acquire a state lock
backup String The path to backup the existing state file
compactWarnings boolean false If the warnings Terraform produces are not accompanied by errors, shows warning in a more compact form that includes only the summary messages
parallelism int 10 Limits the number of concurrent operation as Terraform walks the graph
state String terraform.tfstate The path to the state file
targets java.util.List Resource Addresses to target
refresh boolean true Updates the state prior to checking for differences
stateOut String The path to write updated state file
in String The path to the Terraform source scripts or an execution plan to apply

destroy

Property Type Default Description
noColor boolean false Disables color codes in the command output.
input boolean true Asks for input if necessary
lock boolean true Disables locking of state files during state-related operations
lockTimeout int 0 Overrides the time Terraform will wait to acquire a state lock
backup String The path to backup the existing state file
compactWarnings boolean false If the warnings Terraform produces are not accompanied by errors, shows warning in a more compact form that includes only the summary messages
parallelism int 10 Limits the number of concurrent operation as Terraform walks the graph
state String terraform.tfstate The path to the state file
targets java.util.List Resource Addresses to target
refresh boolean true Updates the state prior to checking for differences
stateOut String The path to write updated state file
in String The path to the Terraform source scripts to destroy

variables

Example:

variables {
    var 'foo', 'bar'
    var 'name', 'value'
    file 'vars-file.tf'
}

See the official documentation for more details.

License

MIT

References

ayltai__terraform-plugin's People

Contributors

ayltai avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.