Gitlab - Terraform - AWS VPC Deployment Files, Images & Commands
Gitlab Commands








































git init git remote add origin https://gitlab.com/tha.kishorekumar/cicdtf.git git remote -v git remote set-url origin https://gitlab.com/tha.kishorekumar/cicdtf.git git add . git config --global user.name "Kishore Kumar" git config --global user.email "kishore@kishoreweb.com" git config --global --list git commit -m "Initial Commmit" git push -u origin dev.gitlab-ci.yml
image:
name: registry.gitlab.com/gitlab-org/gitlab-build-images:terraform
entrypoint:
- '/usr/bin/env'
- 'PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'
variables:
AWS_ACCESS_KEY_ID: ${AWS_ACCESS_KEY}
AWS_SECRET_ACCESS_KEY : ${AWS_SECRET_KEY}
AWS_DEFAULT_REGION: ${AWS_REGION}
cache:
paths:
- .terraform
before_script:
- terraform --version
- terraform init
stages:
- validate
- plan
- apply
- destroy
validate:
stage: validate
script:
- terraform validate
plan:
stage: plan
script:
- terraform plan -out="planfile"
dependencies:
- validate
artifacts:
paths:
- planfile
apply:
stage: apply
script:
- terraform apply -input=false "planfile"
dependencies:
- plan
when: manual
destroy:
stage: destroy
script:
- terraform destroy --auto-approve
when: manual
backend.tf
terraform {
backend "s3" {
bucket = "ctskishore-terraform-backend"
dynamodb_table = "terraform-state-lock-dynamo"
key = "network/demo.tfstate"
region = "ap-south-1"
}
}
vpc.tf
provider "aws" {
region = "ap-south-1"
}
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
instance_tenancy = "default"
tags = {
Name = "mainVpc"
}
}
.gitignore
# Local .terraform directories .terraform/ # .tfstate files *.tfstate *.tfstate.* # Crash log files crash.log crash.*.log # Exclude all .tfvars files, which are likely to contain sensitive data, such as # password, private keys, and other secrets. These should not be part of version # control as they are data points which are potentially sensitive and subject # to change depending on the environment. *.tfvars *.tfvars.json # Ignore override files as they are usually used to override resources locally and so # are not checked in override.tf override.tf.json *_override.tf *_override.tf.json # Ignore transient lock info files created by terraform apply .terraform.tfstate.lock.info # Include override files you do wish to add to version control using negated pattern # !example_override.tf # Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan # example: *tfplan* # Ignore CLI configuration files .terraformrc terraform.rc
Deployment Images
Step 1:

Step 2:

Step 3:

Step 4:

Step 5:

Step 6:

Step 7:

Step 8:

Step 9:

Step 10:

Step 11:

Step 12:

Step 13:

Step 14:

Step 15:

Step 16:

Step 17:

Step 18:

Step 19:

Step 20:

Step 21:

Step 22:

Step 23:

Step 24:

Step 25:

Step 26:

Step 27:

Step 28:

Step 29:

Step 30:

Step 31:

Step 32:

Step 33:

Step 34:

Step 35:

Step 36:

Step 37:

Step 38:

Step 39:

Step 40:
