Skip to content
Open

Stage #147

Show file tree
Hide file tree
Changes from all commits
Commits
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
90 changes: 90 additions & 0 deletions .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
name: "vprofile IAC"
on:
push:
branches:
- main
- stage
paths:
- terraform/**
pull_request:
branches:
- main
paths:
- terraform/**

jobs:
terraform:
name: "Apply terraform packages"
runs-on: ubuntu-latest
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }}
AWS_REGION: "us-east-2"
defaults:
run:
shell: bash
working-directory: ./terraform
steps:
- name: "checkout repository"
uses: actions/checkout@v3

- name: "Setup Terraform"
uses: hashicorp/setup-terraform@v2
with:
terraform_version: 1.6.3


- name: "Terraform Init"
id: init
run: |
terraform init \
-backend-config="bucket=${BUCKET_TF_STATE}" \

- name: "Terraform format check"
id: fmt
run: |
terraform fmt -check

- name: "Terraform Validate"
id: "Validate"
run: |
terraform validate

- name: "Terraform Plan"
id: "Plan"
run: |
terraform plan -no-color -input=false -out=tfplan
continue-on-error: true

- name: Terraform plan status
if: steps.Plan.outcome == 'failure'
run: exit 1

- name: "Terraform Apply"
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
id: "Apply"
run: |
terraform apply -input=false -auto-approve tfplan

- name: "Configure AWS Credentials"
uses: aws-actions/configure-aws-credentials@v2
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-1


- name: "Get kube config file"
id: getconfig
if: steps.Apply.outcome == 'success' || steps.Plan.outcome == 'success'
run: |
aws eks update-kubeconfig --region ${{ env.AWS_REGION }} --name kitops-eks

- name: "Install ingress-nginx controller"
if: steps.getconfig.outcome == 'success'
run: |
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v1.8.1/deploy/static/provider/aws/deploy.yaml



1 change: 0 additions & 1 deletion terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,3 @@ locals {
cluster_name = var.clusterName
}

##
2 changes: 1 addition & 1 deletion terraform/vpc.tf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ module "vpc" {
"kubernetes.io/cluster/${local.cluster_name}" = "shared"
"kubernetes.io/role/internal-elb" = 1
}
}
}