Commit 5ba6df08 authored by rajat.kulkarni's avatar rajat.kulkarni

Update .gitlab-ci.yml

parent 09246c6c
Pipeline #23350 failed with stages
in 5 seconds
# This file is a template, and might need editing before it works on your project. image:
# To contribute improvements to CI/CD templates, please follow the Development guide at: name: hashicorp/terraform:light
#https://docs.gitlab.com/ee/development/cicd/templates.html
# This specific template is located at:
#https://gitlab.com/gitlab-org/gitlab/-/blob/master/lib/gitlab/ci/templates/Terraform.gitlab-ci.yml
default:
image:
name: hashicorp/terraform:latest
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'
before_script: #image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
- wget https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip
- unzip terraform_0.12.29_linux_amd64.zip
- terraform init
cache:
key: terraform
paths:
- .terraform
variables: variables:
TF_VAR_ACCESS_KEY: ${AWS_ACCESS_KEY_ID} TF_VAR_ACCESS_KEY: ${AWS_ACCESS_KEY_ID}
TF_VAR_SECRET_KEY: ${AWS_SECRET_ACCESS_KEY} TF_VAR_SECRET_KEY: ${AWS_SECRET_ACCESS_KEY}
TF_VAR_AWS_REGION: ${AWS_DEFAULT_REGION} TF_VAR_AWS_REGION: ${AWS_DEFAULT_REGION}
cache:
paths:
- .terraform
stages: stages:
- iac_validate - install
- iac_plan - build
- iac_apply - plan
- apply
- destroy
iac_validate: install:
stage: iac_validate tags:
- rr
stage: install
script: script:
- terraform validate - wget https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip
except: - unzip terraform_0.12.29_linux_amd64.zip
refs:
#- mv terraform /usr/local/bin/
#- chown -R root:root /usr/local/bin/terraform
#- terraform_0.11.14_linux_amd64.zip
#- export PATH=$PATH:$HOME/terraform
only:
- master - master
build:
tags: tags:
- rr - rr
stage: build
iac_plan:
stage: iac_plan
script: script:
- terraform plan --out plan - terraform init
only: only:
refs:
- master - master
artifacts:
paths:
- plan
plan:
tags: tags:
- rr - rr
stage: plan
script:
- terraform plan
only:
- master
iac_apply: apply:
stage: iac_apply tags:
- rr
stage: apply
script: script:
- terraform apply --auto-approve plan - terraform apply
dependencies:
- build
when: manual when: manual
allow_failure: false
only: only:
refs:
- master - master
destroy:
tags: tags:
- rr - rr
stage: destroy
script:
- echo "Destroying resources"
- terraform destroy
dependencies:
- apply
when: manual
only:
refs:
- master
\ No newline at end of file
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