Commit 3e5582ce authored by Grzegorz Bizon's avatar Grzegorz Bizon

Merge branch 'feat-terraform-autodevops-script' into 'master'

Output terraform plan to JSON file

See merge request gitlab-org/gitlab!26830
parents 27309598 b0174461
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
# Entrypoint is also needed as image by default set `terraform` binary as an # Entrypoint is also needed as image by default set `terraform` binary as an
# entrypoint. # entrypoint.
image: image:
name: hashicorp/terraform:light name: registry.gitlab.com/gitlab-org/gitlab-build-images:terraform
entrypoint: entrypoint:
- '/usr/bin/env' - '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' - 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
...@@ -18,6 +18,7 @@ cache: ...@@ -18,6 +18,7 @@ cache:
- .terraform - .terraform
before_script: before_script:
- alias convert_report="jq -r '([.resource_changes[].change.actions?]|flatten)|{\"create\":(map(select(.==\"create\"))|length),\"update\":(map(select(.==\"update\"))|length),\"delete\":(map(select(.==\"delete\"))|length)}'"
- terraform --version - terraform --version
- terraform init - terraform init
...@@ -36,6 +37,7 @@ plan: ...@@ -36,6 +37,7 @@ plan:
stage: build stage: build
script: script:
- terraform plan -out=$PLAN - terraform plan -out=$PLAN
- "terraform show --json $PLAN | convert_report > tfplan.json"
artifacts: artifacts:
name: plan name: plan
paths: paths:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment