Skip to content

Commit

Permalink
released v0.12
Browse files Browse the repository at this point in the history
* package tfvars as auto.tfvars (issue #197)
* added support for Terraform's show command in tf-cmd-api for pre-provision testing (issue #196)
* created a simplified api (tf-test-groovy) for testing Terraform w/Groovy (issue #206 & issue #229)
* fixed tf:wrapper bugs (issue #210, issue #218, issue #219 and issue #225)
  • Loading branch information
Clayton7510 committed Oct 18, 2020
1 parent 0d3c118 commit 23d7937
Show file tree
Hide file tree
Showing 50 changed files with 1,717 additions and 1,127 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
@@ -1,2 +1,2 @@
# Clayton and Robert are the reviewers for all PRs
* @Clayton7510 @groberthutto @palaniswamy
# Clayton, Robert and Pal are the reviewers for all PRs
* @Clayton7510 @roberthutto @palaniswamy
27 changes: 27 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.md
@@ -0,0 +1,27 @@
---
name: Bug report
about: Create a report to help us improve
title: ''
labels: bug
assignees: ''

---

**Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Additional context**
Add any other context about the problem here.
20 changes: 20 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.md
@@ -0,0 +1,20 @@
---
name: Feature request
about: Suggest an idea for this project
title: ''
labels: enhancement
assignees: ''

---

**Is your feature request related to a problem? Please describe.**
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

**Describe the solution you'd like**
A clear and concise description of what you want to happen.

**Describe alternatives you've considered**
A clear and concise description of any alternative solutions or features you've considered.

**Additional context**
Add any other context or screenshots about the feature request here.
10 changes: 10 additions & 0 deletions .github/ISSUE_TEMPLATE/question.md
@@ -0,0 +1,10 @@
---
name: Question
about: Ask a question about the project or how something works
title: ''
labels: question
assignees: ''

---


72 changes: 72 additions & 0 deletions .github/workflows/build.yml
@@ -0,0 +1,72 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: build

on:
push:
branches: [ develop, master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Maven
env:
GPG_KEY: ${{ secrets.MAVEN_KEY }}
run: |
export GPG_TTY=$(tty)
cp .mvn.settings.xml $HOME/.m2/settings.xml
echo "$GPG_KEY" >> codesigning.asc
gpg --batch --import codesigning.asc
shred --remove codesigning.asc
- name: Set up Terraform
run: |
curl -g https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip -o /tmp/terraform.zip
sudo unzip /tmp/terraform.zip -d /usr/bin
- name: Build with Maven
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
cd tf-build-tools
./mvnw clean test coveralls:report -DrepoToken="$COVERALLS_REPO_TOKEN" -Dbranch="$BRANCH_NAME" -B
cd ..
- name: Deploy
id: deploy
env:
OSSRH_USERNAME: ${{ secrets.SONATYPE_USER }}
OSSRH_PASSWORD: ${{ secrets.SONATYPE_PW }}
GPG_KEY_PW: ${{ secrets.MAVEN_KEY_PW }}
GPG_KEY_ID: ${{ secrets.MAVEN_KEY_ID }}
run: |
cd tf-build-tools
VERSION=$(./mvnw org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate -Dexpression=project.version -q -DforceStdout)
PROFILE="SNAPSHOT"
if ! echo $VERSION | grep -q SNAPSHOT ; then
PROFILE="release"
echo "***** BRANCH_NAME is ${GITHUB_REF} *****"
if [ "${GITHUB_REF}" == "refs/heads/develop" ] ; then
# Always push a SNAPSHOT release on a merge into the 'develop' branch
./mvnw versions:set -DnewVersion="${VERSION}-SNAPSHOT" -B
./mvnw deploy -DskipTests=true -B -P snapshot
VERSION="${VERSION}-${GITHUB_RUN_NUMBER}"
echo "***** VERSION has been updated to $VERSION ******"
./mvnw versions:set -DnewVersion="${VERSION}" -B
fi
fi
# Stage for Maven Central Deployment if a release or SonaType SNAPSHOT repo if a SNAPSHOT
export GPG_TTY=$(tty)
./mvnw deploy -DskipTests=true -B -P ${PROFILE}
31 changes: 31 additions & 0 deletions .github/workflows/pr_puild.yml
@@ -0,0 +1,31 @@
# This workflow will build a Java project with Maven
# For more information see: https://help.github.com/actions/language-and-framework-guides/building-and-testing-java-with-maven

name: pr build

on:
pull_request:
branches: [ develop, master ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Set up Terraform
run: |
curl -g https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip -o /tmp/terraform.zip
sudo unzip /tmp/terraform.zip -d /usr/bin
- name: Build with Maven
env:
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_REPO_TOKEN }}
run: |
pull_number=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH")
cp .mvn.settings.xml $HOME/.m2/settings.xml
cd tf-build-tools && ./mvnw clean test coveralls:report -DrepoToken="$COVERALLS_REPO_TOKEN" -Dbranch="$BRANCH_NAME" -DpullRequest="$pull_number" -B
13 changes: 13 additions & 0 deletions .mvn.settings.xml
Expand Up @@ -9,4 +9,17 @@
<pluginGroups>
<pluginGroup>org.eluder.coveralls</pluginGroup>
</pluginGroups>
<profiles>
<profile>
<id>release</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<gpg.executable>gpg</gpg.executable>
<gpg.keyname>${env.GPG_KEY_ID}</gpg.keyname>
<gpg.passphrase>${env.GPG_KEY_PW}</gpg.passphrase>
</properties>
</profile>
</profiles>
</settings>
33 changes: 0 additions & 33 deletions .travis.yml

This file was deleted.

33 changes: 19 additions & 14 deletions README.md
@@ -1,10 +1,10 @@
[tf-maven-plugin]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-maven-plugin/0.11/maven-plugin
[tf-cmd-api]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-cmd-api/0.11/jar
[tf-s3-archetype]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-s3-archetype/0.11/jar
[tf-maven-plugin]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-maven-plugin/0.12/maven-plugin
[tf-cmd-api]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-cmd-api/0.12/jar
[tf-s3-archetype]:https://search.maven.org/artifact/com.deliveredtechnologies/tf-s3-archetype/0.12/jar
[tf-maven-plugin-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-maven-plugin/
[tf-cmd-api-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-cmd-api/
[tf-s3-archetype-snapshot]:https://oss.sonatype.org/content/repositories/snapshots/com/deliveredtechnologies/tf-s3-archetype/
[maven-badge]:https://img.shields.io/badge/maven%20central-0.11-green.svg
[maven-badge]:https://img.shields.io/badge/maven%20central-0.12-green.svg
[maven-snapshot-badge]:https://img.shields.io/badge/SNAPSHOT-0.12-green.svg

![terraform-maven](.docs/MavenTerraform.png)
Expand All @@ -13,13 +13,16 @@


![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)
[![Build Status](https://travis-ci.org/deliveredtechnologies/terraform-maven.svg?branch=develop&maxAge=600&service=github)](https://travis-ci.org/deliveredtechnologies/terraform-maven)
[![Build Status](https://github.com/deliveredtechnologies/terraform-maven/workflows/build/badge.svg)](https://github.com/deliveredtechnologies/terraform-maven/actions?query=workflow%3A%22build%22)
[![Coverage Status](https://coveralls.io/repos/github/deliveredtechnologies/terraform-maven/badge.svg?branch=develop)](https://coveralls.io/github/deliveredtechnologies/terraform-maven?branch=develop)
[![Maven Central][maven-badge]][tf-maven-plugin]

# 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!
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!

<hr>

Expand Down Expand Up @@ -66,28 +69,29 @@ Not finding what you are looking for? [Try the Wiki!](https://github.com/deliver
* 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 Enterprise or some other private
* 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](https://maven.apache.org/pom.html). 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 resoolves transitive dependencies. No more modifying code for version updates! No more sourcing obscure URLs!
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](#tfpackage) 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](#tfdeploy) deploys a zip artifact packaged by the [package goal](#tfpackage) to a Maven repo
* By default, the [deploy goal](#tfdeploy) deploys a zip artifact packaged by the [package goal](#tfpackage) 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 or JUnit. One example of this is the [[tf-s3 example in this repo]](examples/tf-s3).
mature Java testing frameworks, like Spock, JUnit or TestNG. One example of this is the [[tf-s3 example in this repo]](examples/tf-s3).
* 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
Expand Down Expand Up @@ -262,7 +266,7 @@ Deletes all 'terraform' files from terraform configurations along with the Terra

Description:

Binds the Maven project to a specific Terraform binary version.
Binds the Maven project to a specific Terraform binary version (think [Maven Wrapper](https://github.com/takari/maven-wrapper), but for Terraform).

The format of the URL from which to fetch the Terraform binary is modeled after HashiCorp's distribution URL.

Expand Down Expand Up @@ -303,15 +307,15 @@ Instead of doing all the above steps you can simply build the module/project by
An example on how to generate the project using an archetype is shown below.

```bash
mvn archetype:generate -B -DarchetypeGroupId=com.deliveredtechnologies -DarchetypeArtifactId="tf-s3-archetype" -DarchetypeVersion=0.10 -DgroupId=<custom_group_name> -DartifactId=<custom-artifact_name>
mvn archetype:generate -B -DarchetypeGroupId=com.deliveredtechnologies -DarchetypeArtifactId="tf-s3-archetype" -DarchetypeVersion=0.12 -DgroupId=<custom_group_name> -DartifactId=<custom-artifact_name>
```

Maven Non-Interactive mode creates a project with the name that you passed in <custom_articatId_name> under <custom_groupId_name>.

or

```bash
mvn archetype:generate -DarchetypeGroupId=com.deliveredtechnologies -DarchetypeArtifactId="tf-s3-archetype" -DarchetypeVersion=0.10
mvn archetype:generate -DarchetypeGroupId=com.deliveredtechnologies -DarchetypeArtifactId="tf-s3-archetype" -DarchetypeVersion=0.12
```

After running the above command mvn interactive console prompts for the required arguments (ex: groupId and artifactId) and creates the project accordingly.
Expand All @@ -332,5 +336,6 @@ Use the plugin or update the plugin configuration in the POM to call terraform s

### Articles

* [Unit Testing Terraform](https://medium.com/@claytonlong_34858/unit-testing-terraform-e592a5c3777f)
* [Making Terraform Testing Groovy: Part 1 - Pre-provision Testing](https://medium.com/deliveredtechnologies/making-terraform-testing-groovy-6a9278bdce1)
* [Unit Testing Terraform](https://medium.com/deliveredtechnologies/unit-testing-terraform-e592a5c3777f)
* [Maven Gives Terraform a Big Boost](https://dzone.com/articles/maven-gives-terraform-a-big-boost)
1 change: 1 addition & 0 deletions examples/pom.xml
Expand Up @@ -8,5 +8,6 @@
<modules>
<module>tf-s3</module>
<module>tf-s3-consumer</module>
<module>tf-pre-post-infra-test</module>
</modules>
</project>

0 comments on commit 23d7937

Please sign in to comment.