Skip to content

Commit

Permalink
Destroy infra
Browse files Browse the repository at this point in the history
  • Loading branch information
yordanovsstoyan committed Nov 12, 2024
1 parent 6adf95f commit 67381db
Show file tree
Hide file tree
Showing 8 changed files with 240 additions and 154 deletions.
154 changes: 77 additions & 77 deletions .github/workflows/terraform-plan-apply.yaml
Original file line number Diff line number Diff line change
@@ -1,93 +1,93 @@
name: Terraform Plan Apply
# name: Terraform Plan Apply

on:
push:
pull_request:
workflow_dispatch:
# on:
# push:
# pull_request:
# workflow_dispatch:

jobs:
plan:
name: "Run Terraform Plan"
runs-on: ubuntu-20.04
# jobs:
# plan:
# name: "Run Terraform Plan"
# runs-on: ubuntu-20.04

defaults:
run:
working-directory: .
steps:
- name: 'Checkout'
uses: actions/checkout@v2
# defaults:
# run:
# working-directory: .
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: 1.3.9
terraform_wrapper: true
# - name: Setup Terraform
# uses: hashicorp/[email protected]
# with:
# terraform_version: 1.3.9
# terraform_wrapper: true

- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
# - name: configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: us-east-2
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}

- name: Terraform Init
id: init
run: terraform init -no-color
# - name: Terraform Init
# id: init
# run: terraform init -no-color

- name: Create Artifact Folder
shell: bash
run: |
sudo mkdir -p -m777 ${{ github.workspace }}/tfplanoutput
# - name: Create Artifact Folder
# shell: bash
# run: |
# sudo mkdir -p -m777 ${{ github.workspace }}/tfplanoutput

- name: Terraform Plan
id: plan
run: |
terraform plan -no-color -out=${{ github.workspace }}/tfplanoutput/tf.plan
# - name: Terraform Plan
# id: plan
# run: |
# terraform plan -no-color -out=${{ github.workspace }}/tfplanoutput/tf.plan

- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: artifact
path: ${{ github.workspace }}/tfplanoutput/
if-no-files-found: error
# - name: Upload Artifact
# uses: actions/upload-artifact@v3
# with:
# name: artifact
# path: ${{ github.workspace }}/tfplanoutput/
# if-no-files-found: error

apply:
name: "Run Terraform Apply"
needs: plan
runs-on: ubuntu-20.04
steps:
- name: 'Checkout'
uses: actions/checkout@v2
# apply:
# name: "Run Terraform Apply"
# needs: plan
# runs-on: ubuntu-20.04
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2

- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: 1.3.9
terraform_wrapper: true
# - name: Setup Terraform
# uses: hashicorp/[email protected]
# with:
# terraform_version: 1.3.9
# terraform_wrapper: true

- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
# - name: configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: us-east-2
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}

- name: Terraform Init
id: init
run: terraform init -no-color
# - name: Terraform Init
# id: init
# run: terraform init -no-color

- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: ${{ github.workspace }}/tfplanoutput
# - name: Download Build Artifact
# uses: actions/download-artifact@v3
# with:
# name: artifact
# path: ${{ github.workspace }}/tfplanoutput

- name: Terraform Apply
id: apply
run: |
terraform apply -no-color -input=false ${{ github.workspace }}/tfplanoutput/tf.plan
# - name: Terraform Apply
# id: apply
# run: |
# terraform apply -no-color -input=false ${{ github.workspace }}/tfplanoutput/tf.plan

- name: Terraform Output
id: output
run: |
terraform output
# - name: Terraform Output
# id: output
# run: |
# terraform output
152 changes: 76 additions & 76 deletions .github/workflows/terraform-plan-destroy.yaml
Original file line number Diff line number Diff line change
@@ -1,92 +1,92 @@
# name: Terraform Plan Destroy
name: Terraform Plan Destroy

# on:
# push:
# workflow_dispatch:
on:
push:
workflow_dispatch:

# jobs:
# plan:
# name: "Run Terraform Plan"
# runs-on: ubuntu-20.04
jobs:
plan:
name: "Run Terraform Plan"
runs-on: ubuntu-20.04

# defaults:
# run:
# working-directory: .
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2
defaults:
run:
working-directory: .
steps:
- name: 'Checkout'
uses: actions/checkout@v2

# - name: Setup Terraform
# uses: hashicorp/[email protected]
# with:
# terraform_version: 1.3.9
# terraform_wrapper: true
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: 1.3.9
terraform_wrapper: true

# - name: configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: us-east-2
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}

# - name: Terraform Init
# id: init
# run: terraform init -no-color
- name: Terraform Init
id: init
run: terraform init -no-color

# - name: Create Artifact Folder
# shell: bash
# run: |
# sudo mkdir -p -m777 ${{ github.workspace }}/tfplanoutput
- name: Create Artifact Folder
shell: bash
run: |
sudo mkdir -p -m777 ${{ github.workspace }}/tfplanoutput
# - name: Terraform Plan
# id: plan
# run: |
# terraform plan -destroy -no-color -out=${{ github.workspace }}/tfplanoutput/tf.plan
- name: Terraform Plan
id: plan
run: |
terraform plan -destroy -no-color -out=${{ github.workspace }}/tfplanoutput/tf.plan
# - name: Upload Artifact
# uses: actions/upload-artifact@v3
# with:
# name: artifact
# path: ${{ github.workspace }}/tfplanoutput/
# if-no-files-found: error
- name: Upload Artifact
uses: actions/upload-artifact@v3
with:
name: artifact
path: ${{ github.workspace }}/tfplanoutput/
if-no-files-found: error

# apply:
# name: "Run Terraform Apply"
# needs: plan
# runs-on: ubuntu-20.04
# steps:
# - name: 'Checkout'
# uses: actions/checkout@v2
apply:
name: "Run Terraform Apply"
needs: plan
runs-on: ubuntu-20.04
steps:
- name: 'Checkout'
uses: actions/checkout@v2

# - name: Setup Terraform
# uses: hashicorp/[email protected]
# with:
# terraform_version: 1.3.9
# terraform_wrapper: true
- name: Setup Terraform
uses: hashicorp/[email protected]
with:
terraform_version: 1.3.9
terraform_wrapper: true

# - name: configure AWS credentials
# uses: aws-actions/configure-aws-credentials@v4
# with:
# aws-region: us-east-2
# aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
# aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
- name: configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: us-east-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}

# - name: Terraform Init
# id: init
# run: terraform init -no-color
- name: Terraform Init
id: init
run: terraform init -no-color

# - name: Download Build Artifact
# uses: actions/download-artifact@v3
# with:
# name: artifact
# path: ${{ github.workspace }}/tfplanoutput
- name: Download Build Artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: ${{ github.workspace }}/tfplanoutput

# - name: Terraform Apply
# id: apply
# run: |
# terraform apply -no-color -input=false ${{ github.workspace }}/tfplanoutput/tf.plan
- name: Terraform Apply
id: apply
run: |
terraform apply -no-color -input=false ${{ github.workspace }}/tfplanoutput/tf.plan
# - name: Terraform Output
# id: output
# run: |
# terraform output
- name: Terraform Output
id: output
run: |
terraform output
8 changes: 7 additions & 1 deletion mysql-con/app.py
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
import os
import pymysql
import time

host = os.getenv('DB_HOST', 'localhost')
user = os.getenv('DB_USER', 'admin')
password = os.getenv('DB_PASSWORD', 'password')
database = os.getenv('DB_NAME', 'mydb')

connection = None
try:
# Connect to DB
connection = pymysql.connect(
host=host,
user=user,
password=password
password=password,
database=database
)
print(f"Connection to MySQL database successful! Hello World")
time.sleep(40)

except pymysql.MySQLError as e:
print(f"Error connecting to MySQL database: {e}")
time.sleep(40)
finally:
if connection:
connection.close()
print("Connection closed.")
time.sleep(20)
23 changes: 23 additions & 0 deletions mysql-connect-helm-chart/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
Loading

0 comments on commit 67381db

Please sign in to comment.