Commit 58116d09 authored by rajat.kulkarni's avatar rajat.kulkarni

Update .gitlab-ci.yml

parent 73697475
Pipeline #23184 canceled with stages
# This file is a template, and might need editing before it works on your project. # This file is a template, and might need editing before it works on your project.
# To contribute improvements to CI/CD templates, please follow the Development guide at: # Official image for Hashicorp's Terraform. It uses light image which is Alpine
# https://docs.gitlab.com/ee/development/cicd/templates.html # based as it is much lighter.
# This specific template is located at: #
# https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml # Entrypoint is also needed as image by default set `terraform` binary as an
# entrypoint.
#include: image:
# - template: Terraform/Base.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml name: hashicorp/terraform:light
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
# Default output file for Terraform plan
variables: variables:
TF_VAR_ACCESS_KEY: ${AWS_ACCESS_KEY_ID} PLAN: plan.tfplan
TF_VAR_SECRET_KEY: ${AWS_SECRET_ACCESS_KEY}
TF_VAR_AWS_REGION: ${AWS_DEFAULT_REGION}
stages:
- install
- build
- plan
- apply
- destroy
.common:
image:
name: hashicorp/terraform:0.14.2
install: cache:
tags: paths:
- rr - .terraform
stage: install
script:
-curl -o terraform.zip https://releases.hashicorp.com/terraform/0.12.2/terraform_0.12.2_linux_amd64.zip
-
only:
- master
build: before_script:
tags:
- rr
stage: build
script:
- terraform --version - terraform --version
- terraform init - terraform init
only:
- master
stages:
- validate
- build
- test
- deploy
validate:
stage: validate
script:
- terraform validate
plan: plan:
tags: stage: build
- rr
stage: plan
script: script:
- terraform plan - terraform plan -out=$PLAN
only: artifacts:
- master name: plan
paths:
- $PLAN
# Separate apply job for manual launching Terraform as it can be destructive
# action.
apply: apply:
tags: stage: deploy
- rr environment:
stage: apply name: production
script:
- terraform apply
dependencies:
- build
when: manual
only:
- master
destroy:
tags:
- rr
stage: destroy
script: script:
- echo "Destroying resources" - terraform apply -input=false $PLAN
- terraform destroy
dependencies: dependencies:
- apply - plan
when: manual when: manual
only: only:
refs:
- master - master
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