Skip to content
Snippets Groups Projects
Commit 106d047f authored by Matt Kasa's avatar Matt Kasa
Browse files

feat: Add support for Terraform 1.0

feat: Update Terraform 0.15 to 0.15.5
feat: Remove support for Terraform 0.12
chore: Remove tfplantool workaround for <0.13.2
parent 2d821a55
Branches terraform-1.0
No related tags found
No related merge requests found
variables:
STABLE_VERSION: "0.15"
STABLE_VERSION: "1.0"
STABLE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/stable:latest"
BASE_IMAGE: "alpine:3.13.1"
BUILD_IMAGE_NAME: "$CI_REGISTRY_IMAGE/branches/$CI_COMMIT_REF_SLUG-$TERRAFORM_VERSION:$CI_COMMIT_SHA"
RELEASE_IMAGE_NAME: "$CI_REGISTRY_IMAGE/releases/$TERRAFORM_VERSION"
TF_ADDRESS: "$CI_API_V4_URL/projects/$CI_PROJECT_ID/terraform/state/$CI_PIPELINE_IID-$STATE_NAME"
TFPLANTOOL_VERSION: "v0.1.1"
.versions:
parallel:
matrix:
- BASE_IMAGE: "alpine:3.13.1"
TERRAFORM_BINARY_VERSION: "0.15.3"
- TERRAFORM_BINARY_VERSION: "1.0.0"
TERRAFORM_VERSION: "1.0"
STATE_NAME: terraform10
- TERRAFORM_BINARY_VERSION: "0.15.5"
TERRAFORM_VERSION: "0.15"
STATE_NAME: terraform015
- BASE_IMAGE: "alpine:3.13.1"
TERRAFORM_BINARY_VERSION: "0.14.11"
- TERRAFORM_BINARY_VERSION: "0.14.11"
TERRAFORM_VERSION: "0.14"
STATE_NAME: terraform014
- BASE_IMAGE: "alpine:3.13.1"
TERRAFORM_BINARY_VERSION: "0.13.7"
- TERRAFORM_BINARY_VERSION: "0.13.7"
TERRAFORM_VERSION: "0.13"
STATE_NAME: terraform013
- BASE_IMAGE: "alpine:3.13.1"
TERRAFORM_BINARY_VERSION: "0.12.31"
TERRAFORM_VERSION: "0.12"
STATE_NAME: terraform012
stages:
- lint
......@@ -66,7 +62,7 @@ build:
- .versions
stage: build
script:
- docker image build --tag "$BUILD_IMAGE_NAME" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg TERRAFORM_BINARY_VERSION=$TERRAFORM_BINARY_VERSION --build-arg TFPLANTOOL_VERSION=$TFPLANTOOL_VERSION .
- docker image build --tag "$BUILD_IMAGE_NAME" --build-arg BASE_IMAGE=$BASE_IMAGE --build-arg TERRAFORM_BINARY_VERSION=$TERRAFORM_BINARY_VERSION .
- docker image push "$BUILD_IMAGE_NAME"
.test:
......@@ -105,7 +101,6 @@ test-plan:
script:
- gitlab-terraform plan
- if [[ ! -f "plan.cache" ]]; then echo "expected to find a plan.cache file"; exit 1; fi
- tfplantool -f plan.cache backend get -k username
- gitlab-terraform plan-json
- if [[ ! -f "plan.json" ]]; then echo "expected to find a plan.json file"; exit 1; fi
- mv plan.cache $TERRAFORM_VERSION-plan.cache
......
ARG BASE_IMAGE
FROM golang:1.16 AS tfplantool
ARG TFPLANTOOL_VERSION
ARG TERRAFORM_BINARY_VERSION
WORKDIR /tfplantool
RUN git clone --branch $TFPLANTOOL_VERSION --depth 1 https://gitlab.com/mattkasa/tfplantool.git .
RUN sed -i -e "/github\.com\/hashicorp\/terraform/s/ v.*\$/ v$TERRAFORM_BINARY_VERSION/" go.mod
RUN go get -d -v ./...
RUN CGO_ENABLED=0 GOOS=linux go build -tags terraform_${TERRAFORM_BINARY_VERSION} -a -installsuffix cgo -o tfplantool .
FROM $BASE_IMAGE
ARG TERRAFORM_BINARY_VERSION
......@@ -28,8 +16,6 @@ RUN ( curl -sLo terraform.zip "https://releases.hashicorp.com/terraform/${TERRAF
WORKDIR /
COPY --from=tfplantool /tfplantool/tfplantool /usr/bin/tfplantool
COPY src/bin/gitlab-terraform.sh /usr/bin/gitlab-terraform
RUN chmod +x /usr/bin/gitlab-terraform
......
......@@ -51,9 +51,6 @@ export TF_HTTP_RETRY_WAIT_MIN="${TF_HTTP_RETRY_WAIT_MIN:-5}"
export TF_IN_AUTOMATION=true
apply() {
if ! terraform_is_at_least 0.13.2; then
tfplantool -f "${plan_cache}" backend set -k password -v "${TF_PASSWORD}"
fi
terraform "${@}" -input=false "${plan_cache}"
}
......
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