Commit ef84f43c authored by rajat.kulkarni's avatar rajat.kulkarni

Update .gitlab-ci.yml

parent c28945cf
Pipeline #23188 failed
# 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.
# Official image for Hashicorp's Terraform. It uses light image which is Alpine # To contribute improvements to CI/CD templates, please follow the Development guide at:
# based as it is much lighter. # https://docs.gitlab.com/ee/development/cicd/templates.html
# # This specific template is located at:
# Entrypoint is also needed as image by default set `terraform` binary as an # https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
# entrypoint.
image: image:
name: hashicorp/terraform:light - name: Terraform/Base.gitlab-ci.yml # https://gitlab.com/gitlab-org/gitlab/blob/master/lib/gitlab/ci/templates/Terraform/Base.latest.gitlab-ci.yml
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:
PLAN: plan.tfplan TF_VAR_ACCESS_KEY: ${AWS_ACCESS_KEY_ID}
TF_VAR_SECRET_KEY: ${AWS_SECRET_ACCESS_KEY}
TF_VAR_AWS_REGION: ${AWS_DEFAULT_REGION}
cache: cache:
paths: paths:
- .terraform - .terraform
before_script:
- terraform --version
- terraform init
stages: stages:
- validate - install
- build - build
- test - plan
- deploy - apply
- destroy
validate: install:
stage: validate tags:
- rr
stage: install
script: script:
- terraform validate - curl -o terraform.zip https://releases.hashicorp.com/terraform/0.12.2/
plan:
only:
- master
build:
tags:
- rs
stage: build stage: build
script: script:
- terraform plan -out=$PLAN - terraform --version
artifacts: - terraform init
name: plan only:
paths: - merge_requests
- $PLAN
# Separate apply job for manual launching Terraform as it can be destructive
# action. plan:
tags:
- rs
stage: plan
script:
- terraform plan
only:
- master
apply: apply:
stage: deploy tags:
environment: - rs
name: production stage: apply
script: script:
- terraform apply -input=false $PLAN - terraform apply
dependencies: dependencies:
- plan - build
when: manual when: manual
only: only:
- master - master
destroy:
tags:
- rs
stage: destroy
script:
- echo "Destroying resources"
- terraform destroy
dependencies:
- apply
when: manual
only:
refs:
- 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