Skip to content
Snippets Groups Projects
Commit 52f309cc authored by João Alexandre Cunha's avatar João Alexandre Cunha Committed by Matt Kasa
Browse files

Add terraform wrapper

parent 348df336
No related branches found
No related tags found
No related merge requests found
...@@ -6,6 +6,7 @@ services: ...@@ -6,6 +6,7 @@ services:
- docker:19.03.5-dind - docker:19.03.5-dind
stages: stages:
- lint
- build - build
- test - test
- release - release
...@@ -49,6 +50,14 @@ stages: ...@@ -49,6 +50,14 @@ stages:
TERRAFORM_BASE: "hashicorp/terraform:0.12.26" TERRAFORM_BASE: "hashicorp/terraform:0.12.26"
TERRAFORM_VERSION: "0.12" TERRAFORM_VERSION: "0.12"
shell check:
stage: lint
image: koalaman/shellcheck-alpine:stable
before_script:
- shellcheck --version
script:
- shellcheck src/**/*.sh
build 0.11: build 0.11:
<<: *terraform011 <<: *terraform011
<<: *build <<: *build
......
...@@ -3,5 +3,8 @@ FROM $BASE ...@@ -3,5 +3,8 @@ FROM $BASE
RUN apk add --no-cache jq RUN apk add --no-cache jq
COPY src/bin/gitlab-terraform.sh /usr/bin/gitlab-terraform
RUN chmod +x /usr/bin/gitlab-terraform
# Override ENTRYPOINT since hashicorp/terraform uses `terraform` # Override ENTRYPOINT since hashicorp/terraform uses `terraform`
ENTRYPOINT [] ENTRYPOINT []
#!/bin/sh -e
set -x
case "${1}" in
"plan-json")
output="${2}"
shift 2
terraform show --json "${@}" | jq -r '([.resource_changes[]?.change.actions?]|flatten)|{"create":(map(select(.=="create"))|length),"update":(map(select(.=="update"))|length),"delete":(map(select(.=="delete"))|length)}' > "${output}"
;;
*)
terraform "${@}"
;;
esac
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment