Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
84 commits
Select commit Hold shift + click to select a range
bd84d09
Update index.php
maddytestaccount Feb 5, 2021
495fe84
Update appspec.yml
maddytestaccount Feb 8, 2021
5fa14f8
Update index.php
maddytestaccount Feb 8, 2021
e7cb8b8
Update appspec.yml
maddytestaccount Feb 8, 2021
c703c75
Delete stop_apache.sh
maddytestaccount Feb 8, 2021
493db13
Update appspec.yml
maddytestaccount Feb 8, 2021
76fc27b
Delete scripts directory
maddytestaccount Sep 15, 2021
13a65bc
Delete appspec.yml
maddytestaccount Sep 15, 2021
0b38bf2
Delete index.php
maddytestaccount Sep 15, 2021
994a6f2
add files
madhusudhanarava Sep 15, 2021
367d55c
add files to github
madhusudhanarava Sep 15, 2021
439fa9c
add files to githubs
madhusudhanarava Sep 15, 2021
cffdb73
add files to github release file
madhusudhanarava Sep 15, 2021
59bcb8b
add files to githubst
madhusudhanarava Sep 15, 2021
a3eb877
add files to githubste
madhusudhanarava Sep 15, 2021
a51d117
changes to release.yml file
madhusudhanarava Sep 15, 2021
3f6f193
changes to release.yml files
madhusudhanarava Sep 15, 2021
605cf37
changes to release.yml files so far
madhusudhanarava Sep 15, 2021
05c2ddf
changes to release.yml
madhusudhanarava Sep 15, 2021
d85d544
sample code to dev
madhusudhanarava Sep 16, 2021
7ca873e
sample code to des
madhusudhanarava Sep 16, 2021
aae8474
sample code to dest
madhusudhanarava Sep 16, 2021
2141690
sample code to desti
madhusudhanarava Sep 16, 2021
366ce0d
sample code to destin
madhusudhanarava Sep 16, 2021
0ad58d1
adding git files to workflow
madhusudhanarava Sep 19, 2021
6a3804d
adding git files to workflow plan
madhusudhanarava Sep 19, 2021
669315d
adding git files to workflow plan to hashicorp
madhusudhanarava Sep 19, 2021
1fbf669
adding git files to workflow plan to hashicorp sandbox
madhusudhanarava Sep 19, 2021
a464e71
adding git files to workflow plan to hashicorp sandbox workflow
madhusudhanarava Sep 19, 2021
6ab8d61
adding git files to workflow plan to hashicorp sandbox workflo
madhusudhanarava Sep 19, 2021
da3ff55
adding git files to workflow plan to hashicorp sandbox workfl
madhusudhanarava Sep 19, 2021
01ffd3f
adding git files to workflow plan to hashicorp sandbox work
madhusudhanarava Sep 20, 2021
bdc024a
adding git files to workflow plan to hashicorp sandbox test
madhusudhanarava Sep 20, 2021
3af9b2c
adding git files to actions
madhusudhanarava Sep 20, 2021
83ff03f
adding git files to actions for test
madhusudhanarava Sep 20, 2021
1485bf1
adding git files to actions for test to master
madhusudhanarava Sep 20, 2021
b1e30cc
adding git files to actions for test to pull request
madhusudhanarava Sep 20, 2021
5f314cc
adding git files to actions for test to pull
madhusudhanarava Sep 20, 2021
75caacd
adding git files to modules
madhusudhanarava Sep 20, 2021
a97bdce
adding git files to modules latest
madhusudhanarava Sep 20, 2021
793346a
adding git files to modules latest
madhusudhanarava Sep 20, 2021
687b9f4
adding git file
madhusudhanarava Sep 20, 2021
7b37d4f
adding git file to qa
madhusudhanarava Sep 20, 2021
151ee3d
adding git file to qa pr
madhusudhanarava Sep 20, 2021
616f035
create workflow based on pull_request
madhusudhanarava Sep 20, 2021
485fe18
create workflow based
madhusudhanarava Sep 20, 2021
b114fd8
create workflow based on tags
madhusudhanarava Sep 20, 2021
5cac3fc
edited tf files
madhusudhanarava Sep 20, 2021
9d030de
edited tf files in sandbox
madhusudhanarava Sep 20, 2021
d748ff8
Create deploy.sh
maddytestaccount Nov 8, 2021
76b4062
Update apply.yml
maddytestaccount Nov 8, 2021
d2b7d5b
Update apply.yml
maddytestaccount Nov 8, 2021
b50b13a
Update apply.yml
maddytestaccount Nov 8, 2021
900793f
Update apply.yml
maddytestaccount Nov 8, 2021
137293f
Update apply.yml
maddytestaccount Nov 8, 2021
1b9cfe2
Update apply.yml
maddytestaccount Nov 9, 2021
5afda38
Update variables.tf
maddytestaccount Nov 9, 2021
f7095bc
Update release.yml
maddytestaccount Nov 9, 2021
08e20e4
Update release.yml
maddytestaccount Nov 9, 2021
55328bb
Update deploy.sh
maddytestaccount Nov 9, 2021
69eb5b5
Update release.yml
maddytestaccount Nov 9, 2021
21a3e11
Update release.yml
maddytestaccount Nov 9, 2021
457a65a
Update release.yml
maddytestaccount Nov 9, 2021
261bd62
Update release.yml
maddytestaccount Nov 9, 2021
9189ac3
Update release.yml
maddytestaccount Nov 9, 2021
5d6c2c5
Update release.yml
maddytestaccount Nov 9, 2021
6706a69
Update release.yml
maddytestaccount Nov 9, 2021
99032ed
Update release.yml
maddytestaccount Nov 9, 2021
e973639
Update release.yml
maddytestaccount Nov 9, 2021
c439db5
Update release.yml
maddytestaccount Nov 9, 2021
24ba7ba
Update release.yml
maddytestaccount Nov 9, 2021
39842d3
Update release.yml
maddytestaccount Nov 9, 2021
b625096
Update release.yml
maddytestaccount Nov 9, 2021
4bd9a39
Update release.yml
maddytestaccount Nov 9, 2021
ab2717e
Update release.yml
maddytestaccount Nov 9, 2021
8df971a
Create deploy.sh
maddytestaccount Nov 9, 2021
8a9c46c
Update release.yml
maddytestaccount Nov 9, 2021
3eaf5a4
Update release.yml
maddytestaccount Nov 9, 2021
d1d6c09
Update release.yml
maddytestaccount Nov 9, 2021
00393ed
Update release.yml
maddytestaccount Nov 9, 2021
5260ba1
adding deploy.sh
madhusudhanarava Nov 29, 2021
14fe14b
update apply.yml file
madhusudhanarava Nov 29, 2021
da05d57
update apply.yml file
madhusudhanarava Nov 29, 2021
ee42871
updated tf files
madhusudhanarava Nov 29, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 110 additions & 0 deletions .github/workflows/apply.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
name: "Terraform-apply"

