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.
# To contribute improvements to CI/CD templates, please follow the Development guide at:
#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
image:
name: hashicorp/terraform:light
entrypoint:
- /usr/bin/env
- "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
before_script:
- 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
#image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
variables:
TF_VAR_ACCESS_KEY: ${AWS_ACCESS_KEY_ID}
TF_VAR_SECRET_KEY: ${AWS_SECRET_ACCESS_KEY}
TF_VAR_AWS_REGION: ${AWS_DEFAULT_REGION}
cache:
paths:
- .terraform
stages:
- iac_validate
- iac_plan
- iac_apply
- install
- build
- plan
- apply
- destroy
iac_validate:
stage: iac_validate
install:
tags:
- rr
stage: install
script:
- terraform validate
except:
refs:
- wget https://releases.hashicorp.com/terraform/0.12.29/terraform_0.12.29_linux_amd64.zip
- unzip terraform_0.12.29_linux_amd64.zip
#- 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
build:
tags:
- rr
iac_plan:
stage: iac_plan
stage: build
script:
- terraform plan --out plan
- terraform init
only:
refs:
- master
artifacts:
paths:
- plan
plan:
tags:
- rr
stage: plan
script:
- terraform plan
only:
- master
iac_apply:
stage: iac_apply
apply:
tags:
- rr
stage: apply
script:
- terraform apply --auto-approve plan
- terraform apply
dependencies:
- build
when: manual
allow_failure: false
only:
refs:
- master
destroy:
tags:
- 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