From e6c780dd14226a4f802265675a85681ccc32c775 Mon Sep 17 00:00:00 2001 From: Bello Date: Wed, 22 Jan 2025 02:05:59 -0400 Subject: [PATCH 01/22] added GH Action for docker --- .DS_Store | Bin 0 -> 6148 bytes .../workflows/build-docker.yaml" | 15 ++++ README.md | 26 ++++++- api/* | 65 ++++++++++++++++++ api/.DS_Store | Bin 0 -> 6148 bytes api/.env.example | 4 +- api/Dockerfile | 17 +++++ api/main.py | 27 +++++--- api/test_main.py | 12 ++-- front-end-nextjs/Dockerfile | 29 ++++++++ front-end-nextjs/install-dependencies.sh | 17 +++++ 11 files changed, 194 insertions(+), 18 deletions(-) create mode 100644 .DS_Store create mode 100644 ".github\\workflows/workflows/build-docker.yaml" create mode 100644 api/* create mode 100644 api/.DS_Store create mode 100644 api/Dockerfile create mode 100644 front-end-nextjs/Dockerfile create mode 100755 front-end-nextjs/install-dependencies.sh diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..41d9723b88012303a914919786ef39ffa18ec104 GIT binary patch literal 6148 zcmeHK-AcnS6i(c98AIrW!Y%{e4y>CDhBu|o7qFriDzl|Si?tbR=Pt&e*ZM*}iO=IX zNeT{oE#l6Bm#NLEl~XVnc7GGW(iru z05R~-7~suuF!o_l_H6yJJUnY9vH1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0 Date: Wed, 22 Jan 2025 02:15:42 -0400 Subject: [PATCH 02/22] added GH Action for docker --- .../workflows/build-docker.yaml" | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 ".github \\ workflows/workflows/build-docker.yaml" diff --git "a/.github \\ workflows/workflows/build-docker.yaml" "b/.github \\ workflows/workflows/build-docker.yaml" new file mode 100644 index 00000000..847e7472 --- /dev/null +++ "b/.github \\ workflows/workflows/build-docker.yaml" @@ -0,0 +1,15 @@ +name: Publish Docker image to Docker Hub +on: + [workflow_dispatch:] + +jobs: + publish_images: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + - name: Build image + run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest + - name: push image to docker hub + run: | + docker push echelonkay/devops-qr-code-api:latest From f49af0de7c6aa46bb33a104cd82a164925a9cbaa Mon Sep 17 00:00:00 2001 From: Bello Date: Wed, 22 Jan 2025 02:18:59 -0400 Subject: [PATCH 03/22] added GH Action for docker --- ".github \\ workflows/workflows/build-docker.yaml" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/.github \\ workflows/workflows/build-docker.yaml" "b/.github \\ workflows/workflows/build-docker.yaml" index 847e7472..55dfe14a 100644 --- "a/.github \\ workflows/workflows/build-docker.yaml" +++ "b/.github \\ workflows/workflows/build-docker.yaml" @@ -1,6 +1,6 @@ name: Publish Docker image to Docker Hub -on: - [workflow_dispatch:] +on: + [workflow_dispatch] jobs: publish_images: From a9f74ef74ab85f11bdaf48340a96f4b994152362 Mon Sep 17 00:00:00 2001 From: Bello Date: Wed, 22 Jan 2025 02:20:17 -0400 Subject: [PATCH 04/22] added GitH Action for docker --- ".github\\workflows/workflows/build-docker.yaml" | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 ".github\\workflows/workflows/build-docker.yaml" diff --git "a/.github\\workflows/workflows/build-docker.yaml" "b/.github\\workflows/workflows/build-docker.yaml" deleted file mode 100644 index 847e7472..00000000 --- "a/.github\\workflows/workflows/build-docker.yaml" +++ /dev/null @@ -1,15 +0,0 @@ -name: Publish Docker image to Docker Hub -on: - [workflow_dispatch:] - -jobs: - publish_images: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build image - run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - - name: push image to docker hub - run: | - docker push echelonkay/devops-qr-code-api:latest From 7aa01011f58e4a8994df18da1d25dfd2f36df61f Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 02:34:27 -0400 Subject: [PATCH 05/22] Delete .github \ workflows/workflows directory --- .../workflows/build-docker.yaml" | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 ".github \\ workflows/workflows/build-docker.yaml" diff --git "a/.github \\ workflows/workflows/build-docker.yaml" "b/.github \\ workflows/workflows/build-docker.yaml" deleted file mode 100644 index 55dfe14a..00000000 --- "a/.github \\ workflows/workflows/build-docker.yaml" +++ /dev/null @@ -1,15 +0,0 @@ -name: Publish Docker image to Docker Hub -on: - [workflow_dispatch] - -jobs: - publish_images: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - - name: Build image - run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - - name: push image to docker hub - run: | - docker push echelonkay/devops-qr-code-api:latest From 9fefd25a707ce931fc800527163c8e2460c4707f Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:02:12 -0400 Subject: [PATCH 06/22] Added GH docker-image --- .github/workflows/docker-image.yml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 .github/workflows/docker-image.yml diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml new file mode 100644 index 00000000..165b8bf4 --- /dev/null +++ b/.github/workflows/docker-image.yml @@ -0,0 +1,18 @@ +name: Publish Docker image to Docker Hub + +on: + workflow_dispatch # This allows manual triggering from GitHub UI + +jobs: + publish_images: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Build image + run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest + + - name: Push Docker image to Docker Hub + run: docker push echelonkay/devops-qr-code-api:latest From 5d4f575d2ca493f524b0863440ad7fd1f10798e6 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:14:17 -0400 Subject: [PATCH 07/22] Added GH Action for docker --- .github/workflows/docker-image.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index 165b8bf4..0f3c41fc 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,7 +1,7 @@ name: Publish Docker image to Docker Hub on: - workflow_dispatch # This allows manual triggering from GitHub UI + [workflow_dispatch] # This allows manual triggering from GitHub UI jobs: publish_images: @@ -14,5 +14,5 @@ jobs: - name: Build image run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - - name: Push Docker image to Docker Hub + - name: | run: docker push echelonkay/devops-qr-code-api:latest From 5f8687d17b5d554f38523e3b5da7814278dbcdd8 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:20:08 -0400 Subject: [PATCH 08/22] Update and rename docker-image.yml to build-docker.yaml --- .github/workflows/{docker-image.yml => build-docker.yaml} | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) rename .github/workflows/{docker-image.yml => build-docker.yaml} (67%) diff --git a/.github/workflows/docker-image.yml b/.github/workflows/build-docker.yaml similarity index 67% rename from .github/workflows/docker-image.yml rename to .github/workflows/build-docker.yaml index 0f3c41fc..1cea55cd 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/build-docker.yaml @@ -1,4 +1,4 @@ -name: Publish Docker image to Docker Hub +name: Build and Publish Image to Docker Hub on: [workflow_dispatch] # This allows manual triggering from GitHub UI @@ -14,5 +14,6 @@ jobs: - name: Build image run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - - name: | - run: docker push echelonkay/devops-qr-code-api:latest + - name: push image to docker hub + run: | + docker push echelonkay/devops-qr-code-api:latest From 6e6b55d3e26795284cddaebc844ed471adb19c15 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:22:15 -0400 Subject: [PATCH 09/22] Update build-docker.yaml --- .github/workflows/build-docker.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 1cea55cd..0b4baa45 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -15,5 +15,4 @@ jobs: run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - name: push image to docker hub - run: | - docker push echelonkay/devops-qr-code-api:latest + run: docker push echelonkay/devops-qr-code-api:latest From 3ac7b9379bc5ac002dc2cbfe1789ad0e82327c51 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:32:17 -0400 Subject: [PATCH 10/22] Update build-docker.yaml Dockerhub_token added --- .github/workflows/build-docker.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 0b4baa45..4e19cb4e 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -15,4 +15,6 @@ jobs: run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - name: push image to docker hub - run: docker push echelonkay/devops-qr-code-api:latest + run: | + docker login -u echelonkay -p ${{ secrets.DOCKER_HUB_TOKEN }} + docker push echelonkay/devops-qr-code-api:latest From 8b349e191f344aa66d104b701a86ff296a7220e6 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 19:42:16 -0400 Subject: [PATCH 11/22] Update build-docker.yaml From 7ec00f40f6ed9915a1dd3c4b9074a3856baddbe5 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:00:20 -0400 Subject: [PATCH 12/22] Update build-docker.yaml Add front-end --- .github/workflows/build-docker.yaml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 4e19cb4e..f2905eb5 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -6,15 +6,15 @@ on: jobs: publish_images: runs-on: ubuntu-latest - steps: - name: Checkout repository uses: actions/checkout@v4 - - - name: Build image - run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest - + - name: build image + run: | + docker build ./api/ -t echelonkay/devops-qr-code-api:latest + docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest - name: push image to docker hub run: | - docker login -u echelonkay -p ${{ secrets.DOCKER_HUB_TOKEN }} - docker push echelonkay/devops-qr-code-api:latest + docker login -u echelonkay -p ${{ secrets.DOCKER_HUB_TOKEN }} + docker push echelonkay/devops-qr-code-api:latest + docker push echelonkay/devops-qr-code-frontend:latest From 7cb6f616dd77acb9f1cea8e6c23910bbc6366946 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:17:48 -0400 Subject: [PATCH 13/22] Update build-docker.yaml Added no cache --- .github/workflows/build-docker.yaml | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index f2905eb5..f16c8e32 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -9,12 +9,18 @@ jobs: steps: - name: Checkout repository uses: actions/checkout@v4 - - name: build image - run: | - docker build ./api/ -t echelonkay/devops-qr-code-api:latest - docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest - - name: push image to docker hub - run: | - docker login -u echelonkay -p ${{ secrets.DOCKER_HUB_TOKEN }} - docker push echelonkay/devops-qr-code-api:latest - docker push echelonkay/devops-qr-code-frontend:latest + + - name: Log in to Docker Hub + run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "echelonkay" --password-stdin + + - name: Build API image + run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest --no-cache + + - name: Build Frontend image + run: docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest --no-cache + + - name: Push API image to Docker Hub + run: docker push echelonkay/devops-qr-code-api:latest + + - name: Push Frontend image to Docker Hub + run: docker push echelonkay/devops-qr-code-frontend:latest From 5d4eb5f4273f1e968f01be208a8c27e82221881f Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 20:48:36 -0400 Subject: [PATCH 14/22] Update build-docker.yaml Added Tag and .next --- .github/workflows/build-docker.yaml | 67 +++++++++++++++++++++-------- 1 file changed, 49 insertions(+), 18 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index f16c8e32..cad2abe0 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -1,26 +1,57 @@ -name: Build and Publish Image to Docker Hub +name: Build and Publish Docker Images on: - [workflow_dispatch] # This allows manual triggering from GitHub UI + workflow_dispatch: # Allows manual triggering from GitHub UI + inputs: + api_image_tag: + description: "Tag for the API image" + default: "latest" + required: false + frontend_image_tag: + description: "Tag for the Frontend image" + default: "latest" + required: false jobs: - publish_images: + build_and_push_images: runs-on: ubuntu-latest + steps: - - name: Checkout repository + # Step 1: Checkout repository + - name: Checkout Repository uses: actions/checkout@v4 - + + # Step 2: Log in to Docker Hub - name: Log in to Docker Hub - run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "echelonkay" --password-stdin - - - name: Build API image - run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest --no-cache - - - name: Build Frontend image - run: docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest --no-cache - - - name: Push API image to Docker Hub - run: docker push echelonkay/devops-qr-code-api:latest - - - name: Push Frontend image to Docker Hub - run: docker push echelonkay/devops-qr-code-frontend:latest + uses: docker/login-action@v2 + with: + username: echelonkay + password: ${{ secrets.DOCKER_HUB_TOKEN }} + + # Step 3: Build API Docker Image + - name: Build API Docker Image + run: | + docker build ./api/ \ + -t echelonkay/devops-qr-code-api:${{ github.event.inputs.api_image_tag }} \ + -t echelonkay/devops-qr-code-api:latest \ + --no-cache + + # Step 4: Push API Docker Image + - name: Push API Docker Image + run: | + docker push echelonkay/devops-qr-code-api:${{ github.event.inputs.api_image_tag }} + docker push echelonkay/devops-qr-code-api:latest + + # Step 5: Build Frontend Docker Image + - name: Build Frontend Docker Image + run: | + docker build ./front-end-nextjs/ \ + -t echelonkay/devops-qr-code-frontend:${{ github.event.inputs.frontend_image_tag }} \ + -t echelonkay/devops-qr-code-frontend:latest \ + --no-cache + + # Step 6: Push Frontend Docker Image + - name: Push Frontend Docker Image + run: | + docker push echelonkay/devops-qr-code-frontend:${{ github.event.inputs.frontend_image_tag }} + docker push echelonkay/devops-qr-code-frontend:latest From 9f6d254639bc49ad14042a9439eb0f71da0407c2 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 21:03:05 -0400 Subject: [PATCH 15/22] Update build-docker.yaml update .next file --- .github/workflows/build-docker.yaml | 61 +++++++++-------------------- 1 file changed, 18 insertions(+), 43 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index cad2abe0..8deeee53 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -1,57 +1,32 @@ name: Build and Publish Docker Images on: - workflow_dispatch: # Allows manual triggering from GitHub UI - inputs: - api_image_tag: - description: "Tag for the API image" - default: "latest" - required: false - frontend_image_tag: - description: "Tag for the Frontend image" - default: "latest" - required: false + workflow_dispatch: jobs: - build_and_push_images: + publish_images: runs-on: ubuntu-latest - steps: - # Step 1: Checkout repository - - name: Checkout Repository + # Step 1: Checkout the repository + - name: Checkout repository uses: actions/checkout@v4 - + # Step 2: Log in to Docker Hub - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: echelonkay - password: ${{ secrets.DOCKER_HUB_TOKEN }} + run: echo "${{ secrets.DOCKER_HUB_TOKEN }}" | docker login -u "echelonkay" --password-stdin - # Step 3: Build API Docker Image - - name: Build API Docker Image - run: | - docker build ./api/ \ - -t echelonkay/devops-qr-code-api:${{ github.event.inputs.api_image_tag }} \ - -t echelonkay/devops-qr-code-api:latest \ - --no-cache + # Step 3: Build API Docker image + - name: Build API Docker image + run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest --no-cache - # Step 4: Push API Docker Image - - name: Push API Docker Image - run: | - docker push echelonkay/devops-qr-code-api:${{ github.event.inputs.api_image_tag }} - docker push echelonkay/devops-qr-code-api:latest + # Step 4: Build Frontend Docker image + - name: Build Frontend Docker image + run: docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest --no-cache - # Step 5: Build Frontend Docker Image - - name: Build Frontend Docker Image - run: | - docker build ./front-end-nextjs/ \ - -t echelonkay/devops-qr-code-frontend:${{ github.event.inputs.frontend_image_tag }} \ - -t echelonkay/devops-qr-code-frontend:latest \ - --no-cache + # Step 5: Push API Docker image to Docker Hub + - name: Push API Docker image + run: docker push echelonkay/devops-qr-code-api:latest - # Step 6: Push Frontend Docker Image - - name: Push Frontend Docker Image - run: | - docker push echelonkay/devops-qr-code-frontend:${{ github.event.inputs.frontend_image_tag }} - docker push echelonkay/devops-qr-code-frontend:latest + # Step 6: Push Frontend Docker image to Docker Hub + - name: Push Frontend Docker image + run: docker push echelonkay/devops-qr-code-frontend:latest From af6c636f25404b32955f52e4ebef8a1558a7b2c0 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 22:09:57 -0400 Subject: [PATCH 16/22] Update build-docker.yaml add .next --- .github/workflows/build-docker.yaml | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 8deeee53..bdd8d23f 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -19,14 +19,26 @@ jobs: - name: Build API Docker image run: docker build ./api/ -t echelonkay/devops-qr-code-api:latest --no-cache - # Step 4: Build Frontend Docker image + # Step 4: Install dependencies for Frontend + - name: Install dependencies for Frontend + run: | + cd front-end-nextjs + npm install + + # Step 5: Build Frontend + - name: Build Frontend + run: | + cd front-end-nextjs + npm run build + + # Step 6: Build Frontend Docker image - name: Build Frontend Docker image run: docker build ./front-end-nextjs/ -t echelonkay/devops-qr-code-frontend:latest --no-cache - # Step 5: Push API Docker image to Docker Hub + # Step 7: Push API Docker image to Docker Hub - name: Push API Docker image run: docker push echelonkay/devops-qr-code-api:latest - # Step 6: Push Frontend Docker image to Docker Hub + # Step 8: Push Frontend Docker image to Docker Hub - name: Push Frontend Docker image run: docker push echelonkay/devops-qr-code-frontend:latest From 291b790898b064cbe6f15412b2806e316b478296 Mon Sep 17 00:00:00 2001 From: Silas Ajayi <123136127+SilasCloud@users.noreply.github.com> Date: Wed, 22 Jan 2025 22:42:43 -0400 Subject: [PATCH 17/22] Update build-docker.yaml Automate workflow. --- .github/workflows/build-docker.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index bdd8d23f..b2456554 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -1,7 +1,12 @@ name: Build and Publish Docker Images on: - workflow_dispatch: + push: + branches: + - main + paths: + - 'api/Dockerfile' + - 'front-end-nextjs/Dockerfile' jobs: publish_images: From 63de5eeb27bd562bf2b9c8d18f0d0f065f5f9ffb Mon Sep 17 00:00:00 2001 From: SilasCloud Date: Wed, 29 Jan 2025 01:11:44 +0000 Subject: [PATCH 18/22] Initial commit with Terraform infrastructure --- .gitignore | 37 ++++++++++++++++ .terraform.lock.hcl | 105 ++++++++++++++++++++++++++++++++++++++++++++ main.tf | 85 +++++++++++++++++++++++++++++++++++ provider.tf | 13 ++++++ 4 files changed, 240 insertions(+) create mode 100644 .gitignore create mode 100644 .terraform.lock.hcl create mode 100644 main.tf create mode 100644 provider.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..21e6d3cb --- /dev/null +++ b/.gitignore @@ -0,0 +1,37 @@ +# 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 \ No newline at end of file diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl new file mode 100644 index 00000000..240bbd7b --- /dev/null +++ b/.terraform.lock.hcl @@ -0,0 +1,105 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.84.0" + constraints = "~> 5.0" + hashes = [ + "h1:OJ53RNte7HLHSMxSkzu1S6H8sC0T8qnCAOcNLjjtMpc=", + "zh:078f77438aba6ec8bf9154b7d223e5c71c48d805d6cd3bcf9db0cc1e82668ac3", + "zh:1f6591ff96be00501e71b792ed3a5a14b21ff03afec9a1c4a3fd9300e6e5b674", + "zh:2ab694e022e81dd74485351c5836148a842ed71cf640664c9d871cb517b09602", + "zh:33c8ccb6e3dc496e828a7572dd981366c6271075c1189f249b9b5236361d7eff", + "zh:6f31068ebad1d627e421c72ccdaafe678c53600ca73714e977bf45ff43ae5d17", + "zh:7488623dccfb639347cae66f9001d39cf06b92e8081975235a1ac3a0ac3f44aa", + "zh:7f042b78b9690a8725c95b91a70fc8e264011b836605bcc342ac297b9ea3937d", + "zh:88b56ac6c7209dc0a775b79975a371918f3aed8f015c37d5899f31deff37c61a", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a1979ba840d704af0932f8de5f541cbb4caa9b6bbd25ed552a24e6772175ba07", + "zh:b058c0533dae580e69d1adbc1f69e6a80632374abfc10e8634d06187a108e87b", + "zh:c88610af9cf957f8dcf4382e0c9ca566ef10e3290f5de01d4d90b2d81b078aa8", + "zh:e9562c055a2247d0c287772b55abef468c79f8d66a74780fe1c5e5dae1a284a9", + "zh:f7a7c71d28441d925a25c08c4485c015b2d9f0338bc9707443e91ff8e161d3d9", + "zh:fee533e81976d0900aa6fa443dc54ef171cbd901847f28a6e8edb1d161fa6fde", + ] +} + +provider "registry.terraform.io/hashicorp/cloudinit" { + version = "2.3.5" + constraints = ">= 2.0.0" + hashes = [ + "h1:Sf1Lt21oTADbzsnlU38ylpkl8YXP0Beznjcy5F/Yx64=", + "zh:17c20574de8eb925b0091c9b6a4d859e9d6e399cd890b44cfbc028f4f312ac7a", + "zh:348664d9a900f7baf7b091cf94d657e4c968b240d31d9e162086724e6afc19d5", + "zh:5a876a468ffabff0299f8348e719cb704daf81a4867f8c6892f3c3c4add2c755", + "zh:6ef97ee4c8c6a69a3d36746ba5c857cf4f4d78f32aa3d0e1ce68f2ece6a5dba5", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:8283e5a785e3c518a440f6ac6e7cc4fc07fe266bf34974246f4e2ef05762feda", + "zh:a44eb5077950168b571b7eb65491246c00f45409110f0f172cc3a7605f19dba9", + "zh:aa0806cbff72b49c1b389c0b8e6904586e5259c08dabb7cb5040418568146530", + "zh:bec4613c3beaad9a7be7ca99cdb2852073f782355b272892e6ee97a22856aec1", + "zh:d7fe368577b6c8d1ae44c751ed42246754c10305c7f001cc0109833e95aa107d", + "zh:df2409fc6a364b1f0a0f8a9cd8a86e61e80307996979ce3790243c4ce88f2915", + "zh:ed3c263396ff1f4d29639cc43339b655235acf4d06296a7c120a80e4e0fd6409", + ] +} + +provider "registry.terraform.io/hashicorp/kubernetes" { + version = "2.35.1" + constraints = ">= 2.10.0" + hashes = [ + "h1:zgXeWvp4//Ry+4glwNrLMpPFOU8QBQlARNmR9WCNe9o=", + "zh:12212ca5ae47823ce14bfafb909eeb6861faf1e2435fb2fc4a8b334b3544b5f5", + "zh:3f49b3d77182df06b225ab266667de69681c2e75d296867eb2cf06a8f8db768c", + "zh:40832494d19f8a2b3cd0c18b80294d0b23ef6b82f6f6897b5fe00248a9997460", + "zh:739a5ddea61a77925ee7006a29c8717377a2e9d0a79a0bbd98738d92eec12c0d", + "zh:a02b472021753627c5c39447a56d125a32214c29ff9108fc499f2dcdf4f1cc4f", + "zh:b78865b3867065aa266d6758c9601a2756741478f5735a838c20d633d65e085b", + "zh:d362e87464683f5632790e66920ea803adb54c2bc0cb24b6fd9a314d2b1efffd", + "zh:d98206fe88c2c9a52b8d2d0cb2c877c812a4a51d19f9d8428e63cbd5fd8a304d", + "zh:dfa320946b1ce3f3615c42b3447a28dc9f604c06d8b9a6fe289855ab2ade4d11", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + "zh:fc1debd2e695b5222d2ccc8b24dab65baba4ee2418ecce944e64d42e79474cb5", + "zh:fdaf960443720a238c09e519aeb30faf74f027ac5d1e0a309c3b326888e031d7", + ] +} + +provider "registry.terraform.io/hashicorp/time" { + version = "0.12.1" + constraints = ">= 0.9.0" + hashes = [ + "h1:JzYsPugN8Fb7C4NlfLoFu7BBPuRVT2/fCOdCaxshveI=", + "zh:090023137df8effe8804e81c65f636dadf8f9d35b79c3afff282d39367ba44b2", + "zh:26f1e458358ba55f6558613f1427dcfa6ae2be5119b722d0b3adb27cd001efea", + "zh:272ccc73a03384b72b964918c7afeb22c2e6be22460d92b150aaf28f29a7d511", + "zh:438b8c74f5ed62fe921bd1078abe628a6675e44912933100ea4fa26863e340e9", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:85c8bd8eefc4afc33445de2ee7fbf33a7807bc34eb3734b8eefa4e98e4cddf38", + "zh:98bbe309c9ff5b2352de6a047e0ec6c7e3764b4ed3dfd370839c4be2fbfff869", + "zh:9c7bf8c56da1b124e0e2f3210a1915e778bab2be924481af684695b52672891e", + "zh:d2200f7f6ab8ecb8373cda796b864ad4867f5c255cff9d3b032f666e4c78f625", + "zh:d8c7926feaddfdc08d5ebb41b03445166df8c125417b28d64712dccd9feef136", + "zh:e2412a192fc340c61b373d6c20c9d805d7d3dee6c720c34db23c2a8ff0abd71b", + "zh:e6ac6bba391afe728a099df344dbd6481425b06d61697522017b8f7a59957d44", + ] +} + +provider "registry.terraform.io/hashicorp/tls" { + version = "4.0.6" + constraints = ">= 3.0.0" + hashes = [ + "h1:n3M50qfWfRSpQV9Pwcvuse03pEizqrmYEryxKky4so4=", + "zh:10de0d8af02f2e578101688fd334da3849f56ea91b0d9bd5b1f7a243417fdda8", + "zh:37fc01f8b2bc9d5b055dc3e78bfd1beb7c42cfb776a4c81106e19c8911366297", + "zh:4578ca03d1dd0b7f572d96bd03f744be24c726bfd282173d54b100fd221608bb", + "zh:6c475491d1250050765a91a493ef330adc24689e8837a0f07da5a0e1269e11c1", + "zh:81bde94d53cdababa5b376bbc6947668be4c45ab655de7aa2e8e4736dfd52509", + "zh:abdce260840b7b050c4e401d4f75c7a199fafe58a8b213947a258f75ac18b3e8", + "zh:b754cebfc5184873840f16a642a7c9ef78c34dc246a8ae29e056c79939963c7a", + "zh:c928b66086078f9917aef0eec15982f2e337914c5c4dbc31dd4741403db7eb18", + "zh:cded27bee5f24de6f2ee0cfd1df46a7f88e84aaffc2ecbf3ff7094160f193d50", + "zh:d65eb3867e8f69aaf1b8bb53bd637c99c6b649ba3db16ded50fa9a01076d1a27", + "zh:ecb0c8b528c7a619fa71852bb3fb5c151d47576c5aab2bf3af4db52588722eeb", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/main.tf b/main.tf new file mode 100644 index 00000000..42c9cfd3 --- /dev/null +++ b/main.tf @@ -0,0 +1,85 @@ +# Create a VPC +resource "aws_vpc" "main" { + cidr_block = "10.0.0.0/16" + enable_dns_hostnames = true +} + +# Create Subnet 1 +resource "aws_subnet" "subnet_1" { + vpc_id = aws_vpc.main.id + cidr_block = "10.0.0.0/20" + availability_zone = "eu-west-2a" + map_public_ip_on_launch = true +} + +# Create Subnet 2 +resource "aws_subnet" "subnet_2" { + vpc_id = aws_vpc.main.id + cidr_block = "10.0.16.0/20" # Updated CIDR to prevent overlap with Subnet 1 + availability_zone = "eu-west-2b" + map_public_ip_on_launch = true +} + +# Create Subnet 3 +resource "aws_subnet" "subnet_3" { + vpc_id = aws_vpc.main.id + cidr_block = "10.0.32.0/20" # Updated CIDR to prevent overlap with Subnet 1 + availability_zone = "eu-west-2c" + map_public_ip_on_launch = true +} + +# Create an Internet Gateway +resource "aws_internet_gateway" "internet_gw" { + vpc_id = aws_vpc.main.id +} + +# Create a Route Table +resource "aws_route_table" "route_table" { + vpc_id = aws_vpc.main.id + + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.internet_gw.id + } + + route { + cidr_block = "10.0.0.0/16" + gateway_id = "local" + } +} + +resource "aws_route_table_association" "subnet_1_association" { + subnet_id = aws_subnet.subnet_1.id + route_table_id = aws_route_table.route_table.id +} +resource "aws_route_table_association" "subnet_2_association" { + subnet_id = aws_subnet.subnet_2.id + route_table_id = aws_route_table.route_table.id +} +resource "aws_route_table_association" "subnet_3_association" { + subnet_id = aws_subnet.subnet_3.id + route_table_id = aws_route_table.route_table.id +} + +module "eks" { + source = "terraform-aws-modules/eks/aws" + version = "~> 19.0" + + cluster_name = "devops-capstone-project" + cluster_version = "1.27" + + cluster_endpoint_public_access = true + + vpc_id = aws_vpc.main.id + subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id] + control_plane_subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id] + + eks_managed_node_groups = { + green = { + min_size = 1 + max_size = 1 + desired_size = 1 + instance_types = ["t3.medium"] + } + } +} diff --git a/provider.tf b/provider.tf new file mode 100644 index 00000000..2ea2afba --- /dev/null +++ b/provider.tf @@ -0,0 +1,13 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } +} + +# Configure the AWS Provider +provider "aws" { + region = "eu-west-2" +} From d1716067f6ae6da4ef64ba126b50002af349624f Mon Sep 17 00:00:00 2001 From: SilasCloud Date: Wed, 29 Jan 2025 01:23:24 +0000 Subject: [PATCH 19/22] Resolved merge conflicts --- .github/workflows/build-docker.yaml | 4 ++++ README.md | 4 ++++ front-end-nextjs/Dockerfile | 19 +++++++++++++++++++ infrastructure | 1 + 4 files changed, 28 insertions(+) create mode 160000 infrastructure diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index b2456554..208e3dbd 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -46,4 +46,8 @@ jobs: # Step 8: Push Frontend Docker image to Docker Hub - name: Push Frontend Docker image +<<<<<<< HEAD run: docker push echelonkay/devops-qr-code-frontend:latest +======= + run: docker push echelonkay/devops-qr-code-frontend:latest +>>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) diff --git a/README.md b/README.md index 962530aa..ecbcc5ba 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,11 @@ The API code exists in the `api` directory. You can run the API server locally: - Create a virtualenv by typing in the following command: `python3 -m venv .venv` - Run command `source .venv/bin` - Run command `source .venv/bin/activate` +<<<<<<< HEAD - Install the required packages: `pip install -r requirements.txt` 'or pip install fastapi uvicorn boto3 python-dotenv pytest qrcode' +======= +- Install the required packages: `pip install -r requirements.txt` or `pip install fastapi uvicorn boto3 python-dotenv pytest qrcode` +>>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) - Create a `.env` file, and add you AWS Access and Secret key, check `.env.example` - and Save the Access & secret key, cat the `.env` to verify. - Also, change the BUCKET_NAME to your S3 bucket name in `main.py` diff --git a/front-end-nextjs/Dockerfile b/front-end-nextjs/Dockerfile index b81c78aa..10f458c9 100644 --- a/front-end-nextjs/Dockerfile +++ b/front-end-nextjs/Dockerfile @@ -11,19 +11,38 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ COPY install-dependencies.sh ./ # Install dependencies using the script +<<<<<<< HEAD RUN ./install-dependencies.sh +======= +RUN chmod +x ./install-dependencies.sh && ./install-dependencies.sh +>>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) # Copy the rest of the application code COPY . . +<<<<<<< HEAD +======= +# Run the Next.js build step +RUN npm run build + +# Expose the build folder +RUN mkdir -p .next + +# Copy the .next folder (to avoid context issues) +COPY .next ./.next + +>>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) # Expose the application port EXPOSE 3000 # Start the application CMD ["npm", "start"] +<<<<<<< HEAD # Build the Next.js app RUN npm run build # Expose the build folder COPY .next ./.next +======= +>>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) diff --git a/infrastructure b/infrastructure new file mode 160000 index 00000000..63de5eeb --- /dev/null +++ b/infrastructure @@ -0,0 +1 @@ +Subproject commit 63de5eeb27bd562bf2b9c8d18f0d0f065f5f9ffb From b828284bae6794bd862b1b48f8d838fd363ad733 Mon Sep 17 00:00:00 2001 From: SilasCloud Date: Wed, 29 Jan 2025 01:35:05 +0000 Subject: [PATCH 20/22] Recommit the project with infrastructure folder and Terraform configuration --- .github/workflows/build-docker.yaml | 4 ---- front-end-nextjs/Dockerfile | 16 ---------------- 2 files changed, 20 deletions(-) diff --git a/.github/workflows/build-docker.yaml b/.github/workflows/build-docker.yaml index 208e3dbd..b2456554 100644 --- a/.github/workflows/build-docker.yaml +++ b/.github/workflows/build-docker.yaml @@ -46,8 +46,4 @@ jobs: # Step 8: Push Frontend Docker image to Docker Hub - name: Push Frontend Docker image -<<<<<<< HEAD run: docker push echelonkay/devops-qr-code-frontend:latest -======= - run: docker push echelonkay/devops-qr-code-frontend:latest ->>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) diff --git a/front-end-nextjs/Dockerfile b/front-end-nextjs/Dockerfile index 10f458c9..72739a75 100644 --- a/front-end-nextjs/Dockerfile +++ b/front-end-nextjs/Dockerfile @@ -11,17 +11,11 @@ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* ./ COPY install-dependencies.sh ./ # Install dependencies using the script -<<<<<<< HEAD -RUN ./install-dependencies.sh -======= RUN chmod +x ./install-dependencies.sh && ./install-dependencies.sh ->>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) # Copy the rest of the application code COPY . . -<<<<<<< HEAD -======= # Run the Next.js build step RUN npm run build @@ -31,18 +25,8 @@ RUN mkdir -p .next # Copy the .next folder (to avoid context issues) COPY .next ./.next ->>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) # Expose the application port EXPOSE 3000 # Start the application CMD ["npm", "start"] -<<<<<<< HEAD - -# Build the Next.js app -RUN npm run build - -# Expose the build folder -COPY .next ./.next -======= ->>>>>>> 9db5a81 (Moved Terraform files into the infrastructure folder) From cd7d1c84d824ee72476ca506e069a30e3e7c8cbe Mon Sep 17 00:00:00 2001 From: SilasCloud Date: Wed, 29 Jan 2025 22:03:15 +0000 Subject: [PATCH 21/22] Re-added infrastructure directory correctly --- infrastructure | 1 - infrastructure/.gitignore | 37 ++++++++++ infrastructure/.terraform.lock.hcl | 105 +++++++++++++++++++++++++++++ infrastructure/main.tf | 85 +++++++++++++++++++++++ infrastructure/provider.tf | 13 ++++ 5 files changed, 240 insertions(+), 1 deletion(-) delete mode 160000 infrastructure create mode 100644 infrastructure/.gitignore create mode 100644 infrastructure/.terraform.lock.hcl create mode 100644 infrastructure/main.tf create mode 100644 infrastructure/provider.tf diff --git a/infrastructure b/infrastructure deleted file mode 160000 index 63de5eeb..00000000 --- a/infrastructure +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 63de5eeb27bd562bf2b9c8d18f0d0f065f5f9ffb diff --git a/infrastructure/.gitignore b/infrastructure/.gitignore new file mode 100644 index 00000000..21e6d3cb --- /dev/null +++ b/infrastructure/.gitignore @@ -0,0 +1,37 @@ +# 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 \ No newline at end of file diff --git a/infrastructure/.terraform.lock.hcl b/infrastructure/.terraform.lock.hcl new file mode 100644 index 00000000..240bbd7b --- /dev/null +++ b/infrastructure/.terraform.lock.hcl @@ -0,0 +1,105 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.84.0" + constraints = "~> 5.0" + hashes = [ + "h1:OJ53RNte7HLHSMxSkzu1S6H8sC0T8qnCAOcNLjjtMpc=", + "zh:078f77438aba6ec8bf9154b7d223e5c71c48d805d6cd3bcf9db0cc1e82668ac3", + "zh:1f6591ff96be00501e71b792ed3a5a14b21ff03afec9a1c4a3fd9300e6e5b674", + "zh:2ab694e022e81dd74485351c5836148a842ed71cf640664c9d871cb517b09602", + "zh:33c8ccb6e3dc496e828a7572dd981366c6271075c1189f249b9b5236361d7eff", + "zh:6f31068ebad1d627e421c72ccdaafe678c53600ca73714e977bf45ff43ae5d17", + "zh:7488623dccfb639347cae66f9001d39cf06b92e8081975235a1ac3a0ac3f44aa", + "zh:7f042b78b9690a8725c95b91a70fc8e264011b836605bcc342ac297b9ea3937d", + "zh:88b56ac6c7209dc0a775b79975a371918f3aed8f015c37d5899f31deff37c61a", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a1979ba840d704af0932f8de5f541cbb4caa9b6bbd25ed552a24e6772175ba07", + "zh:b058c0533dae580e69d1adbc1f69e6a80632374abfc10e8634d06187a108e87b", + "zh:c88610af9cf957f8dcf4382e0c9ca566ef10e3290f5de01d4d90b2d81b078aa8", + "zh:e9562c055a2247d0c287772b55abef468c79f8d66a74780fe1c5e5dae1a284a9", + "zh:f7a7c71d28441d925a25c08c4485c015b2d9f0338bc9707443e91ff8e161d3d9", + "zh:fee533e81976d0900aa6fa443dc54ef171cbd901847f28a6e8edb1d161fa6fde", + ] +} + +provider "registry.terraform.io/hashicorp/cloudinit" { + version = "2.3.5" + constraints = ">= 2.0.0" + hashes = [ + "h1:Sf1Lt21oTADbzsnlU38ylpkl8YXP0Beznjcy5F/Yx64=", + "zh:17c20574de8eb925b0091c9b6a4d859e9d6e399cd890b44cfbc028f4f312ac7a", + "zh:348664d9a900f7baf7b091cf94d657e4c968b240d31d9e162086724e6afc19d5", + "zh:5a876a468ffabff0299f8348e719cb704daf81a4867f8c6892f3c3c4add2c755", + "zh:6ef97ee4c8c6a69a3d36746ba5c857cf4f4d78f32aa3d0e1ce68f2ece6a5dba5", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:8283e5a785e3c518a440f6ac6e7cc4fc07fe266bf34974246f4e2ef05762feda", + "zh:a44eb5077950168b571b7eb65491246c00f45409110f0f172cc3a7605f19dba9", + "zh:aa0806cbff72b49c1b389c0b8e6904586e5259c08dabb7cb5040418568146530", + "zh:bec4613c3beaad9a7be7ca99cdb2852073f782355b272892e6ee97a22856aec1", + "zh:d7fe368577b6c8d1ae44c751ed42246754c10305c7f001cc0109833e95aa107d", + "zh:df2409fc6a364b1f0a0f8a9cd8a86e61e80307996979ce3790243c4ce88f2915", + "zh:ed3c263396ff1f4d29639cc43339b655235acf4d06296a7c120a80e4e0fd6409", + ] +} + +provider "registry.terraform.io/hashicorp/kubernetes" { + version = "2.35.1" + constraints = ">= 2.10.0" + hashes = [ + "h1:zgXeWvp4//Ry+4glwNrLMpPFOU8QBQlARNmR9WCNe9o=", + "zh:12212ca5ae47823ce14bfafb909eeb6861faf1e2435fb2fc4a8b334b3544b5f5", + "zh:3f49b3d77182df06b225ab266667de69681c2e75d296867eb2cf06a8f8db768c", + "zh:40832494d19f8a2b3cd0c18b80294d0b23ef6b82f6f6897b5fe00248a9997460", + "zh:739a5ddea61a77925ee7006a29c8717377a2e9d0a79a0bbd98738d92eec12c0d", + "zh:a02b472021753627c5c39447a56d125a32214c29ff9108fc499f2dcdf4f1cc4f", + "zh:b78865b3867065aa266d6758c9601a2756741478f5735a838c20d633d65e085b", + "zh:d362e87464683f5632790e66920ea803adb54c2bc0cb24b6fd9a314d2b1efffd", + "zh:d98206fe88c2c9a52b8d2d0cb2c877c812a4a51d19f9d8428e63cbd5fd8a304d", + "zh:dfa320946b1ce3f3615c42b3447a28dc9f604c06d8b9a6fe289855ab2ade4d11", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + "zh:fc1debd2e695b5222d2ccc8b24dab65baba4ee2418ecce944e64d42e79474cb5", + "zh:fdaf960443720a238c09e519aeb30faf74f027ac5d1e0a309c3b326888e031d7", + ] +} + +provider "registry.terraform.io/hashicorp/time" { + version = "0.12.1" + constraints = ">= 0.9.0" + hashes = [ + "h1:JzYsPugN8Fb7C4NlfLoFu7BBPuRVT2/fCOdCaxshveI=", + "zh:090023137df8effe8804e81c65f636dadf8f9d35b79c3afff282d39367ba44b2", + "zh:26f1e458358ba55f6558613f1427dcfa6ae2be5119b722d0b3adb27cd001efea", + "zh:272ccc73a03384b72b964918c7afeb22c2e6be22460d92b150aaf28f29a7d511", + "zh:438b8c74f5ed62fe921bd1078abe628a6675e44912933100ea4fa26863e340e9", + "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", + "zh:85c8bd8eefc4afc33445de2ee7fbf33a7807bc34eb3734b8eefa4e98e4cddf38", + "zh:98bbe309c9ff5b2352de6a047e0ec6c7e3764b4ed3dfd370839c4be2fbfff869", + "zh:9c7bf8c56da1b124e0e2f3210a1915e778bab2be924481af684695b52672891e", + "zh:d2200f7f6ab8ecb8373cda796b864ad4867f5c255cff9d3b032f666e4c78f625", + "zh:d8c7926feaddfdc08d5ebb41b03445166df8c125417b28d64712dccd9feef136", + "zh:e2412a192fc340c61b373d6c20c9d805d7d3dee6c720c34db23c2a8ff0abd71b", + "zh:e6ac6bba391afe728a099df344dbd6481425b06d61697522017b8f7a59957d44", + ] +} + +provider "registry.terraform.io/hashicorp/tls" { + version = "4.0.6" + constraints = ">= 3.0.0" + hashes = [ + "h1:n3M50qfWfRSpQV9Pwcvuse03pEizqrmYEryxKky4so4=", + "zh:10de0d8af02f2e578101688fd334da3849f56ea91b0d9bd5b1f7a243417fdda8", + "zh:37fc01f8b2bc9d5b055dc3e78bfd1beb7c42cfb776a4c81106e19c8911366297", + "zh:4578ca03d1dd0b7f572d96bd03f744be24c726bfd282173d54b100fd221608bb", + "zh:6c475491d1250050765a91a493ef330adc24689e8837a0f07da5a0e1269e11c1", + "zh:81bde94d53cdababa5b376bbc6947668be4c45ab655de7aa2e8e4736dfd52509", + "zh:abdce260840b7b050c4e401d4f75c7a199fafe58a8b213947a258f75ac18b3e8", + "zh:b754cebfc5184873840f16a642a7c9ef78c34dc246a8ae29e056c79939963c7a", + "zh:c928b66086078f9917aef0eec15982f2e337914c5c4dbc31dd4741403db7eb18", + "zh:cded27bee5f24de6f2ee0cfd1df46a7f88e84aaffc2ecbf3ff7094160f193d50", + "zh:d65eb3867e8f69aaf1b8bb53bd637c99c6b649ba3db16ded50fa9a01076d1a27", + "zh:ecb0c8b528c7a619fa71852bb3fb5c151d47576c5aab2bf3af4db52588722eeb", + "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", + ] +} diff --git a/infrastructure/main.tf b/infrastructure/main.tf new file mode 100644 index 00000000..42c9cfd3 --- /dev/null +++ b/infrastructure/main.tf @@ -0,0 +1,85 @@ +# Create a VPC +resource "aws_vpc" "main" { + cidr_block = "10.0.0.0/16" + enable_dns_hostnames = true +} + +# Create Subnet 1 +resource "aws_subnet" "subnet_1" { + vpc_id = aws_vpc.main.id + cidr_block = "10.0.0.0/20" + availability_zone = "eu-west-2a" + map_public_ip_on_launch = true +} + +# Create Subnet 2 +resource "aws_subnet" "subnet_2" { + vpc_id = aws_vpc.main.id + cidr_block = "10.0.16.0/20" # Updated CIDR to prevent overlap with Subnet 1 + availability_zone = "eu-west-2b" + map_public_ip_on_launch = true +} + +# Create Subnet 3 +resource "aws_subnet" "subnet_3" { + vpc_id = aws_vpc.main.id + cidr_block = "10.0.32.0/20" # Updated CIDR to prevent overlap with Subnet 1 + availability_zone = "eu-west-2c" + map_public_ip_on_launch = true +} + +# Create an Internet Gateway +resource "aws_internet_gateway" "internet_gw" { + vpc_id = aws_vpc.main.id +} + +# Create a Route Table +resource "aws_route_table" "route_table" { + vpc_id = aws_vpc.main.id + + route { + cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.internet_gw.id + } + + route { + cidr_block = "10.0.0.0/16" + gateway_id = "local" + } +} + +resource "aws_route_table_association" "subnet_1_association" { + subnet_id = aws_subnet.subnet_1.id + route_table_id = aws_route_table.route_table.id +} +resource "aws_route_table_association" "subnet_2_association" { + subnet_id = aws_subnet.subnet_2.id + route_table_id = aws_route_table.route_table.id +} +resource "aws_route_table_association" "subnet_3_association" { + subnet_id = aws_subnet.subnet_3.id + route_table_id = aws_route_table.route_table.id +} + +module "eks" { + source = "terraform-aws-modules/eks/aws" + version = "~> 19.0" + + cluster_name = "devops-capstone-project" + cluster_version = "1.27" + + cluster_endpoint_public_access = true + + vpc_id = aws_vpc.main.id + subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id] + control_plane_subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id] + + eks_managed_node_groups = { + green = { + min_size = 1 + max_size = 1 + desired_size = 1 + instance_types = ["t3.medium"] + } + } +} diff --git a/infrastructure/provider.tf b/infrastructure/provider.tf new file mode 100644 index 00000000..2ea2afba --- /dev/null +++ b/infrastructure/provider.tf @@ -0,0 +1,13 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + } +} + +# Configure the AWS Provider +provider "aws" { + region = "eu-west-2" +} From d987c6e9ebe454fa80052c8fb3093ae2a0adeb1d Mon Sep 17 00:00:00 2001 From: SilasCloud Date: Wed, 29 Jan 2025 22:06:22 +0000 Subject: [PATCH 22/22] Removed duplicate Terraform files from root directory --- .gitignore | 37 ---------------- .terraform.lock.hcl | 105 -------------------------------------------- main.tf | 85 ----------------------------------- provider.tf | 13 ------ 4 files changed, 240 deletions(-) delete mode 100644 .gitignore delete mode 100644 .terraform.lock.hcl delete mode 100644 main.tf delete mode 100644 provider.tf diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 21e6d3cb..00000000 --- a/.gitignore +++ /dev/null @@ -1,37 +0,0 @@ -# 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 \ No newline at end of file diff --git a/.terraform.lock.hcl b/.terraform.lock.hcl deleted file mode 100644 index 240bbd7b..00000000 --- a/.terraform.lock.hcl +++ /dev/null @@ -1,105 +0,0 @@ -# This file is maintained automatically by "terraform init". -# Manual edits may be lost in future updates. - -provider "registry.terraform.io/hashicorp/aws" { - version = "5.84.0" - constraints = "~> 5.0" - hashes = [ - "h1:OJ53RNte7HLHSMxSkzu1S6H8sC0T8qnCAOcNLjjtMpc=", - "zh:078f77438aba6ec8bf9154b7d223e5c71c48d805d6cd3bcf9db0cc1e82668ac3", - "zh:1f6591ff96be00501e71b792ed3a5a14b21ff03afec9a1c4a3fd9300e6e5b674", - "zh:2ab694e022e81dd74485351c5836148a842ed71cf640664c9d871cb517b09602", - "zh:33c8ccb6e3dc496e828a7572dd981366c6271075c1189f249b9b5236361d7eff", - "zh:6f31068ebad1d627e421c72ccdaafe678c53600ca73714e977bf45ff43ae5d17", - "zh:7488623dccfb639347cae66f9001d39cf06b92e8081975235a1ac3a0ac3f44aa", - "zh:7f042b78b9690a8725c95b91a70fc8e264011b836605bcc342ac297b9ea3937d", - "zh:88b56ac6c7209dc0a775b79975a371918f3aed8f015c37d5899f31deff37c61a", - "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", - "zh:a1979ba840d704af0932f8de5f541cbb4caa9b6bbd25ed552a24e6772175ba07", - "zh:b058c0533dae580e69d1adbc1f69e6a80632374abfc10e8634d06187a108e87b", - "zh:c88610af9cf957f8dcf4382e0c9ca566ef10e3290f5de01d4d90b2d81b078aa8", - "zh:e9562c055a2247d0c287772b55abef468c79f8d66a74780fe1c5e5dae1a284a9", - "zh:f7a7c71d28441d925a25c08c4485c015b2d9f0338bc9707443e91ff8e161d3d9", - "zh:fee533e81976d0900aa6fa443dc54ef171cbd901847f28a6e8edb1d161fa6fde", - ] -} - -provider "registry.terraform.io/hashicorp/cloudinit" { - version = "2.3.5" - constraints = ">= 2.0.0" - hashes = [ - "h1:Sf1Lt21oTADbzsnlU38ylpkl8YXP0Beznjcy5F/Yx64=", - "zh:17c20574de8eb925b0091c9b6a4d859e9d6e399cd890b44cfbc028f4f312ac7a", - "zh:348664d9a900f7baf7b091cf94d657e4c968b240d31d9e162086724e6afc19d5", - "zh:5a876a468ffabff0299f8348e719cb704daf81a4867f8c6892f3c3c4add2c755", - "zh:6ef97ee4c8c6a69a3d36746ba5c857cf4f4d78f32aa3d0e1ce68f2ece6a5dba5", - "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:8283e5a785e3c518a440f6ac6e7cc4fc07fe266bf34974246f4e2ef05762feda", - "zh:a44eb5077950168b571b7eb65491246c00f45409110f0f172cc3a7605f19dba9", - "zh:aa0806cbff72b49c1b389c0b8e6904586e5259c08dabb7cb5040418568146530", - "zh:bec4613c3beaad9a7be7ca99cdb2852073f782355b272892e6ee97a22856aec1", - "zh:d7fe368577b6c8d1ae44c751ed42246754c10305c7f001cc0109833e95aa107d", - "zh:df2409fc6a364b1f0a0f8a9cd8a86e61e80307996979ce3790243c4ce88f2915", - "zh:ed3c263396ff1f4d29639cc43339b655235acf4d06296a7c120a80e4e0fd6409", - ] -} - -provider "registry.terraform.io/hashicorp/kubernetes" { - version = "2.35.1" - constraints = ">= 2.10.0" - hashes = [ - "h1:zgXeWvp4//Ry+4glwNrLMpPFOU8QBQlARNmR9WCNe9o=", - "zh:12212ca5ae47823ce14bfafb909eeb6861faf1e2435fb2fc4a8b334b3544b5f5", - "zh:3f49b3d77182df06b225ab266667de69681c2e75d296867eb2cf06a8f8db768c", - "zh:40832494d19f8a2b3cd0c18b80294d0b23ef6b82f6f6897b5fe00248a9997460", - "zh:739a5ddea61a77925ee7006a29c8717377a2e9d0a79a0bbd98738d92eec12c0d", - "zh:a02b472021753627c5c39447a56d125a32214c29ff9108fc499f2dcdf4f1cc4f", - "zh:b78865b3867065aa266d6758c9601a2756741478f5735a838c20d633d65e085b", - "zh:d362e87464683f5632790e66920ea803adb54c2bc0cb24b6fd9a314d2b1efffd", - "zh:d98206fe88c2c9a52b8d2d0cb2c877c812a4a51d19f9d8428e63cbd5fd8a304d", - "zh:dfa320946b1ce3f3615c42b3447a28dc9f604c06d8b9a6fe289855ab2ade4d11", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - "zh:fc1debd2e695b5222d2ccc8b24dab65baba4ee2418ecce944e64d42e79474cb5", - "zh:fdaf960443720a238c09e519aeb30faf74f027ac5d1e0a309c3b326888e031d7", - ] -} - -provider "registry.terraform.io/hashicorp/time" { - version = "0.12.1" - constraints = ">= 0.9.0" - hashes = [ - "h1:JzYsPugN8Fb7C4NlfLoFu7BBPuRVT2/fCOdCaxshveI=", - "zh:090023137df8effe8804e81c65f636dadf8f9d35b79c3afff282d39367ba44b2", - "zh:26f1e458358ba55f6558613f1427dcfa6ae2be5119b722d0b3adb27cd001efea", - "zh:272ccc73a03384b72b964918c7afeb22c2e6be22460d92b150aaf28f29a7d511", - "zh:438b8c74f5ed62fe921bd1078abe628a6675e44912933100ea4fa26863e340e9", - "zh:78d5eefdd9e494defcb3c68d282b8f96630502cac21d1ea161f53cfe9bb483b3", - "zh:85c8bd8eefc4afc33445de2ee7fbf33a7807bc34eb3734b8eefa4e98e4cddf38", - "zh:98bbe309c9ff5b2352de6a047e0ec6c7e3764b4ed3dfd370839c4be2fbfff869", - "zh:9c7bf8c56da1b124e0e2f3210a1915e778bab2be924481af684695b52672891e", - "zh:d2200f7f6ab8ecb8373cda796b864ad4867f5c255cff9d3b032f666e4c78f625", - "zh:d8c7926feaddfdc08d5ebb41b03445166df8c125417b28d64712dccd9feef136", - "zh:e2412a192fc340c61b373d6c20c9d805d7d3dee6c720c34db23c2a8ff0abd71b", - "zh:e6ac6bba391afe728a099df344dbd6481425b06d61697522017b8f7a59957d44", - ] -} - -provider "registry.terraform.io/hashicorp/tls" { - version = "4.0.6" - constraints = ">= 3.0.0" - hashes = [ - "h1:n3M50qfWfRSpQV9Pwcvuse03pEizqrmYEryxKky4so4=", - "zh:10de0d8af02f2e578101688fd334da3849f56ea91b0d9bd5b1f7a243417fdda8", - "zh:37fc01f8b2bc9d5b055dc3e78bfd1beb7c42cfb776a4c81106e19c8911366297", - "zh:4578ca03d1dd0b7f572d96bd03f744be24c726bfd282173d54b100fd221608bb", - "zh:6c475491d1250050765a91a493ef330adc24689e8837a0f07da5a0e1269e11c1", - "zh:81bde94d53cdababa5b376bbc6947668be4c45ab655de7aa2e8e4736dfd52509", - "zh:abdce260840b7b050c4e401d4f75c7a199fafe58a8b213947a258f75ac18b3e8", - "zh:b754cebfc5184873840f16a642a7c9ef78c34dc246a8ae29e056c79939963c7a", - "zh:c928b66086078f9917aef0eec15982f2e337914c5c4dbc31dd4741403db7eb18", - "zh:cded27bee5f24de6f2ee0cfd1df46a7f88e84aaffc2ecbf3ff7094160f193d50", - "zh:d65eb3867e8f69aaf1b8bb53bd637c99c6b649ba3db16ded50fa9a01076d1a27", - "zh:ecb0c8b528c7a619fa71852bb3fb5c151d47576c5aab2bf3af4db52588722eeb", - "zh:f569b65999264a9416862bca5cd2a6177d94ccb0424f3a4ef424428912b9cb3c", - ] -} diff --git a/main.tf b/main.tf deleted file mode 100644 index 42c9cfd3..00000000 --- a/main.tf +++ /dev/null @@ -1,85 +0,0 @@ -# Create a VPC -resource "aws_vpc" "main" { - cidr_block = "10.0.0.0/16" - enable_dns_hostnames = true -} - -# Create Subnet 1 -resource "aws_subnet" "subnet_1" { - vpc_id = aws_vpc.main.id - cidr_block = "10.0.0.0/20" - availability_zone = "eu-west-2a" - map_public_ip_on_launch = true -} - -# Create Subnet 2 -resource "aws_subnet" "subnet_2" { - vpc_id = aws_vpc.main.id - cidr_block = "10.0.16.0/20" # Updated CIDR to prevent overlap with Subnet 1 - availability_zone = "eu-west-2b" - map_public_ip_on_launch = true -} - -# Create Subnet 3 -resource "aws_subnet" "subnet_3" { - vpc_id = aws_vpc.main.id - cidr_block = "10.0.32.0/20" # Updated CIDR to prevent overlap with Subnet 1 - availability_zone = "eu-west-2c" - map_public_ip_on_launch = true -} - -# Create an Internet Gateway -resource "aws_internet_gateway" "internet_gw" { - vpc_id = aws_vpc.main.id -} - -# Create a Route Table -resource "aws_route_table" "route_table" { - vpc_id = aws_vpc.main.id - - route { - cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.internet_gw.id - } - - route { - cidr_block = "10.0.0.0/16" - gateway_id = "local" - } -} - -resource "aws_route_table_association" "subnet_1_association" { - subnet_id = aws_subnet.subnet_1.id - route_table_id = aws_route_table.route_table.id -} -resource "aws_route_table_association" "subnet_2_association" { - subnet_id = aws_subnet.subnet_2.id - route_table_id = aws_route_table.route_table.id -} -resource "aws_route_table_association" "subnet_3_association" { - subnet_id = aws_subnet.subnet_3.id - route_table_id = aws_route_table.route_table.id -} - -module "eks" { - source = "terraform-aws-modules/eks/aws" - version = "~> 19.0" - - cluster_name = "devops-capstone-project" - cluster_version = "1.27" - - cluster_endpoint_public_access = true - - vpc_id = aws_vpc.main.id - subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id] - control_plane_subnet_ids = [aws_subnet.subnet_1.id, aws_subnet.subnet_2.id, aws_subnet.subnet_3.id] - - eks_managed_node_groups = { - green = { - min_size = 1 - max_size = 1 - desired_size = 1 - instance_types = ["t3.medium"] - } - } -} diff --git a/provider.tf b/provider.tf deleted file mode 100644 index 2ea2afba..00000000 --- a/provider.tf +++ /dev/null @@ -1,13 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - } -} - -# Configure the AWS Provider -provider "aws" { - region = "eu-west-2" -}