on:
pull_request:
types: [ closed ]

jobs:
# terraform-module:
# name: "Terraform-modules"
# runs-on: ubuntu-latest
# env:
# AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
# AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRETE_ID }}
# AWS_REGION: 'ap-east-1'

# steps:
# - name: 'Checkout'
# uses: actions/checkout@master
# - name: 'Terraform Init'
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_version: 0.12.13
# tf_actions_subcommand: 'init'
# tf_actions_working_dir: './modules/vpc'
# tf_actions_comment: true
# - name: 'Terraform plan'
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_version: 0.12.13
# tf_actions_subcommand: 'plan'
# tf_actions_working_dir: './modules/vpc'
# tf_actions_comment: true
# - name: 'Terraform apply'
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_version: 0.12.13
# tf_actions_subcommand: 'apply'
# tf_actions_working_dir: './modules/vpc'
# tf_actions_comment: true
terraform:
name: "Terraform"
needs: terraform-sandbox
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRETE_ID }}
AWS_REGION: 'eu-central-1'

steps:
- name: 'Checkout'
uses: actions/checkout@master
- name: set-env
run: echo "tf_actions_working_dir=$(echo $tf_actions_working_dir | cut -c 1-6)" >> $GITHUB_ENV
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'init'
tf_actions_working_dir: './environments/production'
tf_actions_comment: true

- name: 'Terraform plan'
uses: hashicorp/terraform-github-actions@master
- name: set env
run: ./bin/deploy.sh -e $tf_actions_working_dir -o plan >> $GITHUB_ENV
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'plan'
tf_actions_working_dir: './environments/production'
tf_actions_comment: true
- name: 'Terraform apply'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'apply'
tf_actions_working_dir: './environments/production'
tf_actions_comment: true
terraform-sandbox:
name: "sandbox-Terraform"

runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRETE_ID }}
AWS_REGION: 'ap-south-1'

steps:
- name: 'Checkout'
uses: actions/checkout@master
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'init'
tf_actions_working_dir: './environments/sandbox'
tf_actions_comment: true
- name: 'Terraform plan'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'plan'
tf_actions_working_dir: './environments/sandbox'
tf_actions_comment: true
- name: 'Terraform apply'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'apply'
tf_actions_working_dir: './environments/sandbox'
tf_actions_comment: true
84 changes: 84 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
name: "Terraform-Plan"

on:
pull_request:
branches: [ master ]

jobs:
terraform-module:
name: "Terraform-modules"
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRETE_ID }}
AWS_REGION: 'ap-east-1'

steps:
- name: 'Checkout'
uses: actions/checkout@master
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'init'
tf_actions_working_dir: './modules/vpc'
tf_actions_comment: true
# - name: 'Terraform plan'
# uses: hashicorp/terraform-github-actions@master
# with:
# tf_actions_version: 0.12.13
# tf_actions_subcommand: 'plan'
# tf_actions_working_dir: './modules/vpc'
# tf_actions_comment: true
terraform-sandbox:
name: "sandbox-Terraform"
needs: terraform-module
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRETE_ID }}
AWS_REGION: 'ap-south-1'

steps:
- name: 'Checkout'
uses: actions/checkout@master
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'init'
tf_actions_working_dir: './environments/sandbox'
tf_actions_comment: true
- name: 'Terraform plan'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'plan'
tf_actions_working_dir: './environments/sandbox'
tf_actions_comment: true
terraform-prod:
name: "Terraform-prod"
needs: terraform-sandbox
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRETE_ID }}
AWS_REGION: 'eu-central-1'

steps:
- name: 'Checkout'
uses: actions/checkout@master
- name: 'Terraform Init'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'init'
tf_actions_working_dir: './environments/production'
tf_actions_comment: true
- name: 'Terraform plan'
uses: hashicorp/terraform-github-actions@master
with:
tf_actions_version: 0.12.13
tf_actions_subcommand: 'plan'
tf_actions_working_dir: './environments/production'
tf_actions_comment: true
23 changes: 0 additions & 23 deletions appspec.yml

This file was deleted.

145 changes: 145 additions & 0 deletions bin/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
#!/usr/bin/env bash

# set -x # Un-comment to debug this script

#TF_LOG=DEBUG; TF_LOG_PATH=~tf.log # Un-comment to debug terraform

if [ -z "${BASH_VERSINFO[*]}" ] || [ -z "${BASH_VERSINFO[0]}" ] || [ "${BASH_VERSINFO[0]}" -lt 4 ]; then
echo "This script requires Bash version >= 4"
exit 1
fi

programname=$0
SCRIPT_REL_DIR=$(dirname "${0}")
ROOT=$(realpath "$SCRIPT_REL_DIR/../")
cd "$ROOT" || exit

TERRAFORM_OPTS=()

# echo 'pull latest code ...'
# git pull origin master

