Skip to content

Commit 321c820

Browse files
committed
Configured backend and fixed some plan and apply errors
1 parent 069bc31 commit 321c820

20 files changed

Lines changed: 1485 additions & 1484 deletions

.github/workflows/pipeline.yml

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,53 @@
1-
name: Pipeline for architecture
2-
3-
on:
4-
push:
5-
branches:
6-
- main
7-
8-
jobs:
9-
build_and_push:
10-
runs-on: ubuntu-latest
11-
12-
steps:
13-
- name: Checkout Repository
14-
uses: actions/checkout@v4
15-
16-
- name: Setup python
17-
uses: actions/setup-python@v5
18-
with:
19-
python-version: "3.12"
20-
cache: pip
21-
22-
- name: Python version
23-
run: python --version
24-
25-
- name: Install Requirements
26-
run: pip install -r requirements.txt
27-
28-
- name: Verify app loads
29-
run: python -c "from app import app"
30-
31-
- name: Login to DockerHub
32-
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
33-
34-
- name: Build docker Image
35-
run: |
36-
docker build \
37-
-t lavanyasharma07/terraform-three-tier-aws:${{ github.sha }} \
38-
-t lavanyasharma07/terraform-three-tier-aws:latest \
39-
.
40-
41-
- name: Smoke Test Docker Image
42-
run: |
43-
docker run -d --name test-app -p 5000:5000 \
44-
lavanyasharma07/terraform-three-tier-aws:${{ github.sha }}
45-
sleep 20
46-
curl -v http://localhost:5000/health
47-
docker logs test-app
48-
docker rm -f test-app
49-
50-
- name: Push Docker image
51-
run: |
52-
docker push lavanyasharma07/terraform-three-tier-aws:${{ github.sha }}
53-
docker push lavanyasharma07/terraform-three-tier-aws:latest
1+
name: Pipeline for architecture
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build_and_push:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v4
15+
16+
- name: Setup python
17+
uses: actions/setup-python@v5
18+
with:
19+
python-version: "3.12"
20+
cache: pip
21+
22+
- name: Python version
23+
run: python --version
24+
25+
- name: Install Requirements
26+
run: pip install -r requirements.txt
27+
28+
- name: Verify app loads
29+
run: python -c "from app import app"
30+
31+
- name: Login to DockerHub
32+
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin
33+
34+
- name: Build docker Image
35+
run: |
36+
docker build \
37+
-t lavanyasharma07/terraform-three-tier-aws:${{ github.sha }} \
38+
-t lavanyasharma07/terraform-three-tier-aws:latest \
39+
.
40+
41+
- name: Smoke Test Docker Image
42+
run: |
43+
docker run -d --name test-app -p 5000:5000 \
44+
lavanyasharma07/terraform-three-tier-aws:${{ github.sha }}
45+
sleep 20
46+
curl -v http://localhost:5000/health
47+
docker logs test-app
48+
docker rm -f test-app
49+
50+
- name: Push Docker image
51+
run: |
52+
docker push lavanyasharma07/terraform-three-tier-aws:${{ github.sha }}
53+
docker push lavanyasharma07/terraform-three-tier-aws:latest
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: Terraform apply pipeline
2-
3-
on:
4-
workflow_dispatch
5-
6-
7-
jobs:
8-
apply_terraform:
9-
runs-on: ubuntu-latest
10-
11-
defaults:
12-
run:
13-
working-directory: terraform_infra
14-
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
19-
- name: Configure AWS Credentials
20-
uses: aws-actions/configure-aws-credentials@v4
21-
with:
22-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24-
aws-region: ap-south-1
25-
26-
- name: Setup Terraform
27-
uses: hashicorp/setup-terraform@v3
28-
with:
29-
terraform_version: 1.15.6
30-
31-
- name: Initialize Terraform
32-
run: terraform init
33-
34-
- name: Apply Terraform
1+
name: Terraform apply pipeline
2+
3+
on:
4+
workflow_dispatch
5+
6+
7+
jobs:
8+
apply_terraform:
9+
runs-on: ubuntu-latest
10+
11+
defaults:
12+
run:
13+
working-directory: terraform_infra
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Configure AWS Credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-region: ap-south-1
25+
26+
- name: Setup Terraform
27+
uses: hashicorp/setup-terraform@v3
28+
with:
29+
terraform_version: 1.15.6
30+
31+
- name: Initialize Terraform
32+
run: terraform init
33+
34+
- name: Apply Terraform
3535
run: terraform apply --auto-approve
Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,35 @@
1-
name: Terraform destroy pipeline
2-
3-
on:
4-
workflow_dispatch
5-
6-
7-
jobs:
8-
apply_terraform:
9-
runs-on: ubuntu-latest
10-
11-
defaults:
12-
run:
13-
working-directory: terraform_infra
14-
15-
steps:
16-
- name: Checkout
17-
uses: actions/checkout@v4
18-
19-
- name: Configure AWS Credentials
20-
uses: aws-actions/configure-aws-credentials@v4
21-
with:
22-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24-
aws-region: ap-south-1
25-
26-
- name: Setup Terraform
27-
uses: hashicorp/setup-terraform@v3
28-
with:
29-
terraform_version: 1.15.6
30-
31-
- name: Initialize Terraform
32-
run: terraform init
33-
34-
- name: Destroy Terraform
1+
name: Terraform destroy pipeline
2+
3+
on:
4+
workflow_dispatch
5+
6+
7+
jobs:
8+
apply_terraform:
9+
runs-on: ubuntu-latest
10+
11+
defaults:
12+
run:
13+
working-directory: terraform_infra
14+
15+
steps:
16+
- name: Checkout
17+
uses: actions/checkout@v4
18+
19+
- name: Configure AWS Credentials
20+
uses: aws-actions/configure-aws-credentials@v4
21+
with:
22+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
23+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
24+
aws-region: ap-south-1
25+
26+
- name: Setup Terraform
27+
uses: hashicorp/setup-terraform@v3
28+
with:
29+
terraform_version: 1.15.6
30+
31+
- name: Initialize Terraform
32+
run: terraform init
33+
34+
- name: Destroy Terraform
3535
run: terraform destroy --auto-approve
Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
name: Terraform pipeline
2-
3-
on:
4-
push:
5-
branches:
6-
main
7-
8-
paths:
9-
- 'terraform_infra/**'
10-
11-
jobs:
12-
apply_terraform:
13-
runs-on: ubuntu-latest
14-
15-
defaults:
16-
run:
17-
working-directory: terraform_infra
18-
19-
steps:
20-
- name: Checkout
21-
uses: actions/checkout@v4
22-
23-
- name: Configure AWS Credentials
24-
uses: aws-actions/configure-aws-credentials@v4
25-
with:
26-
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27-
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28-
aws-region: ap-south-1
29-
30-
- name: Setup Terraform
31-
uses: hashicorp/setup-terraform@v3
32-
with:
33-
terraform_version: 1.15.6
34-
35-
- name: Initialize Terraform
36-
run: terraform init
37-
38-
- name: Format correction
39-
run: terraform fmt -check -recursive
40-
41-
- name: Validate the configuration
42-
run: terraform validate
43-
44-
- name: Plan the infra
45-
id: plan
1+
name: Terraform pipeline
2+
3+
on:
4+
push:
5+
branches:
6+
main
7+
8+
paths:
9+
- 'terraform_infra/**'
10+
11+
jobs:
12+
apply_terraform:
13+
runs-on: ubuntu-latest
14+
15+
defaults:
16+
run:
17+
working-directory: terraform_infra
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Configure AWS Credentials
24+
uses: aws-actions/configure-aws-credentials@v4
25+
with:
26+
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
27+
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
28+
aws-region: ap-south-1
29+
30+
- name: Setup Terraform
31+
uses: hashicorp/setup-terraform@v3
32+
with:
33+
terraform_version: 1.15.6
34+
35+
- name: Initialize Terraform
36+
run: terraform init
37+
38+
- name: Format correction
39+
run: terraform fmt -check -recursive
40+
41+
- name: Validate the configuration
42+
run: terraform validate
43+
44+
- name: Plan the infra
45+
id: plan
4646
run: terraform plan -out=tfplan

Dockerfile

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
FROM python:3.12-slim
2-
3-
WORKDIR /app
4-
5-
COPY requirements.txt .
6-
7-
RUN pip install --no-cache-dir -r requirements.txt
8-
9-
COPY . .
10-
11-
EXPOSE 5000
12-
13-
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
14-
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/health')"
15-
16-
CMD ["sh", "-c", "gunicorn -w ${WORKERS:-1} -b 0.0.0.0:5000 app:app"]
1+
FROM python:3.12-slim
2+
3+
WORKDIR /app
4+
5+
COPY requirements.txt .
6+
7+
RUN pip install --no-cache-dir -r requirements.txt
8+
9+
COPY . .
10+
11+
EXPOSE 5000
12+
13+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
14+
CMD python -c "import urllib.request; urllib.request.urlopen('http://localhost:5000/health')"
15+
16+
CMD ["sh", "-c", "gunicorn -w ${WORKERS:-1} -b 0.0.0.0:5000 app:app"]

0 commit comments

Comments
 (0)