From 77c8945ef326b43ef3885d1e3db3159c704b8a5f Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 14:37:38 +0530 Subject: [PATCH 1/7] fix the deployment --- .gitignore | 15 +++++++++------ shipment-list-frontend/.gitignore | 1 + shipment-picture-lambda-validator/pom.xml | 18 ++++++++++++++++-- src/main/resources/buckets.properties | 4 ++-- 4 files changed, 28 insertions(+), 10 deletions(-) create mode 100644 shipment-list-frontend/.gitignore diff --git a/.gitignore b/.gitignore index d4e2fb4..27ff1f9 100644 --- a/.gitignore +++ b/.gitignore @@ -57,11 +57,14 @@ src/main/shipment-list-frontend/yarn-debug.log* src/main/shipment-list-frontend/yarn-error.log* # terraform - -setup/terraform/terraform.tfstate -setup/terraform/.terraform.lock.hcl -setup/terraform/terraform.tfstate.backup +terraform/.terraform/ +terraform/terraform.tfstate +terraform/.terraform.lock.hcl +terraform/terraform.tfstate.backup # lambda module -/shipment-picture-lambda-validator/.idea -/shipment-picture-lambda-validator/target/ +shipment-picture-lambda-validator/.idea +shipment-picture-lambda-validator/target/ + +# frontend +shipment-list-frontend/node_modules diff --git a/shipment-list-frontend/.gitignore b/shipment-list-frontend/.gitignore new file mode 100644 index 0000000..3c3629e --- /dev/null +++ b/shipment-list-frontend/.gitignore @@ -0,0 +1 @@ +node_modules diff --git a/shipment-picture-lambda-validator/pom.xml b/shipment-picture-lambda-validator/pom.xml index 67ec0a6..7cf6904 100644 --- a/shipment-picture-lambda-validator/pom.xml +++ b/shipment-picture-lambda-validator/pom.xml @@ -57,7 +57,7 @@ org.projectlombok lombok - 1.18.22 + 1.18.30 compile @@ -84,6 +84,20 @@ + + org.apache.maven.plugins + maven-compiler-plugin + 3.13.0 + + + + org.projectlombok + lombok + 1.18.30 + + + + org.apache.maven.plugins maven-shade-plugin @@ -103,4 +117,4 @@ - \ No newline at end of file + diff --git a/src/main/resources/buckets.properties b/src/main/resources/buckets.properties index 17e66ef..1b2b6aa 100755 --- a/src/main/resources/buckets.properties +++ b/src/main/resources/buckets.properties @@ -1,2 +1,2 @@ -shipment-picture-bucket=shipment-picture-bucket-artistic-alpaca -shipment-picture-bucket-validator=shipment-picture-lambda-validator-bucket-artistic-alpaca +shipment-picture-bucket=shipment-picture-bucket-polite-ghoul +shipment-picture-bucket-validator=shipment-picture-lambda-validator-bucket-polite-ghoul From b0fa9b137eb8f9567bdc454f3a833b6650456935 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 14:51:55 +0530 Subject: [PATCH 2/7] fix the ci --- .github/workflows/ci.yml | 53 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 25 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 618e0a7..5a1f8f2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,12 +20,12 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup Python uses: actions/setup-python@v4 with: - python-version: '3.9' + python-version: '3.11' - name: Set up JDK uses: actions/setup-java@v2 @@ -36,40 +36,43 @@ jobs: - name: Set up Maven run: sudo apt-get install -y maven - - name: Install localstack & awslocal + - name: Start LocalStack + uses: LocalStack/setup-localstack@v0.2.4 + with: + image-tag: 'latest' + use-pro: 'true' + configuration: LS_LOG=trace + install-awslocal: 'true' + env: + LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} + + - name: Install Terraform + uses: hashicorp/setup-terraform@v2 + + - name: Install tflocal run: | - pip install localstack pip install terraform-local - pip install awscli-local - name: Build project run: | cd shipment-picture-lambda-validator mvn clean package shade:shade - - name: Start LocalStack - run: | - docker pull localstack/localstack:latest - # Start LocalStack in the background - LS_LOG=trace localstack start -d - # Wait 30 seconds for the LocalStack container to become ready before timing out - echo "Waiting for LocalStack startup..." - localstack wait -t 15 - echo "Startup complete" - - - name: Run Terraform Config File + - name: Deploy using Terraform run: | cd terraform bash run-tflocal.sh - - name: Check for Bucket + - name: Build frontend + run: | + cd shipment-list-frontend + npm install + npm run build + + - name: Show LocalStack logs + if: always() run: | - output=$(awslocal s3api list-buckets --query "Buckets[?contains(Name, 'shipment-picture-bucket')].Name" --output text) - if [ -z "$output" ]; then - echo "Created bucket not found." - exit 1 - else echo "Bucket with random name was found: $output" - fi + localstack logs - name: Send a Slack notification if: failure() || github.event_name != 'pull_request' @@ -91,7 +94,7 @@ jobs: - name: Upload the Diagnostic Report if: failure() - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: diagnose.json.gz - path: ./diagnose.json.gz \ No newline at end of file + path: ./diagnose.json.gz From 22cf21869e13d6d18b9a457e8f3008d0a466f8ef Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 14:55:26 +0530 Subject: [PATCH 3/7] fix terraform deployment --- .github/workflows/ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5a1f8f2..57f2f93 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -61,7 +61,9 @@ jobs: - name: Deploy using Terraform run: | cd terraform - bash run-tflocal.sh + tflocal init + tflocal plan + tflocal apply --auto-approve - name: Build frontend run: | From f42e90f1edf883a0289b090461333f473b85a5ed Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 14:58:52 +0530 Subject: [PATCH 4/7] fix terraform deployment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 57f2f93..b69e8e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -47,7 +47,7 @@ jobs: LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }} - name: Install Terraform - uses: hashicorp/setup-terraform@v2 + uses: hashicorp/setup-terraform@v3 - name: Install tflocal run: | From 5513c1b7ea19ab74aaf216f504436125964ab66a Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 15:22:18 +0530 Subject: [PATCH 5/7] fix terraform deployment --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b69e8e0..cdab034 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -51,7 +51,7 @@ jobs: - name: Install tflocal run: | - pip install terraform-local + pip install --upgrade terraform-local - name: Build project run: | From 7586ac59bbc9a3b68bcfda3394fe3bea176f90b4 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 15:24:51 +0530 Subject: [PATCH 6/7] fix terraform deployment --- terraform/main.tf | 5 ----- 1 file changed, 5 deletions(-) diff --git a/terraform/main.tf b/terraform/main.tf index ebecdee..c86d26e 100644 --- a/terraform/main.tf +++ b/terraform/main.tf @@ -1,10 +1,5 @@ terraform { required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.59.0" - } - random = { source = "hashicorp/random" version = "~> 3.6.2" From 3b41a4a1950b3d9152a8238a1fb710e621a52315 Mon Sep 17 00:00:00 2001 From: Harsh Mishra Date: Wed, 23 Apr 2025 15:33:40 +0530 Subject: [PATCH 7/7] fix frontend deployment --- .github/workflows/ci.yml | 7 ++++++- terraform/cleanup.sh | 4 ---- terraform/run-tflocal.sh | 3 --- 3 files changed, 6 insertions(+), 8 deletions(-) delete mode 100644 terraform/cleanup.sh delete mode 100644 terraform/run-tflocal.sh diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index cdab034..9e4201c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,6 +22,11 @@ jobs: - name: Checkout uses: actions/checkout@v4 + - name: Setup Node + uses: actions/setup-node@v4 + with: + node-version: '22' + - name: Setup Python uses: actions/setup-python@v4 with: @@ -69,7 +74,7 @@ jobs: run: | cd shipment-list-frontend npm install - npm run build + CI=false npm run build - name: Show LocalStack logs if: always() diff --git a/terraform/cleanup.sh b/terraform/cleanup.sh deleted file mode 100644 index 81e33b1..0000000 --- a/terraform/cleanup.sh +++ /dev/null @@ -1,4 +0,0 @@ -rm .terraform.lock.hcl -rm -rf .terraform -rm terraform.tfstate -rm terraform.tfstate.backup \ No newline at end of file diff --git a/terraform/run-tflocal.sh b/terraform/run-tflocal.sh deleted file mode 100644 index 553d0e5..0000000 --- a/terraform/run-tflocal.sh +++ /dev/null @@ -1,3 +0,0 @@ -tflocal init -tflocal plan -tflocal apply --auto-approve \ No newline at end of file