usage() {
echo "usage: $programname [-e environment] [-o operation]"
echo "MANDATORY:"
echo " -e, --environment VAL specify environment [global sandbox staging production management ops new_sandbox]"
echo " -o, --operation VAL specify operation [plan print_output apply]"
echo "OPTIONAL:"
echo " -a, --auto-approve TERRAFORM_OPTS: auto-approve on apply"
exit 1
}

parse_params() {
while [ ! $# -eq 0 ]; do
case "$1" in
--help | -h)
usage
exit
;;
--environment | -e)
ENV=$2
if [[ $ENV != "global" && $ENV != "sandbox" && $ENV != "staging" && $ENV != "production" && $ENV != "management" && $ENV != "ops" && $ENV != "new_sandbox" ]]; then
echo "Wrong environment: $ENV. Valid options: global sandbox staging production management ops"
exit 1
fi
;;
--operation | -o)
OPER=$2
if [[ $OPER != "plan" && $OPER != "print_output" && $OPER != "apply" ]]; then
echo "Wrong operation: $OPER. Valid options: plan print_output apply"
exit 1
fi
;;
--auto-approve | -a)
if [[ $OPER == "apply" ]]; then
TERRAFORM_OPTS+=('-auto-approve')
fi
;;
esac
shift
done
}

print_params() {
echo "-------------------------------"
echo "ENV : $ENV"
echo "OPER : $OPER"
echo "-------------------------------"
}

select_environment() {
ENVS=("global" "sandbox" "staging" "production" "management" "ops")
echo "Select environment:"
select var in "${ENVS[@]}"; do
ENV=$var
break
done
}

select_oper() {
OPERS=("apply" "plan" "print_output")
echo "Select operation:"
select oper in "${OPERS[@]}"; do
OPER=$oper
break
done
}

release_notes() {
RELEASE="RELEASES.md"
if ! grep -q "$PROJECT" $RELEASE; then
echo "#$PROJECT" >>$RELEASE
fi
DATE=$(date +%Y-%m-%d)
sed -i "/$PROJECT/a * **$DATE** - $DESCRIPTION" $RELEASE
}

get_output_var() {
terraform output -json | jq -r ".$1.value"
}

# Display output
display_output() {
terraform output
}

do_project() {
# cd to env folder
cd "environments/$ENV" || exit

# Deploy architecture
if [[ $OPER == "print_output" ]]; then
display_output
else
echo "Performing $OPER"
terraform "$OPER" "${TERRAFORM_OPTS[@]}" || exit 1
fi
}

update_shared_json() {
if [[ $ENV == "global" ]]; then
echo "[Skipping] Uploading shared.json to S3 - global env does not expose shared.json"
elif [[ $OPER != "apply" ]]; then
echo "[Skipping] Uploading shared.json to S3 - terraform outputs are updated only on apply"
else
echo 'Uploading shared.json to S3 ...'

output=$(terraform output -json)
echo "$output" >shared.json

aws s3 cp shared.json "s3://lambda-$ENV.spire.io/shared.json"
fi
}

# execution sequence:
[[ $# -eq 0 ]] && usage
parse_params "$@"
print_params
# select_project
# select_environment
# select_oper
do_project
update_shared_json

echo ''
echo 'done.'
31 changes: 31 additions & 0 deletions environments/production/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
variable "env" {
default = "undefined"
}

variable "region" {
default = "eu-central-1"
}

variable "zones" {
default = ["a", "b", "c"]
}

variable "vpc_cidr" {
default = "10.100.0.0/16"
}

variable "public_subnet_cidr_blocks" {
default = {
zone0 = "10.100.10.0/24"
zone1 = "10.100.20.0/24"
zone2 = "10.100.30.0/24"
}
}

variable "private_subnet_cidr_blocks" {
default = {
zone0 = "10.100.11.0/24"
zone1 = "10.100.21.0/24"
zone2 = "10.100.31.0/24"
}
}
Loading