-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from telia-oss/add-terratest
Add terratest for examples
- Loading branch information
Showing
32 changed files
with
481 additions
and
423 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,20 @@ | ||
dist: trusty | ||
language: go | ||
sudo: false | ||
|
||
before_install: | ||
go: | ||
- 1.12.x | ||
|
||
env: | ||
- GO111MODULE=on AWS_REGION=eu-west-1 | ||
|
||
notifications: | ||
email: false | ||
|
||
before_script: | ||
- curl -fSL "https://releases.hashicorp.com/terraform/0.12.3/terraform_0.12.3_linux_amd64.zip" -o terraform.zip | ||
- sudo unzip terraform.zip -d /opt/terraform | ||
- sudo ln -s /opt/terraform/terraform /usr/bin/terraform | ||
- rm -f terraform.zip | ||
- curl -fSL https://github.com/wata727/tflint/releases/download/v0.7.0/tflint_linux_amd64.zip -o tflint.zip | ||
- sudo unzip tflint.zip -d /opt/tflint | ||
- sudo ln -s /opt/tflint/tflint /usr/bin/tflint | ||
- rm -f tflint.zip | ||
|
||
notifications: | ||
email: false | ||
|
||
script: | ||
- make | ||
- go get -u -v github.com/go-task/task/v2/cmd/task && task test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
version: '2' | ||
|
||
vars: | ||
DIRECTORIES: | ||
sh: find . -type f -name '*.tf' -not -path "**/.terraform/*" -exec dirname {} \; | sort -u | ||
FILES: | ||
sh: find . -type f -name '*.tf' -not -path "**/.terraform/*" | ||
|
||
tasks: | ||
default: | ||
cmds: | ||
- task: test | ||
|
||
test: | ||
desc: Run all tests. | ||
silent: true | ||
cmds: | ||
- task: fmt | ||
- task: validate | ||
|
||
tidy: | ||
desc: Tidy all the things. | ||
silent: true | ||
cmds: | ||
- go mod tidy | ||
- | | ||
for f in $(echo "{{.FILES}}"); do | ||
sed -i '' -E "s/^([ ]*version[ ]*=[ ]*)\"([^\"]*)\"/\\1\"{{.PROVIDER_VERSION}}\"/g" $f | ||
sed -i '' -E "s/^([ ]*required_version[ ]*=[ ]*)\"([^\"]*)\"/\\1\"{{.TERRAFORM_VERSION}}\"/g" $f | ||
done | ||
vars: | ||
TERRAFORM_VERSION: '>= 0.12' | ||
PROVIDER_VERSION: '>= 2.17' | ||
|
||
fmt: | ||
desc: Check formatting of all terraform files. | ||
silent: true | ||
cmds: | ||
- task: command | ||
vars: | ||
COMMAND: terraform fmt | ||
ARGS: -check=true -write=true -list=false -recursive=false | ||
PIPE: | ||
|
||
validate: | ||
desc: Validate all terraform directories. | ||
silent: true | ||
cmds: | ||
- task: command | ||
vars: | ||
COMMAND: terraform init | ||
ARGS: -backend=false -input=false -get=true -get-plugins=true -no-color | ||
PIPE: '> /dev/null' | ||
- task: command | ||
vars: | ||
COMMAND: terraform validate | ||
ARGS: | ||
PIPE: '> /dev/null' | ||
|
||
e2e: | ||
desc: Run the end 2 end test suite. | ||
cmds: | ||
- go test -v ./... -timeout=1h | ||
|
||
command: | ||
desc: Run a command on the terraform directories. | ||
silent: true | ||
cmds: | ||
- | | ||
BOLD=$(tput bold) | ||
NORM=$(tput sgr0) | ||
CODE=0 | ||
echo "${BOLD} {{.COMMAND}}:${NORM}" | ||
for d in $(echo "{{.DIRECTORIES}}"); do | ||
if ! {{.COMMAND}} {{.ARGS}} $d {{.PIPE}}; then | ||
echo " ✗ $d" && exit $? | ||
else | ||
echo " √ $d" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## examples/basic | ||
|
||
An example which shows _basic_ usage of the module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
terraform { | ||
required_version = ">= 0.12" | ||
} | ||
|
||
provider "aws" { | ||
version = ">= 2.17" | ||
region = "${var.region}" | ||
} | ||
|
||
module "vpc" { | ||
source = "../../" | ||
name_prefix = var.name_prefix | ||
|
||
tags = { | ||
terraform = "True" | ||
environment = "dev" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "vpc_id" { | ||
value = module.vpc.vpc_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
variable "name_prefix" { | ||
type = string | ||
default = "vpc-basic-example" | ||
} | ||
|
||
variable "region" { | ||
type = string | ||
default = "eu-west-1" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## examples/complete | ||
|
||
An example which shows a more _complete_ usage of the module. |
Oops, something went wrong.