From 02840e2743033dd95d755979b92f5c65373073e1 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Mon, 3 Nov 2025 17:28:18 +0100 Subject: [PATCH 01/19] Support for LocalStack --- .github/workflows/common-test.yml | 322 +++++++++++++++++++ .github/workflows/pull-request.yml | 10 + .github/workflows/test-with-real-npm-all.yml | 43 +++ .github/workflows/test-with-real-npm.yml | 5 + src/awsCredentials.ts | 44 +++ src/configuration.ts | 13 + src/infraDeploy.ts | 5 + src/ioTService.ts | 9 +- src/lldebugger.ts | 5 + src/types/lldConfig.ts | 9 +- 10 files changed, 463 insertions(+), 2 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 098bd3ce..c21575ee 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -13,6 +13,11 @@ on: description: 'Test monorepo by specifying folder in config' type: string required: true + useLocalStack: + description: 'Use LocalStack instead of AWS' + type: boolean + required: false + default: false version: description: 'Specify the version of the package' type: string @@ -25,6 +30,7 @@ permissions: env: REAL_NPM: ${{ inputs.mode == 'global' || inputs.mode == 'local' }} TEST_MONOREPO: ${{ inputs.testMonorepo }} + USE_LOCALSTACK: ${{ inputs.useLocalStack }} node_version: 22 jobs: @@ -34,6 +40,17 @@ jobs: group: test-cdk-basic steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -60,11 +77,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/cdk-basic @@ -72,15 +98,25 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/cdk-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/cdk-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Deploy YAML version run: npm run deploy-yaml working-directory: test/cdk-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test YAML run: npx vitest --retry 2 test/cdk-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-cdk-esm: runs-on: ubuntu-latest @@ -88,6 +124,17 @@ jobs: group: test-cdk-esm steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -114,11 +161,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/cdk-esm @@ -126,10 +182,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/cdk-esm + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-esm.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/cdk-esm.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sls-basic: runs-on: ubuntu-latest @@ -137,6 +199,17 @@ jobs: group: test-sls-basic steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -164,11 +237,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/sls-basic @@ -176,10 +258,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sls-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sls-esbuild-cjs: runs-on: ubuntu-latest @@ -187,6 +275,17 @@ jobs: group: test-sls-esbuild-cjs steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -214,11 +313,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/sls-esbuild-cjs @@ -226,10 +334,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-esbuild-cjs + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-cjs.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-cjs.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sls-esbuild-esm: runs-on: ubuntu-latest @@ -237,6 +351,17 @@ jobs: group: test-sls-esbuild-esm steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -264,11 +389,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/sls-esbuild-esm @@ -276,10 +410,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-esbuild-esm + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-esm.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-esm.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-osls-basic: runs-on: ubuntu-latest @@ -287,6 +427,17 @@ jobs: group: test-osls-basic steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -314,11 +465,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/osls-basic @@ -326,10 +486,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/osls-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-osls-esbuild-cjs: runs-on: ubuntu-latest @@ -337,6 +503,17 @@ jobs: group: test-osls-esbuild-cjs steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -364,11 +541,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/osls-esbuild-cjs @@ -376,10 +562,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-esbuild-cjs + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-osls-esbuild-esm: runs-on: ubuntu-latest @@ -387,6 +579,17 @@ jobs: group: test-osls-esbuild-esm steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -414,11 +617,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/osls-esbuild-esm @@ -426,10 +638,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-esbuild-esm + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-esm.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-esm.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sam-basic: runs-on: ubuntu-latest @@ -437,6 +655,17 @@ jobs: group: test-sam-basic steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - uses: aws-actions/setup-sam@v2 with: use-installer: true @@ -467,11 +696,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/sam-basic @@ -479,10 +717,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sam-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sam-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sam-alt: runs-on: ubuntu-latest @@ -490,6 +734,17 @@ jobs: group: test-sam-alt steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - uses: aws-actions/setup-sam@v2 with: use-installer: true @@ -520,11 +775,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy run: npm run destroy working-directory: test/sam-alt @@ -532,10 +796,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sam-alt + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sam-alt.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-alt.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-terraform-basic: runs-on: ubuntu-latest @@ -543,6 +813,17 @@ jobs: group: test-terraform-basic steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -569,11 +850,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Setup Terraform uses: hashicorp/setup-terraform@v3 - name: Terraform Init @@ -588,10 +878,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/terraform-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/terraform-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/terraform-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-opentofu-basic: runs-on: ubuntu-latest @@ -599,6 +895,17 @@ jobs: group: test-opentofu-basic steps: - uses: actions/checkout@v4 + - name: Start LocalStack + if: ${{ inputs.useLocalStack }} + run: | + pip install localstack awscli-local + docker pull localstack/localstack:latest + localstack start -d + echo "Waiting for LocalStack to be ready..." + localstack wait -t 30 + localstack status services + env: + LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - name: Use Node.js uses: actions/setup-node@v4 with: @@ -625,11 +932,20 @@ jobs: npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test - name: Configure AWS Credentials + if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 with: aws-region: eu-west-1 role-to-assume: ${{ secrets.AWS_ROLE }} role-session-name: GitHubActions + - name: Configure LocalStack AWS Credentials + if: ${{ inputs.useLocalStack }} + run: | + aws configure set aws_access_key_id test + aws configure set aws_secret_access_key test + aws configure set region us-east-1 + env: + AWS_ENDPOINT_URL: http://localhost:4566 - name: Setup OpenTofu uses: opentofu/setup-opentofu@v1 - name: OpenTofu Init @@ -644,7 +960,13 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/opentofu-basic + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/opentofu-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/opentofu-basic.test.ts + env: + AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 9f6da130..dc94aa46 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -53,3 +53,13 @@ jobs: with: mode: build testMonorepo: false + useLocalStack: false + + test-localstack: + uses: ./.github/workflows/common-test.yml + secrets: inherit + needs: remove-old-layers + with: + mode: build + testMonorepo: false + useLocalStack: true diff --git a/.github/workflows/test-with-real-npm-all.yml b/.github/workflows/test-with-real-npm-all.yml index 1996366d..c76fd4c9 100644 --- a/.github/workflows/test-with-real-npm-all.yml +++ b/.github/workflows/test-with-real-npm-all.yml @@ -19,6 +19,16 @@ jobs: mode: global testMonorepo: false version: ${{ inputs.version }} + useLocalStack: false + secrets: inherit + + test-global-not-monorepo-localstack: + uses: ./.github/workflows/common-test.yml + with: + mode: global + testMonorepo: false + version: ${{ inputs.version }} + useLocalStack: true secrets: inherit test-local-not-monorepo: @@ -28,6 +38,17 @@ jobs: mode: local testMonorepo: false version: ${{ inputs.version }} + useLocalStack: false + secrets: inherit + + test-local-not-monorepo-localstack: + needs: test-global-not-monorepo + uses: ./.github/workflows/common-test.yml + with: + mode: local + testMonorepo: false + version: ${{ inputs.version }} + useLocalStack: true secrets: inherit test-global-monorepo: @@ -37,6 +58,17 @@ jobs: mode: global testMonorepo: true version: ${{ inputs.version }} + useLocalStack: false + secrets: inherit + + test-global-monorepo-localstack: + needs: test-local-not-monorepo + uses: ./.github/workflows/common-test.yml + with: + mode: global + testMonorepo: true + version: ${{ inputs.version }} + useLocalStack: true secrets: inherit test-local-monorepo: @@ -46,4 +78,15 @@ jobs: mode: local testMonorepo: true version: ${{ inputs.version }} + useLocalStack: false + secrets: inherit + + test-local-monorepo-localstack: + needs: test-global-monorepo + uses: ./.github/workflows/common-test.yml + with: + mode: local + testMonorepo: true + version: ${{ inputs.version }} + useLocalStack: true secrets: inherit diff --git a/.github/workflows/test-with-real-npm.yml b/.github/workflows/test-with-real-npm.yml index 9d1676c9..f34b6569 100644 --- a/.github/workflows/test-with-real-npm.yml +++ b/.github/workflows/test-with-real-npm.yml @@ -16,6 +16,10 @@ on: description: 'Test monorepo by specifying folder in config' type: boolean default: false + useLocalStack: + description: 'Use LocalStack instead of AWS' + type: boolean + default: false version: description: 'Specify the version of the package' type: string @@ -32,4 +36,5 @@ jobs: mode: ${{ inputs.mode }} testMonorepo: ${{ inputs.testMonorepo }} version: ${{ inputs.version }} + useLocalStack: ${{ inputs.useLocalStack }} secrets: inherit diff --git a/src/awsCredentials.ts b/src/awsCredentials.ts index 8b8ac227..6c9245d0 100644 --- a/src/awsCredentials.ts +++ b/src/awsCredentials.ts @@ -17,6 +17,50 @@ function getCredentialsProvider( }); } +/** + * Detects if LocalStack is being used by making a test request and checking for + * the 'x-localstack' header in the response. + * @see {@link https://github.com/localstack/localstack/pull/12769} + * @param awsConfiguration - AWS configuration to use for the test request + * @returns true if LocalStack is detected (x-localstack header present), false otherwise + */ +async function isLocalStackDetected( + awsConfiguration: AwsConfiguration, +): Promise { + // Enable LocalStack response header to detect LocalStack + process.env.LOCALSTACK_RESPONSE_HEADER_ENABLED = 'true'; + + const { STSClient, GetCallerIdentityCommand } = await import( + '@aws-sdk/client-sts' + ); + + const client = new STSClient({ + region: awsConfiguration.region, + credentials: fromNodeProviderChain({ + clientConfig: { region: awsConfiguration.region }, + profile: awsConfiguration.profile, + roleArn: awsConfiguration.role, + }), + }); + + const command = new GetCallerIdentityCommand({}); + const response = await client.send(command); + + // Check for x-localstack header in response metadata + const headers = (response.$metadata as any)?.httpHeaders; + if ( + headers && + ('x-localstack' in headers || + 'X-Localstack' in headers || + 'X-LOCALSTACK' in headers) + ) { + return true; + } + + return false; +} + export const AwsCredentials = { getCredentialsProvider, + isLocalStackDetected, }; diff --git a/src/configuration.ts b/src/configuration.ts index bcfab294..e6c46de4 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -9,6 +9,7 @@ import { getConfigTsFromConfigFile } from './configuration/getConfigFromTsConfig import { configFileDefaultName } from './constants.js'; import { ResourceDiscovery } from './resourceDiscovery.js'; import { Logger } from './logger.js'; +import { AwsCredentials } from './awsCredentials.js'; let config: LldConfig; const lambdas: Record = {}; @@ -41,9 +42,15 @@ async function readConfig() { }); const debuggerId = await generateDebuggerId(!!configFromWizard.observable); + const localStack = await AwsCredentials.isLocalStackDetected({ + profile: configFromWizard.profile, + region: configFromWizard.region, + role: configFromWizard.role, + }); setConfig({ ...configFromWizard, debuggerId, + localStack, start: false, // don't start the debugger after the wizard }); } else { @@ -63,9 +70,15 @@ async function readConfig() { : configFromConfigFile?.context, }; const debuggerId = await generateDebuggerId(!!configMerged.observable); + const localStack = await AwsCredentials.isLocalStackDetected({ + profile: configMerged.profile, + region: configMerged.region, + role: configMerged.role, + }); setConfig({ ...configMerged, debuggerId, + localStack, start: true, }); } diff --git a/src/infraDeploy.ts b/src/infraDeploy.ts index 0250421d..897e4b91 100755 --- a/src/infraDeploy.ts +++ b/src/infraDeploy.ts @@ -1061,6 +1061,11 @@ function getEnvironmentVariablesForDebugger({ env.LLD_VERBOSE = 'true'; } + // Disable TLS verification for LocalStack + if (Configuration.config.localStack) { + env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + } + return env; } diff --git a/src/ioTService.ts b/src/ioTService.ts index 74995cbd..2268f901 100755 --- a/src/ioTService.ts +++ b/src/ioTService.ts @@ -122,12 +122,19 @@ async function connect(props?: { credentials, }); + let region = props?.region; + + if (!region && process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') { + // it is localstack + region = process.env.AWS_REGION ?? 'us-east-1'; + } + device = new iot.device({ protocol: 'wss', host: endpoint, reconnectPeriod: 1, keepalive: 60, - region: props?.region, + region, accessKeyId: credentials?.accessKeyId, secretKey: credentials?.secretAccessKey, sessionToken: credentials?.sessionToken, diff --git a/src/lldebugger.ts b/src/lldebugger.ts index 11f89038..4cce667c 100755 --- a/src/lldebugger.ts +++ b/src/lldebugger.ts @@ -55,6 +55,11 @@ async function run() { return; } + if (Configuration.config.localStack) { + //https://github.com/localstack/localstack/issues/13308 + process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'; + } + let message = `Starting the debugger ${ Configuration.config.observable ? 'in Observability mode' diff --git a/src/types/lldConfig.ts b/src/types/lldConfig.ts index 201f84e1..9cb232fe 100644 --- a/src/types/lldConfig.ts +++ b/src/types/lldConfig.ts @@ -91,4 +91,11 @@ export type LldConfigCliArgs = { export type LldConfigTs = Partial; -export type LldConfig = LldConfigCliArgs & LldConfigTs & { debuggerId: string }; +export type LldConfig = LldConfigCliArgs & + LldConfigTs & { + debuggerId: string; + /** + * Indicates whether LocalStack is being used instead of real AWS services. + */ + localStack: boolean; + }; From 29fa2c8d17b10e6eabc8747d61660b481022a2aa Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Mon, 3 Nov 2025 20:45:15 +0100 Subject: [PATCH 02/19] chore: Update LocalStack detection to use IAMClient and ListAccountAliasesCommand --- src/awsCredentials.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/awsCredentials.ts b/src/awsCredentials.ts index 6c9245d0..ed31f745 100644 --- a/src/awsCredentials.ts +++ b/src/awsCredentials.ts @@ -30,11 +30,11 @@ async function isLocalStackDetected( // Enable LocalStack response header to detect LocalStack process.env.LOCALSTACK_RESPONSE_HEADER_ENABLED = 'true'; - const { STSClient, GetCallerIdentityCommand } = await import( - '@aws-sdk/client-sts' + const { IAMClient, ListAccountAliasesCommand } = await import( + '@aws-sdk/client-iam' ); - const client = new STSClient({ + const client = new IAMClient({ region: awsConfiguration.region, credentials: fromNodeProviderChain({ clientConfig: { region: awsConfiguration.region }, @@ -43,7 +43,7 @@ async function isLocalStackDetected( }), }); - const command = new GetCallerIdentityCommand({}); + const command = new ListAccountAliasesCommand({}); const response = await client.send(command); // Check for x-localstack header in response metadata From 9f1f03c1e0f02e1958028e38e1188b661c2cefa8 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Mon, 3 Nov 2025 20:51:19 +0100 Subject: [PATCH 03/19] fix: Add CDK bootstrap step for LocalStack in CI workflow --- .github/workflows/common-test.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index c21575ee..b5459eff 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -91,6 +91,13 @@ jobs: aws configure set region us-east-1 env: AWS_ENDPOINT_URL: http://localhost:4566 + - name: Bootstrap CDK for LocalStack + if: ${{ inputs.useLocalStack }} + run: npx cdk bootstrap aws://000000000000/us-east-1 + working-directory: test/cdk-basic + env: + AWS_ENDPOINT_URL: http://localhost:4566 + CDK_DEFAULT_REGION: eu-west-1 - name: Destroy run: npm run destroy working-directory: test/cdk-basic @@ -100,6 +107,7 @@ jobs: working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + CDK_DEFAULT_REGION: ${{ inputs.useLocalStack && 'eu-west-1' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-basic.test.ts env: @@ -113,6 +121,7 @@ jobs: working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + CDK_DEFAULT_REGION: ${{ inputs.useLocalStack && 'eu-west-1' || '' }} - name: Test YAML run: npx vitest --retry 2 test/cdk-basic.test.ts env: @@ -175,6 +184,13 @@ jobs: aws configure set region us-east-1 env: AWS_ENDPOINT_URL: http://localhost:4566 + - name: Bootstrap CDK for LocalStack + if: ${{ inputs.useLocalStack }} + run: npx cdk bootstrap aws://000000000000/us-east-1 + working-directory: test/cdk-esm + env: + AWS_ENDPOINT_URL: http://localhost:4566 + CDK_DEFAULT_REGION: eu-west-1 - name: Destroy run: npm run destroy working-directory: test/cdk-esm @@ -184,6 +200,7 @@ jobs: working-directory: test/cdk-esm env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + CDK_DEFAULT_REGION: ${{ inputs.useLocalStack && 'eu-west-1' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-esm.test.ts env: From 77db7112f33598b89a19edb24322b91d04da53d8 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 07:24:11 +0100 Subject: [PATCH 04/19] fix: Update CDK bootstrap region for LocalStack in CI workflow --- .github/workflows/common-test.yml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index b5459eff..6a52006c 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -93,11 +93,11 @@ jobs: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdk bootstrap aws://000000000000/us-east-1 + run: npx cdk bootstrap aws://000000000000/eu-west-1 working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: http://localhost:4566 - CDK_DEFAULT_REGION: eu-west-1 + # CDK_DEFAULT_REGION: eu-west-1 - name: Destroy run: npm run destroy working-directory: test/cdk-basic @@ -107,7 +107,6 @@ jobs: working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - CDK_DEFAULT_REGION: ${{ inputs.useLocalStack && 'eu-west-1' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-basic.test.ts env: @@ -121,7 +120,6 @@ jobs: working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - CDK_DEFAULT_REGION: ${{ inputs.useLocalStack && 'eu-west-1' || '' }} - name: Test YAML run: npx vitest --retry 2 test/cdk-basic.test.ts env: @@ -186,11 +184,11 @@ jobs: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdk bootstrap aws://000000000000/us-east-1 + run: npx cdk bootstrap aws://000000000000/eu-west-1 working-directory: test/cdk-esm env: AWS_ENDPOINT_URL: http://localhost:4566 - CDK_DEFAULT_REGION: eu-west-1 + # CDK_DEFAULT_REGION: eu-west-1 - name: Destroy run: npm run destroy working-directory: test/cdk-esm @@ -200,7 +198,6 @@ jobs: working-directory: test/cdk-esm env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - CDK_DEFAULT_REGION: ${{ inputs.useLocalStack && 'eu-west-1' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-esm.test.ts env: From 6d78b538407e2f3247b7bb5562b5d14f39046bb1 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 07:25:27 +0100 Subject: [PATCH 05/19] fix: Update AWS region from us-east-1 to eu-west-1 in CI workflow --- .github/workflows/common-test.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 6a52006c..b7c87c62 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -88,7 +88,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack @@ -179,7 +179,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack @@ -262,7 +262,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -338,7 +338,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -414,7 +414,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -490,7 +490,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -566,7 +566,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -642,7 +642,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -721,7 +721,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -800,7 +800,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy @@ -875,7 +875,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Setup Terraform @@ -957,7 +957,7 @@ jobs: run: | aws configure set aws_access_key_id test aws configure set aws_secret_access_key test - aws configure set region us-east-1 + aws configure set region eu-west-1 env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Setup OpenTofu From d532c7de54bb14cf51c39a9f24f774bc3c225fe9 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 08:21:37 +0100 Subject: [PATCH 06/19] fix: Add environment parameter to CDK bootstrap command for LocalStack --- .github/workflows/common-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index b7c87c62..290b1957 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -93,7 +93,7 @@ jobs: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdk bootstrap aws://000000000000/eu-west-1 + run: npx cdk bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: http://localhost:4566 @@ -184,7 +184,7 @@ jobs: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdk bootstrap aws://000000000000/eu-west-1 + run: npx cdk bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-esm env: AWS_ENDPOINT_URL: http://localhost:4566 From 0cb808c8d583d6d2d48e71e4dfe03eeb588e08ca Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 08:53:03 +0100 Subject: [PATCH 07/19] fix: Install cdklocal for LocalStack and update CDK bootstrap commands --- .github/workflows/common-test.yml | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 290b1957..5481d98a 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -76,6 +76,9 @@ jobs: run: | npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test + - name: Install cdklocal for LocalStack + if: ${{ inputs.useLocalStack }} + run: npm i -g cdklocal - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 @@ -93,12 +96,12 @@ jobs: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdk bootstrap aws://000000000000/eu-west-1 -c environment=test + run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-basic env: AWS_ENDPOINT_URL: http://localhost:4566 - # CDK_DEFAULT_REGION: eu-west-1 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/cdk-basic continue-on-error: true @@ -167,6 +170,9 @@ jobs: run: | npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test + - name: Install cdklocal for LocalStack + if: ${{ inputs.useLocalStack }} + run: npm i -g cdklocal - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 @@ -184,12 +190,12 @@ jobs: AWS_ENDPOINT_URL: http://localhost:4566 - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdk bootstrap aws://000000000000/eu-west-1 -c environment=test + run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-esm env: AWS_ENDPOINT_URL: http://localhost:4566 - # CDK_DEFAULT_REGION: eu-west-1 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/cdk-esm continue-on-error: true @@ -266,6 +272,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/sls-basic continue-on-error: true @@ -274,6 +281,7 @@ jobs: working-directory: test/sls-basic env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-basic.test.ts env: @@ -342,6 +350,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/sls-esbuild-cjs continue-on-error: true @@ -350,6 +359,7 @@ jobs: working-directory: test/sls-esbuild-cjs env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-cjs.test.ts env: @@ -418,6 +428,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/sls-esbuild-esm continue-on-error: true @@ -426,6 +437,7 @@ jobs: working-directory: test/sls-esbuild-esm env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-esm.test.ts env: @@ -494,6 +506,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/osls-basic continue-on-error: true @@ -502,6 +515,7 @@ jobs: working-directory: test/osls-basic env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-basic.test.ts env: @@ -570,6 +584,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/osls-esbuild-cjs continue-on-error: true @@ -578,6 +593,7 @@ jobs: working-directory: test/osls-esbuild-cjs env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-cjs.test.ts env: @@ -646,6 +662,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/osls-esbuild-esm continue-on-error: true @@ -654,6 +671,7 @@ jobs: working-directory: test/osls-esbuild-esm env: AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-esm.test.ts env: @@ -725,6 +743,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/sam-basic continue-on-error: true @@ -804,6 +823,7 @@ jobs: env: AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/sam-alt continue-on-error: true @@ -886,6 +906,7 @@ jobs: terraform init -backend-config="bucket=lld-terraform-basic" working-directory: test/terraform-basic - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/terraform-basic continue-on-error: true @@ -968,6 +989,7 @@ jobs: tofu init -backend-config="bucket=lld-opentofu-basic" working-directory: test/opentofu-basic - name: Destroy + if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/opentofu-basic continue-on-error: true From bef4844d7409af90f131beff35c771bea4c90e10 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 09:03:06 +0100 Subject: [PATCH 08/19] fix: Update installation command for cdklocal to aws-cdk-local in CI workflow --- .github/workflows/common-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 5481d98a..90857717 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -78,7 +78,7 @@ jobs: working-directory: test - name: Install cdklocal for LocalStack if: ${{ inputs.useLocalStack }} - run: npm i -g cdklocal + run: npm i -g aws-cdk-local - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 @@ -172,7 +172,7 @@ jobs: working-directory: test - name: Install cdklocal for LocalStack if: ${{ inputs.useLocalStack }} - run: npm i -g cdklocal + run: npm i -g aws-cdk-local - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 From b3c2fb1c38878e4edd16bfb70f2d4296c937cbeb Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 09:13:07 +0100 Subject: [PATCH 09/19] fix: Refactor LocalStack AWS credentials configuration to use environment variables --- .github/workflows/common-test.yml | 230 +++++++++++------------------- 1 file changed, 84 insertions(+), 146 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 90857717..e2033312 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -89,17 +89,17 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-basic - env: - AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -108,25 +108,15 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/cdk-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/cdk-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Deploy YAML version run: npm run deploy-yaml working-directory: test/cdk-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test YAML run: npx vitest --retry 2 test/cdk-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-cdk-esm: runs-on: ubuntu-latest @@ -183,17 +173,17 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-esm - env: - AWS_ENDPOINT_URL: http://localhost:4566 - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -202,16 +192,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/cdk-esm - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/cdk-esm.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/cdk-esm.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sls-basic: runs-on: ubuntu-latest @@ -266,11 +250,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -279,17 +265,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sls-esbuild-cjs: runs-on: ubuntu-latest @@ -344,11 +323,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -357,17 +338,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-esbuild-cjs - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-cjs.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-cjs.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sls-esbuild-esm: runs-on: ubuntu-latest @@ -422,11 +396,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -435,17 +411,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-esbuild-esm - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-esm.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-esm.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-osls-basic: runs-on: ubuntu-latest @@ -500,11 +469,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -513,17 +484,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-osls-esbuild-cjs: runs-on: ubuntu-latest @@ -578,11 +542,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -591,17 +557,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-esbuild-cjs - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-cjs.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-cjs.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-osls-esbuild-esm: runs-on: ubuntu-latest @@ -656,11 +615,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -669,17 +630,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-esbuild-esm - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-esm.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-esm.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sam-basic: runs-on: ubuntu-latest @@ -737,11 +691,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -750,16 +706,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sam-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sam-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-sam-alt: runs-on: ubuntu-latest @@ -817,11 +767,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy @@ -830,16 +782,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sam-alt - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/sam-alt.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-alt.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-terraform-basic: runs-on: ubuntu-latest @@ -893,11 +839,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Setup Terraform uses: hashicorp/setup-terraform@v3 - name: Terraform Init @@ -913,16 +861,10 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/terraform-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/terraform-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/terraform-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} test-opentofu-basic: runs-on: ubuntu-latest @@ -976,11 +918,13 @@ jobs: - name: Configure LocalStack AWS Credentials if: ${{ inputs.useLocalStack }} run: | - aws configure set aws_access_key_id test - aws configure set aws_secret_access_key test - aws configure set region eu-west-1 - env: - AWS_ENDPOINT_URL: http://localhost:4566 + { + echo "AWS_ACCESS_KEY_ID=test" + echo "AWS_SECRET_ACCESS_KEY=test" + echo "AWS_REGION=eu-west-1" + echo "AWS_DEFAULT_REGION=eu-west-1" + echo "AWS_ENDPOINT_URL=http://localhost:4566" + } >> "$GITHUB_ENV" - name: Setup OpenTofu uses: opentofu/setup-opentofu@v1 - name: OpenTofu Init @@ -996,13 +940,7 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/opentofu-basic - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test run: npx vitest --retry 2 test/opentofu-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/opentofu-basic.test.ts - env: - AWS_ENDPOINT_URL: ${{ inputs.useLocalStack && 'http://localhost:4566' || '' }} From 0be6a4d822cca08524c3d9e52e1476b579eef638 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 19:26:05 +0100 Subject: [PATCH 10/19] fix: Install aws-cdk alongside aws-cdk-local for LocalStack --- .github/workflows/common-test.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index e2033312..3fc0c825 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -78,7 +78,7 @@ jobs: working-directory: test - name: Install cdklocal for LocalStack if: ${{ inputs.useLocalStack }} - run: npm i -g aws-cdk-local + run: npm i -g aws-cdk-local aws-cdk - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 @@ -162,7 +162,7 @@ jobs: working-directory: test - name: Install cdklocal for LocalStack if: ${{ inputs.useLocalStack }} - run: npm i -g aws-cdk-local + run: npm i -g aws-cdk-local aws-cdk - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 From 8b4bf748b4c41553c9827e391612e65a13aa9ce7 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 19:35:25 +0100 Subject: [PATCH 11/19] fix: Enhance LocalStack region detection and logging in IoT service connection --- src/extension/interceptor.ts | 8 ++++++++ src/ioTService.ts | 9 +-------- src/lambdaConnection.ts | 9 +++++++++ 3 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/extension/interceptor.ts b/src/extension/interceptor.ts index b9b0659e..a70fec9d 100755 --- a/src/extension/interceptor.ts +++ b/src/extension/interceptor.ts @@ -48,6 +48,13 @@ async function regularMode(context: any, event: any) { }); }, 5 * 1000); + let region: string | undefined; + if (process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') { + // it is localstack + region = process.env.AWS_REGION; + Logger.verbose(`Region is set to ${region} due to LocalStack detection`); + } + const ioTService = await IoTService.connect({ onMessage: async (message: IoTMessage) => { if (Logger.isVerbose()) { @@ -83,6 +90,7 @@ async function regularMode(context: any, event: any) { } }, topic, + region, }); const payload: IoTMessage = { diff --git a/src/ioTService.ts b/src/ioTService.ts index 2268f901..74995cbd 100755 --- a/src/ioTService.ts +++ b/src/ioTService.ts @@ -122,19 +122,12 @@ async function connect(props?: { credentials, }); - let region = props?.region; - - if (!region && process.env.NODE_TLS_REJECT_UNAUTHORIZED === '0') { - // it is localstack - region = process.env.AWS_REGION ?? 'us-east-1'; - } - device = new iot.device({ protocol: 'wss', host: endpoint, reconnectPeriod: 1, keepalive: 60, - region, + region: props?.region, accessKeyId: credentials?.accessKeyId, secretKey: credentials?.secretAccessKey, sessionToken: credentials?.sessionToken, diff --git a/src/lambdaConnection.ts b/src/lambdaConnection.ts index 26e4f357..0e6751e9 100644 --- a/src/lambdaConnection.ts +++ b/src/lambdaConnection.ts @@ -13,6 +13,15 @@ const lambdasProcessingObservableMode = new Set(); */ async function connect() { topic = `${Configuration.config.debuggerId}/events`; + + let region = Configuration.config.region; + if (!region && Configuration.config.localStack) { + region = process.env.AWS_REGION || 'us-east-1'; + Logger.verbose( + `Empty region detected with LocalStack, defaulting to ${region}`, + ); + } + ioTServiceConnection = await IoTService.connect({ onMessage: onMessageFromLambda, topic, From c182bbc700ac67484420bcd600c7072194ac5619 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 19:56:50 +0100 Subject: [PATCH 12/19] fix: Set AWS_SDK_LOAD_CONFIG environment variable for LocalStack in test jobs --- .github/workflows/common-test.yml | 36 +++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 3fc0c825..f4ff582e 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -265,10 +265,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-basic + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-basic.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-basic.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-sls-esbuild-cjs: runs-on: ubuntu-latest @@ -338,10 +344,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-esbuild-cjs + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-cjs.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-cjs.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-sls-esbuild-esm: runs-on: ubuntu-latest @@ -411,10 +423,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/sls-esbuild-esm + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/sls-esbuild-esm.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-esm.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-osls-basic: runs-on: ubuntu-latest @@ -484,10 +502,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-basic + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-basic.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-basic.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-osls-esbuild-cjs: runs-on: ubuntu-latest @@ -557,10 +581,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-esbuild-cjs + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-osls-esbuild-esm: runs-on: ubuntu-latest @@ -630,10 +660,16 @@ jobs: - name: Deploy run: npm run deploy working-directory: test/osls-esbuild-esm + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test run: npx vitest --retry 2 test/osls-esbuild-esm.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-esm.test.ts + env: + AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-sam-basic: runs-on: ubuntu-latest From 06a1d43530c5539c53be6523cae03069bb31af0c Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 20:00:04 +0100 Subject: [PATCH 13/19] fix: Add AWS_ENDPOINT_URL_S3 environment variable for LocalStack in CI jobs --- .github/workflows/common-test.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index f4ff582e..7ef0a192 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -95,6 +95,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} @@ -179,6 +180,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} @@ -256,6 +258,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -335,6 +338,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -414,6 +418,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -493,6 +498,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -572,6 +578,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -651,6 +658,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -733,6 +741,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -809,6 +818,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -881,6 +891,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Setup Terraform uses: hashicorp/setup-terraform@v3 @@ -960,6 +971,7 @@ jobs: echo "AWS_REGION=eu-west-1" echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" + echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" } >> "$GITHUB_ENV" - name: Setup OpenTofu uses: opentofu/setup-opentofu@v1 From fd376137b71c1fb9f5077b2443790b647f905b63 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 20:10:55 +0100 Subject: [PATCH 14/19] fix: Update deployment command to use npx serverless with specified region --- .github/workflows/common-test.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 7ef0a192..07bad5fe 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -266,7 +266,7 @@ jobs: working-directory: test/sls-basic continue-on-error: true - name: Deploy - run: npm run deploy + run: npx serverless deploy --region eu-west-1 working-directory: test/sls-basic env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} @@ -346,7 +346,7 @@ jobs: working-directory: test/sls-esbuild-cjs continue-on-error: true - name: Deploy - run: npm run deploy + run: npx serverless deploy --region eu-west-1 working-directory: test/sls-esbuild-cjs env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} @@ -426,7 +426,7 @@ jobs: working-directory: test/sls-esbuild-esm continue-on-error: true - name: Deploy - run: npm run deploy + run: npx serverless deploy --region eu-west-1 working-directory: test/sls-esbuild-esm env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} @@ -506,7 +506,7 @@ jobs: working-directory: test/osls-basic continue-on-error: true - name: Deploy - run: npm run deploy + run: npx serverless deploy --region eu-west-1 working-directory: test/osls-basic env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} @@ -586,7 +586,7 @@ jobs: working-directory: test/osls-esbuild-cjs continue-on-error: true - name: Deploy - run: npm run deploy + run: npx serverless deploy --region eu-west-1 working-directory: test/osls-esbuild-cjs env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} @@ -666,7 +666,7 @@ jobs: working-directory: test/osls-esbuild-esm continue-on-error: true - name: Deploy - run: npm run deploy + run: npx serverless deploy --region eu-west-1 working-directory: test/osls-esbuild-esm env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} From 7258a44a940b95ef99b9d5e98b63bc88d5358f0f Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 20:31:08 +0100 Subject: [PATCH 15/19] fix: Update concurrency group names to include useLocalStack variable --- .github/workflows/common-test.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 07bad5fe..347807e5 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -37,7 +37,7 @@ jobs: test-cdk-basic: runs-on: ubuntu-latest concurrency: - group: test-cdk-basic + group: test-cdk-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -122,7 +122,7 @@ jobs: test-cdk-esm: runs-on: ubuntu-latest concurrency: - group: test-cdk-esm + group: test-cdk-esm-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -202,7 +202,7 @@ jobs: test-sls-basic: runs-on: ubuntu-latest concurrency: - group: test-sls-basic + group: test-sls-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -282,7 +282,7 @@ jobs: test-sls-esbuild-cjs: runs-on: ubuntu-latest concurrency: - group: test-sls-esbuild-cjs + group: test-sls-esbuild-cjs-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -362,7 +362,7 @@ jobs: test-sls-esbuild-esm: runs-on: ubuntu-latest concurrency: - group: test-sls-esbuild-esm + group: test-sls-esbuild-esm-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -442,7 +442,7 @@ jobs: test-osls-basic: runs-on: ubuntu-latest concurrency: - group: test-osls-basic + group: test-osls-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -522,7 +522,7 @@ jobs: test-osls-esbuild-cjs: runs-on: ubuntu-latest concurrency: - group: test-osls-esbuild-cjs + group: test-osls-esbuild-cjs-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -602,7 +602,7 @@ jobs: test-osls-esbuild-esm: runs-on: ubuntu-latest concurrency: - group: test-osls-esbuild-esm + group: test-osls-esbuild-esm-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -682,7 +682,7 @@ jobs: test-sam-basic: runs-on: ubuntu-latest concurrency: - group: test-sam-basic + group: test-sam-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -759,7 +759,7 @@ jobs: test-sam-alt: runs-on: ubuntu-latest concurrency: - group: test-sam-alt + group: test-sam-alt-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -836,7 +836,7 @@ jobs: test-terraform-basic: runs-on: ubuntu-latest concurrency: - group: test-terraform-basic + group: test-terraform-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -892,6 +892,7 @@ jobs: echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + echo "AWS_S3_FORCE_PATH_STYLE=1" } >> "$GITHUB_ENV" - name: Setup Terraform uses: hashicorp/setup-terraform@v3 @@ -916,7 +917,7 @@ jobs: test-opentofu-basic: runs-on: ubuntu-latest concurrency: - group: test-opentofu-basic + group: test-opentofu-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -972,6 +973,7 @@ jobs: echo "AWS_DEFAULT_REGION=eu-west-1" echo "AWS_ENDPOINT_URL=http://localhost:4566" echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + echo "AWS_S3_FORCE_PATH_STYLE=1" } >> "$GITHUB_ENV" - name: Setup OpenTofu uses: opentofu/setup-opentofu@v1 From 3968c3faffbd922cd20fd5f20f54da7eaf678c19 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Tue, 4 Nov 2025 20:33:15 +0100 Subject: [PATCH 16/19] fix: Set CDK_DEFAULT_REGION environment variable for LocalStack bootstrap step --- .github/workflows/common-test.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 347807e5..dd5850e8 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -101,6 +101,8 @@ jobs: if: ${{ inputs.useLocalStack }} run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test working-directory: test/cdk-basic + env: + CDK_DEFAULT_REGION: eu-west-1 - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy From de0736b94a8f640e6017b3f5269221818fd25763 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Wed, 5 Nov 2025 07:40:46 +0100 Subject: [PATCH 17/19] feat: Enhance LocalStack support in CI workflows and configurations --- .github/workflows/common-test.yml | 31 +++++++++++++++++-- .github/workflows/pull-request.yml | 16 +++++----- package-lock.json | 22 ++++++++++++- test/cdk-basic/bin/cdk-basic.ts | 8 ++--- .../lib/subfolder/cdk-basic-stack2.ts | 14 ++++----- test/sls-basic/package.json | 3 +- test/sls-basic/serverless.yml | 3 ++ 7 files changed, 73 insertions(+), 24 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index dd5850e8..80003fdc 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -109,7 +109,12 @@ jobs: working-directory: test/cdk-basic continue-on-error: true - name: Deploy - run: npm run deploy + if: ${{ !inputs.useLocalStack }} + run: cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json + working-directory: test/cdk-basic + - name: Deploy (LocalStack) + if: ${{ inputs.useLocalStack }} + run: cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json working-directory: test/cdk-basic - name: Test run: npx vitest --retry 2 test/cdk-basic.test.ts @@ -194,7 +199,12 @@ jobs: working-directory: test/cdk-esm continue-on-error: true - name: Deploy - run: npm run deploy + if: ${{ !inputs.useLocalStack }} + run: cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json + working-directory: test/cdk-esm + - name: Deploy (LocalStack) + if: ${{ inputs.useLocalStack }} + run: cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json working-directory: test/cdk-esm - name: Test run: npx vitest --retry 2 test/cdk-esm.test.ts @@ -877,6 +887,9 @@ jobs: run: | npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test + - name: Install terraform-local for LocalStack + if: ${{ inputs.useLocalStack }} + run: pip install terraform-local - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 @@ -899,17 +912,29 @@ jobs: - name: Setup Terraform uses: hashicorp/setup-terraform@v3 - name: Terraform Init + if: ${{ !inputs.useLocalStack }} run: | ./create_bucket.sh lld-terraform-basic terraform init -backend-config="bucket=lld-terraform-basic" working-directory: test/terraform-basic + - name: Terraform Init (LocalStack) + if: ${{ inputs.useLocalStack }} + run: | + ./create_bucket.sh lld-terraform-basic + tflocal init -backend-config="bucket=lld-terraform-basic" + working-directory: test/terraform-basic - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy working-directory: test/terraform-basic continue-on-error: true - name: Deploy - run: npm run deploy + if: ${{ !inputs.useLocalStack }} + run: npm run build && terraform apply -auto-approve && terraform output -json > terraform-outputs.json + working-directory: test/terraform-basic + - name: Deploy (LocalStack) + if: ${{ inputs.useLocalStack }} + run: npm run build && tflocal apply -auto-approve && tflocal output -json > terraform-outputs.json working-directory: test/terraform-basic - name: Test run: npx vitest --retry 2 test/terraform-basic.test.ts diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index dc94aa46..6d852065 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -46,14 +46,14 @@ jobs: # Picking random test so I can have environment working-directory: test/sam-basic - test: - uses: ./.github/workflows/common-test.yml - secrets: inherit - needs: remove-old-layers - with: - mode: build - testMonorepo: false - useLocalStack: false + # test: + # uses: ./.github/workflows/common-test.yml + # secrets: inherit + # needs: remove-old-layers + # with: + # mode: build + # testMonorepo: false + # useLocalStack: false test-localstack: uses: ./.github/workflows/common-test.yml diff --git a/package-lock.json b/package-lock.json index f42e9799..b13a8868 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31538,6 +31538,13 @@ "es6-symbol": "^3.1.1" } }, + "node_modules/es6-promisify": { + "version": "6.1.1", + "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-6.1.1.tgz", + "integrity": "sha512-HBL8I3mIki5C1Cc9QjKUenHtnG0A5/xA8Q/AllRcfiwl2CZFXGK7ddBiCoRwAix4i2KxcQfjtIVcrVbB3vbmwg==", + "dev": true, + "license": "MIT" + }, "node_modules/es6-set": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/es6-set/-/es6-set-0.1.6.tgz", @@ -40028,6 +40035,18 @@ "node": ">=6" } }, + "node_modules/serverless-localstack": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/serverless-localstack/-/serverless-localstack-1.3.1.tgz", + "integrity": "sha512-dBwKCo6mhJuQuIWnYAacfbyZhBnl0N8UgXLkZ3NpOFvEa2PAnwBzoRL5xpZGoPze+aPPOKrMhiSmSGspalJgEQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "adm-zip": "^0.5.10", + "aws-sdk": "^2.402.0", + "es6-promisify": "^6.0.1" + } + }, "node_modules/serverless/node_modules/agent-base": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", @@ -44278,7 +44297,8 @@ "@aws-sdk/client-sts": "^3.920.0" }, "devDependencies": { - "serverless": "^3.38.0" + "serverless": "^3.38.0", + "serverless-localstack": "^1.3.1" } }, "test/sls-esbuild-cjs": { diff --git a/test/cdk-basic/bin/cdk-basic.ts b/test/cdk-basic/bin/cdk-basic.ts index 2547fdd9..0f8b7e6e 100644 --- a/test/cdk-basic/bin/cdk-basic.ts +++ b/test/cdk-basic/bin/cdk-basic.ts @@ -4,10 +4,10 @@ import * as cdk from 'aws-cdk-lib'; import { CdkbasicStack } from '../lib/cdk-basic-stack'; import { CdkbasicStack2 } from '../lib/subfolder/cdk-basic-stack2'; -if (process.env.CDK_DEFAULT_REGION !== 'eu-west-1') { - // checking if the region is set with Lambda Live Debugger - throw new Error('CDK_DEFAULT_REGION must be set to eu-west-1'); -} +// if (process.env.CDK_DEFAULT_REGION !== 'eu-west-1') { +// // checking if the region is set with Lambda Live Debugger +// throw new Error('CDK_DEFAULT_REGION must be set to eu-west-1'); +// } const app = new cdk.App(); diff --git a/test/cdk-basic/lib/subfolder/cdk-basic-stack2.ts b/test/cdk-basic/lib/subfolder/cdk-basic-stack2.ts index b7316cbb..99d37047 100644 --- a/test/cdk-basic/lib/subfolder/cdk-basic-stack2.ts +++ b/test/cdk-basic/lib/subfolder/cdk-basic-stack2.ts @@ -3,7 +3,7 @@ import { Construct } from 'constructs'; import * as lambda_nodejs from 'aws-cdk-lib/aws-lambda-nodejs'; import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as log from 'aws-cdk-lib/aws-logs'; -import * as ec2 from 'aws-cdk-lib/aws-ec2'; +//import * as ec2 from 'aws-cdk-lib/aws-ec2'; import * as path from 'path'; export class CdkbasicStack2 extends cdk.Stack { @@ -11,12 +11,12 @@ export class CdkbasicStack2 extends cdk.Stack { super(scope, id, props); // to test internal CDK internal handler restrict-default-security-group-handler/index.js - new ec2.Vpc(this, 'vpc', { - ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/24'), - ipProtocol: ec2.IpProtocol.DUAL_STACK, - restrictDefaultSecurityGroup: true, - natGateways: 0, - }); + // new ec2.Vpc(this, 'vpc', { + // ipAddresses: ec2.IpAddresses.cidr('10.0.0.0/24'), + // ipProtocol: ec2.IpProtocol.DUAL_STACK, + // restrictDefaultSecurityGroup: true, + // natGateways: 0, + // }); //testJsEsModule const functionTestJsEsModule = new lambda_nodejs.NodejsFunction( diff --git a/test/sls-basic/package.json b/test/sls-basic/package.json index f24f6b09..97a245c5 100644 --- a/test/sls-basic/package.json +++ b/test/sls-basic/package.json @@ -11,7 +11,8 @@ "author": "", "license": "ISC", "devDependencies": { - "serverless": "^3.38.0" + "serverless": "^3.38.0", + "serverless-localstack": "^1.3.1" }, "dependencies": { "@aws-sdk/client-sts": "^3.920.0" diff --git a/test/sls-basic/serverless.yml b/test/sls-basic/serverless.yml index 4484f690..fec3a7fd 100644 --- a/test/sls-basic/serverless.yml +++ b/test/sls-basic/serverless.yml @@ -6,6 +6,9 @@ provider: runtime: nodejs20.x region: eu-west-1 +plugins: + - serverless-localstack + functions: - ${file(./functions1.yml)} - ${file(./functions2.yml)} From 7e12e915613d46d6f79c22cb60a2452fd3b992fd Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Wed, 5 Nov 2025 07:59:23 +0100 Subject: [PATCH 18/19] Disable remove-old-layers job in pull-request workflow and update dependencies for test-localstack job --- .github/workflows/common-test.yml | 1314 ++++++++++++++-------------- .github/workflows/pull-request.yml | 62 +- 2 files changed, 692 insertions(+), 684 deletions(-) diff --git a/.github/workflows/common-test.yml b/.github/workflows/common-test.yml index 80003fdc..a85c66bc 100644 --- a/.github/workflows/common-test.yml +++ b/.github/workflows/common-test.yml @@ -99,7 +99,7 @@ jobs: } >> "$GITHUB_ENV" - name: Bootstrap CDK for LocalStack if: ${{ inputs.useLocalStack }} - run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test + run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test --region eu-west-1 working-directory: test/cdk-basic env: CDK_DEFAULT_REGION: eu-west-1 @@ -110,11 +110,11 @@ jobs: continue-on-error: true - name: Deploy if: ${{ !inputs.useLocalStack }} - run: cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json + run: cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json --region eu-west-1 working-directory: test/cdk-basic - name: Deploy (LocalStack) if: ${{ inputs.useLocalStack }} - run: cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json + run: cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json --region eu-west-1 working-directory: test/cdk-basic - name: Test run: npx vitest --retry 2 test/cdk-basic.test.ts @@ -126,415 +126,95 @@ jobs: - name: Test YAML run: npx vitest --retry 2 test/cdk-basic.test.ts - test-cdk-esm: - runs-on: ubuntu-latest - concurrency: - group: test-cdk-esm-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js cdk-esm - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Install cdklocal for LocalStack - if: ${{ inputs.useLocalStack }} - run: npm i -g aws-cdk-local aws-cdk - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Bootstrap CDK for LocalStack - if: ${{ inputs.useLocalStack }} - run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test - working-directory: test/cdk-esm - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/cdk-esm - continue-on-error: true - - name: Deploy - if: ${{ !inputs.useLocalStack }} - run: cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json - working-directory: test/cdk-esm - - name: Deploy (LocalStack) - if: ${{ inputs.useLocalStack }} - run: cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json - working-directory: test/cdk-esm - - name: Test - run: npx vitest --retry 2 test/cdk-esm.test.ts - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/cdk-esm.test.ts - - test-sls-basic: - runs-on: ubuntu-latest - concurrency: - group: test-sls-basic-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js sls-basic - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - npm i serverless@3.38.0 -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/sls-basic - continue-on-error: true - - name: Deploy - run: npx serverless deploy --region eu-west-1 - working-directory: test/sls-basic - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - run: npx vitest --retry 2 test/sls-basic.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-basic.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - test-sls-esbuild-cjs: - runs-on: ubuntu-latest - concurrency: - group: test-sls-esbuild-cjs-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js sls-esbuild-cjs - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - npm i serverless@3.38.0 -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/sls-esbuild-cjs - continue-on-error: true - - name: Deploy - run: npx serverless deploy --region eu-west-1 - working-directory: test/sls-esbuild-cjs - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - run: npx vitest --retry 2 test/sls-esbuild-cjs.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-cjs.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - test-sls-esbuild-esm: - runs-on: ubuntu-latest - concurrency: - group: test-sls-esbuild-esm-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js sls-esbuild-esm - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - npm i serverless@3.38.0 -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/sls-esbuild-esm - continue-on-error: true - - name: Deploy - run: npx serverless deploy --region eu-west-1 - working-directory: test/sls-esbuild-esm - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - run: npx vitest --retry 2 test/sls-esbuild-esm.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-esm.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - test-osls-basic: - runs-on: ubuntu-latest - concurrency: - group: test-osls-basic-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js osls-basic - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - npm i osls -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/osls-basic - continue-on-error: true - - name: Deploy - run: npx serverless deploy --region eu-west-1 - working-directory: test/osls-basic - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - run: npx vitest --retry 2 test/osls-basic.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-basic.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # test-cdk-esm: + # runs-on: ubuntu-latest + # concurrency: + # group: test-cdk-esm-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js cdk-esm + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Install cdklocal for LocalStack + # if: ${{ inputs.useLocalStack }} + # run: npm i -g aws-cdk-local aws-cdk + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Bootstrap CDK for LocalStack + # if: ${{ inputs.useLocalStack }} + # run: npx cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test + # working-directory: test/cdk-esm + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/cdk-esm + # continue-on-error: true + # - name: Deploy + # if: ${{ !inputs.useLocalStack }} + # run: cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json + # working-directory: test/cdk-esm + # - name: Deploy (LocalStack) + # if: ${{ inputs.useLocalStack }} + # run: cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json + # working-directory: test/cdk-esm + # - name: Test + # run: npx vitest --retry 2 test/cdk-esm.test.ts + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/cdk-esm.test.ts - test-osls-esbuild-cjs: + test-sls-basic: runs-on: ubuntu-latest concurrency: - group: test-osls-esbuild-cjs-${{ inputs.useLocalStack }} + group: test-sls-basic-${{ inputs.useLocalStack }} steps: - uses: actions/checkout@v4 - name: Start LocalStack @@ -555,7 +235,7 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: Install dependencies run: | - node prepareForTest.js osls-esbuild-cjs + node prepareForTest.js sls-basic npm i - name: Download build artifact uses: actions/download-artifact@v4 @@ -567,7 +247,7 @@ jobs: if: ${{ inputs.mode == 'global' }} run: | npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - npm i osls -g + npm i serverless@3.38.0 -g working-directory: test - name: Install lambda-live-debugger locally if: ${{ inputs.mode == 'local' }} @@ -595,101 +275,421 @@ jobs: - name: Destroy if: ${{ !inputs.useLocalStack }} run: npm run destroy - working-directory: test/osls-esbuild-cjs + working-directory: test/sls-basic continue-on-error: true - name: Deploy run: npx serverless deploy --region eu-west-1 - working-directory: test/osls-esbuild-cjs + working-directory: test/sls-basic env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - run: npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + run: npx vitest --retry 2 test/sls-basic.test.ts env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-basic.test.ts env: AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - test-osls-esbuild-esm: - runs-on: ubuntu-latest - concurrency: - group: test-osls-esbuild-esm-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js osls-esbuild-esm - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - npm i osls -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/osls-esbuild-esm - continue-on-error: true - - name: Deploy - run: npx serverless deploy --region eu-west-1 - working-directory: test/osls-esbuild-esm - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - run: npx vitest --retry 2 test/osls-esbuild-esm.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-esm.test.ts - env: - AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # test-sls-esbuild-cjs: + # runs-on: ubuntu-latest + # concurrency: + # group: test-sls-esbuild-cjs-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js sls-esbuild-cjs + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # npm i serverless@3.38.0 -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/sls-esbuild-cjs + # continue-on-error: true + # - name: Deploy + # run: npx serverless deploy --region eu-west-1 + # working-directory: test/sls-esbuild-cjs + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test + # run: npx vitest --retry 2 test/sls-esbuild-cjs.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-cjs.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + + # test-sls-esbuild-esm: + # runs-on: ubuntu-latest + # concurrency: + # group: test-sls-esbuild-esm-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js sls-esbuild-esm + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # npm i serverless@3.38.0 -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/sls-esbuild-esm + # continue-on-error: true + # - name: Deploy + # run: npx serverless deploy --region eu-west-1 + # working-directory: test/sls-esbuild-esm + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test + # run: npx vitest --retry 2 test/sls-esbuild-esm.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sls-esbuild-esm.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + + # test-osls-basic: + # runs-on: ubuntu-latest + # concurrency: + # group: test-osls-basic-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js osls-basic + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # npm i osls -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/osls-basic + # continue-on-error: true + # - name: Deploy + # run: npx serverless deploy --region eu-west-1 + # working-directory: test/osls-basic + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test + # run: npx vitest --retry 2 test/osls-basic.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-basic.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + + # test-osls-esbuild-cjs: + # runs-on: ubuntu-latest + # concurrency: + # group: test-osls-esbuild-cjs-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js osls-esbuild-cjs + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # npm i osls -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/osls-esbuild-cjs + # continue-on-error: true + # - name: Deploy + # run: npx serverless deploy --region eu-west-1 + # working-directory: test/osls-esbuild-cjs + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test + # run: npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-cjs.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + + # test-osls-esbuild-esm: + # runs-on: ubuntu-latest + # concurrency: + # group: test-osls-esbuild-esm-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js osls-esbuild-esm + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # npm i osls -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/osls-esbuild-esm + # continue-on-error: true + # - name: Deploy + # run: npx serverless deploy --region eu-west-1 + # working-directory: test/osls-esbuild-esm + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test + # run: npx vitest --retry 2 test/osls-esbuild-esm.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/osls-esbuild-esm.test.ts + # env: + # AWS_SDK_LOAD_CONFIG: ${{ inputs.useLocalStack && '1' || '' }} test-sam-basic: runs-on: ubuntu-latest @@ -737,6 +737,9 @@ jobs: run: | npm i lambda-live-debugger@${{ inputs.version || 'latest' }} working-directory: test + - name: Install samlocal for LocalStack + if: ${{ inputs.useLocalStack }} + run: pip install aws-sam-cli-local - name: Configure AWS Credentials if: ${{ !inputs.useLocalStack }} uses: aws-actions/configure-aws-credentials@v4 @@ -761,89 +764,94 @@ jobs: working-directory: test/sam-basic continue-on-error: true - name: Deploy - run: npm run deploy + if: ${{ !inputs.useLocalStack }} + run: npm run build && sam deploy --config-env test --no-confirm-changeset --region eu-west-1 && npm run export_outputs + working-directory: test/sam-basic + - name: Deploy (LocalStack) + if: ${{ inputs.useLocalStack }} + run: npm run build && samlocal deploy --config-env test --no-confirm-changeset --region eu-west-1 && npm run export_outputs working-directory: test/sam-basic - name: Test run: npx vitest --retry 2 test/sam-basic.test.ts - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-basic.test.ts - test-sam-alt: - runs-on: ubuntu-latest - concurrency: - group: test-sam-alt-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - uses: aws-actions/setup-sam@v2 - with: - use-installer: true - token: ${{ secrets.GITHUB_TOKEN }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js sam-alt - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - } >> "$GITHUB_ENV" - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/sam-alt - continue-on-error: true - - name: Deploy - run: npm run deploy - working-directory: test/sam-alt - - name: Test - run: npx vitest --retry 2 test/sam-alt.test.ts - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-alt.test.ts + # test-sam-alt: + # runs-on: ubuntu-latest + # concurrency: + # group: test-sam-alt-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - uses: aws-actions/setup-sam@v2 + # with: + # use-installer: true + # token: ${{ secrets.GITHUB_TOKEN }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js sam-alt + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # } >> "$GITHUB_ENV" + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/sam-alt + # continue-on-error: true + # - name: Deploy + # run: npm run deploy + # working-directory: test/sam-alt + # - name: Test + # run: npx vitest --retry 2 test/sam-alt.test.ts + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/sam-alt.test.ts test-terraform-basic: runs-on: ubuntu-latest @@ -915,13 +923,13 @@ jobs: if: ${{ !inputs.useLocalStack }} run: | ./create_bucket.sh lld-terraform-basic - terraform init -backend-config="bucket=lld-terraform-basic" + terraform init -backend-config="bucket=lld-terraform-basic" -backend-config="region=eu-west-1" working-directory: test/terraform-basic - name: Terraform Init (LocalStack) if: ${{ inputs.useLocalStack }} run: | ./create_bucket.sh lld-terraform-basic - tflocal init -backend-config="bucket=lld-terraform-basic" + tflocal init -backend-config="bucket=lld-terraform-basic" -backend-config="region=eu-west-1" working-directory: test/terraform-basic - name: Destroy if: ${{ !inputs.useLocalStack }} @@ -941,83 +949,83 @@ jobs: - name: Test - observability mode run: OBSERVABLE_MODE=true npx vitest --retry 2 test/terraform-basic.test.ts - test-opentofu-basic: - runs-on: ubuntu-latest - concurrency: - group: test-opentofu-basic-${{ inputs.useLocalStack }} - steps: - - uses: actions/checkout@v4 - - name: Start LocalStack - if: ${{ inputs.useLocalStack }} - run: | - pip install localstack awscli-local - docker pull localstack/localstack:latest - localstack start -d - echo "Waiting for LocalStack to be ready..." - localstack wait -t 30 - localstack status services - env: - LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: | - node prepareForTest.js opentofu-basic - npm i - - name: Download build artifact - uses: actions/download-artifact@v4 - if: ${{ inputs.mode == 'build' }} - with: - name: dist - path: dist - - name: Install lambda-live-debugger globally - if: ${{ inputs.mode == 'global' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g - working-directory: test - - name: Install lambda-live-debugger locally - if: ${{ inputs.mode == 'local' }} - run: | - npm i lambda-live-debugger@${{ inputs.version || 'latest' }} - working-directory: test - - name: Configure AWS Credentials - if: ${{ !inputs.useLocalStack }} - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Configure LocalStack AWS Credentials - if: ${{ inputs.useLocalStack }} - run: | - { - echo "AWS_ACCESS_KEY_ID=test" - echo "AWS_SECRET_ACCESS_KEY=test" - echo "AWS_REGION=eu-west-1" - echo "AWS_DEFAULT_REGION=eu-west-1" - echo "AWS_ENDPOINT_URL=http://localhost:4566" - echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" - echo "AWS_S3_FORCE_PATH_STYLE=1" - } >> "$GITHUB_ENV" - - name: Setup OpenTofu - uses: opentofu/setup-opentofu@v1 - - name: OpenTofu Init - run: | - ./create_bucket.sh lld-opentofu-basic - tofu init -backend-config="bucket=lld-opentofu-basic" - working-directory: test/opentofu-basic - - name: Destroy - if: ${{ !inputs.useLocalStack }} - run: npm run destroy - working-directory: test/opentofu-basic - continue-on-error: true - - name: Deploy - run: npm run deploy - working-directory: test/opentofu-basic - - name: Test - run: npx vitest --retry 2 test/opentofu-basic.test.ts - - name: Test - observability mode - run: OBSERVABLE_MODE=true npx vitest --retry 2 test/opentofu-basic.test.ts + # test-opentofu-basic: + # runs-on: ubuntu-latest + # concurrency: + # group: test-opentofu-basic-${{ inputs.useLocalStack }} + # steps: + # - uses: actions/checkout@v4 + # - name: Start LocalStack + # if: ${{ inputs.useLocalStack }} + # run: | + # pip install localstack awscli-local + # docker pull localstack/localstack:latest + # localstack start -d + # echo "Waiting for LocalStack to be ready..." + # localstack wait -t 30 + # localstack status services + # env: + # LOCALSTACK_API_KEY: ${{ secrets.LOCALSTACK_API_KEY }} + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: | + # node prepareForTest.js opentofu-basic + # npm i + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # if: ${{ inputs.mode == 'build' }} + # with: + # name: dist + # path: dist + # - name: Install lambda-live-debugger globally + # if: ${{ inputs.mode == 'global' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} -g + # working-directory: test + # - name: Install lambda-live-debugger locally + # if: ${{ inputs.mode == 'local' }} + # run: | + # npm i lambda-live-debugger@${{ inputs.version || 'latest' }} + # working-directory: test + # - name: Configure AWS Credentials + # if: ${{ !inputs.useLocalStack }} + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Configure LocalStack AWS Credentials + # if: ${{ inputs.useLocalStack }} + # run: | + # { + # echo "AWS_ACCESS_KEY_ID=test" + # echo "AWS_SECRET_ACCESS_KEY=test" + # echo "AWS_REGION=eu-west-1" + # echo "AWS_DEFAULT_REGION=eu-west-1" + # echo "AWS_ENDPOINT_URL=http://localhost:4566" + # echo "AWS_ENDPOINT_URL_S3=http://localhost:4566" + # echo "AWS_S3_FORCE_PATH_STYLE=1" + # } >> "$GITHUB_ENV" + # - name: Setup OpenTofu + # uses: opentofu/setup-opentofu@v1 + # - name: OpenTofu Init + # run: | + # ./create_bucket.sh lld-opentofu-basic + # tofu init -backend-config="bucket=lld-opentofu-basic" + # working-directory: test/opentofu-basic + # - name: Destroy + # if: ${{ !inputs.useLocalStack }} + # run: npm run destroy + # working-directory: test/opentofu-basic + # continue-on-error: true + # - name: Deploy + # run: npm run deploy + # working-directory: test/opentofu-basic + # - name: Test + # run: npx vitest --retry 2 test/opentofu-basic.test.ts + # - name: Test - observability mode + # run: OBSERVABLE_MODE=true npx vitest --retry 2 test/opentofu-basic.test.ts diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 6d852065..60ab5dc9 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -15,36 +15,36 @@ jobs: uses: ./.github/workflows/common-build.yml secrets: inherit - remove-old-layers: - runs-on: ubuntu-latest - needs: build - concurrency: - group: remove-all-layers - steps: - - uses: actions/checkout@v4 - - name: Use Node.js - uses: actions/setup-node@v4 - with: - node-version: ${{ env.node_version }} - registry-url: 'https://registry.npmjs.org' - - name: Install dependencies - run: npm ci - - name: Download build artifact - uses: actions/download-artifact@v4 - with: - name: dist - path: dist - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v4 - with: - aws-region: eu-west-1 - role-to-assume: ${{ secrets.AWS_ROLE }} - role-session-name: GitHubActions - - name: Remove old layers - run: | - node ../../dist/lldebugger.mjs -r all --config-env=test -v - # Picking random test so I can have environment - working-directory: test/sam-basic + # remove-old-layers: + # runs-on: ubuntu-latest + # needs: build + # concurrency: + # group: remove-all-layers + # steps: + # - uses: actions/checkout@v4 + # - name: Use Node.js + # uses: actions/setup-node@v4 + # with: + # node-version: ${{ env.node_version }} + # registry-url: 'https://registry.npmjs.org' + # - name: Install dependencies + # run: npm ci + # - name: Download build artifact + # uses: actions/download-artifact@v4 + # with: + # name: dist + # path: dist + # - name: Configure AWS Credentials + # uses: aws-actions/configure-aws-credentials@v4 + # with: + # aws-region: eu-west-1 + # role-to-assume: ${{ secrets.AWS_ROLE }} + # role-session-name: GitHubActions + # - name: Remove old layers + # run: | + # node ../../dist/lldebugger.mjs -r all --config-env=test -v + # # Picking random test so I can have environment + # working-directory: test/sam-basic # test: # uses: ./.github/workflows/common-test.yml @@ -58,7 +58,7 @@ jobs: test-localstack: uses: ./.github/workflows/common-test.yml secrets: inherit - needs: remove-old-layers + needs: build with: mode: build testMonorepo: false From 0b839f8d4f4608e12864936e7c528029ff40e261 Mon Sep 17 00:00:00 2001 From: "Marko (ServerlessLife)" Date: Wed, 5 Nov 2025 09:01:58 +0100 Subject: [PATCH 19/19] feat: Add LocalStack support and specify region for deployments across multiple packages --- test/cdk-basic/package.json | 7 +++++-- test/cdk-esm/package.json | 7 +++++-- test/opentofu-basic/package.json | 7 +++++-- test/osls-basic/package.json | 6 ++++-- test/osls-esbuild-cjs/package.json | 6 ++++-- test/osls-esbuild-esm/package.json | 6 ++++-- test/sam-alt/package.json | 7 +++++-- test/sam-basic/package.json | 7 +++++-- test/sls-basic/package.json | 6 ++++-- test/sls-esbuild-cjs/package.json | 6 ++++-- test/sls-esbuild-esm/package.json | 6 ++++-- test/terraform-basic/package.json | 7 +++++-- test/utils/startDebugger.ts | 2 ++ 13 files changed, 56 insertions(+), 24 deletions(-) diff --git a/test/cdk-basic/package.json b/test/cdk-basic/package.json index a62fce03..bd36c218 100644 --- a/test/cdk-basic/package.json +++ b/test/cdk-basic/package.json @@ -5,7 +5,10 @@ "cdk-basic": "bin/cdk-basic.js" }, "scripts": { - "deploy": "cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json", + "deploy": "cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json --region eu-west-1", + "deploy:localstack": "cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json --region eu-west-1", + "bootstrap:localstack": "cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test --region eu-west-1", + "install:localstack": "npm i -g aws-cdk-local aws-cdk", "build": "cdk synth -c environment=test", "deploy-yaml": "bash deploy-yaml.sh", "destroy": "cdk destroy --all -c environment=test --force" @@ -24,4 +27,4 @@ "source-map-support": "^0.5.21", "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/cdk-esm/package.json b/test/cdk-esm/package.json index a16fb951..fe7a071e 100644 --- a/test/cdk-esm/package.json +++ b/test/cdk-esm/package.json @@ -6,7 +6,10 @@ "cdk-esm": "bin/cdk-esm.js" }, "scripts": { - "deploy": "cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json", + "deploy": "cdk deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json --region eu-west-1", + "deploy:localstack": "cdklocal deploy --all -c environment=test --require-approval never --outputs-file cdk-outputs.json --region eu-west-1", + "bootstrap:localstack": "cdklocal bootstrap aws://000000000000/eu-west-1 -c environment=test --region eu-west-1", + "install:localstack": "npm i -g aws-cdk-local aws-cdk", "build": "cdk synth -c environment=test", "destroy": "cdk destroy --all -c environment=test --force" }, @@ -25,4 +28,4 @@ "constructs": "^10.4.2", "source-map-support": "^0.5.21" } -} +} \ No newline at end of file diff --git a/test/opentofu-basic/package.json b/test/opentofu-basic/package.json index 903ff877..37853a2a 100644 --- a/test/opentofu-basic/package.json +++ b/test/opentofu-basic/package.json @@ -4,11 +4,14 @@ "description": "", "main": "index.js", "scripts": { - "init": "./create_bucket.sh lld-openotofu-basic-marko && tofu init -backend-config=\"bucket=lld-openotofu-basic-marko\"", + "init": "./create_bucket.sh lld-openotofu-basic-marko && tofu init -backend-config=\"bucket=lld-openotofu-basic-marko\" -backend-config=\"region=eu-west-1\"", + "init:localstack": "./create_bucket.sh lld-opentofu-basic && tofulocal init -backend-config=\"bucket=lld-opentofu-basic\" -backend-config=\"region=eu-west-1\"", + "install:localstack": "pip install terraform-local", "build_test-ts-esmodule": "cd services/testTsEsModule && npx tsc && cp package.json ./dist && cd ../..", "build_test-ts-commonjs": "cd services/testTsCommonJs && npx tsc && cp package.json ./dist && cd ../..", "build": "npm run build_test-ts-esmodule && npm run build_test-ts-commonjs", "deploy": "npm run build && tofu apply -auto-approve && tofu output -json > opentofu-outputs.json", + "deploy:localstack": "npm run build && tofulocal apply -auto-approve && tofulocal output -json > opentofu-outputs.json", "destroy": "npm run build && tofu destroy -auto-approve" }, "keywords": [], @@ -20,4 +23,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/osls-basic/package.json b/test/osls-basic/package.json index da5efbf5..f1ec2b28 100644 --- a/test/osls-basic/package.json +++ b/test/osls-basic/package.json @@ -4,7 +4,9 @@ "description": "", "main": "index.js", "scripts": { - "deploy": "serverless deploy --stage=test", + "deploy": "serverless deploy --stage=test --region eu-west-1", + "deploy:localstack": "serverless deploy --stage=test --region eu-west-1", + "install:localstack": "npm install --save-dev serverless-localstack", "destroy": "serverless remove --stage=test" }, "keywords": [], @@ -16,4 +18,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/osls-esbuild-cjs/package.json b/test/osls-esbuild-cjs/package.json index b3ddf224..1c6052b2 100644 --- a/test/osls-esbuild-cjs/package.json +++ b/test/osls-esbuild-cjs/package.json @@ -5,7 +5,9 @@ "type": "module", "main": "index.js", "scripts": { - "deploy": "serverless deploy", + "deploy": "serverless deploy --region eu-west-1", + "deploy:localstack": "serverless deploy --region eu-west-1", + "install:localstack": "npm install --save-dev serverless-localstack", "destroy": "serverless remove" }, "keywords": [], @@ -20,4 +22,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/osls-esbuild-esm/package.json b/test/osls-esbuild-esm/package.json index 49b9cee0..0baaa625 100644 --- a/test/osls-esbuild-esm/package.json +++ b/test/osls-esbuild-esm/package.json @@ -5,7 +5,9 @@ "type": "module", "main": "index.js", "scripts": { - "deploy": "serverless deploy", + "deploy": "serverless deploy --region eu-west-1", + "deploy:localstack": "serverless deploy --region eu-west-1", + "install:localstack": "npm install --save-dev serverless-localstack", "destroy": "serverless remove" }, "keywords": [], @@ -21,4 +23,4 @@ "@tsconfig/node22": "^22.0.2", "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/sam-alt/package.json b/test/sam-alt/package.json index f95cc402..de119189 100755 --- a/test/sam-alt/package.json +++ b/test/sam-alt/package.json @@ -4,7 +4,10 @@ "private": true, "scripts": { "build": "sam build --config-env test --config-file alt-samconfig.yaml --template-file alt-template.yaml", - "deploy": "npm run build && sam deploy --config-env test --config-file alt-samconfig.yaml --no-confirm-changeset && npm run export_outputs", + "build:localstack": "samlocal build --config-env test --config-file alt-samconfig.yaml --template-file alt-template.yaml", + "deploy": "npm run build && sam deploy --config-env test --config-file alt-samconfig.yaml --no-confirm-changeset --region eu-west-1 && npm run export_outputs", + "deploy:localstack": "npm run build:localstack && samlocal deploy --config-env test --config-file alt-samconfig.yaml --no-confirm-changeset --region eu-west-1 && npm run export_outputs", + "install:localstack": "pip install aws-sam-cli-local", "export_outputs": "aws cloudformation describe-stacks --stack-name lld-test-sam-alt --output json --query Stacks[0].Outputs > sam-outputs.json", "destroy": "sam delete --config-env test --config-file alt-samconfig.yaml --no-prompts" }, @@ -15,4 +18,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/sam-basic/package.json b/test/sam-basic/package.json index 29e8e00a..ba3fdab0 100755 --- a/test/sam-basic/package.json +++ b/test/sam-basic/package.json @@ -4,7 +4,10 @@ "private": true, "scripts": { "build": "sam build", - "deploy": "npm run build && sam deploy --config-env test --no-confirm-changeset && npm run export_outputs", + "build:localstack": "samlocal build", + "deploy": "npm run build && sam deploy --config-env test --no-confirm-changeset --region eu-west-1 && npm run export_outputs", + "deploy:localstack": "npm run build:localstack && samlocal deploy --config-env test --no-confirm-changeset --region eu-west-1 && npm run export_outputs", + "install:localstack": "pip install aws-sam-cli-local", "export_outputs": "aws cloudformation describe-stacks --stack-name lld-test-sam-basic --output json --query Stacks[0].Outputs > sam-outputs.json", "destroy": "sam delete --config-env test --no-prompts" }, @@ -15,4 +18,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/sls-basic/package.json b/test/sls-basic/package.json index 97a245c5..279d8ae6 100644 --- a/test/sls-basic/package.json +++ b/test/sls-basic/package.json @@ -4,7 +4,9 @@ "description": "", "main": "index.js", "scripts": { - "deploy": "serverless deploy --stage=test", + "deploy": "serverless deploy --stage=test --region eu-west-1", + "deploy:localstack": "serverless deploy --stage=test --region eu-west-1", + "install:localstack": "npm install --save-dev serverless-localstack", "destroy": "serverless remove --stage=test" }, "keywords": [], @@ -17,4 +19,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/sls-esbuild-cjs/package.json b/test/sls-esbuild-cjs/package.json index bf5a17d5..3dcbd9b6 100644 --- a/test/sls-esbuild-cjs/package.json +++ b/test/sls-esbuild-cjs/package.json @@ -5,7 +5,9 @@ "type": "module", "main": "index.js", "scripts": { - "deploy": "serverless deploy", + "deploy": "serverless deploy --region eu-west-1", + "deploy:localstack": "serverless deploy --region eu-west-1", + "install:localstack": "npm install --save-dev serverless-localstack", "destroy": "serverless remove" }, "keywords": [], @@ -20,4 +22,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/sls-esbuild-esm/package.json b/test/sls-esbuild-esm/package.json index dba05e0f..b28bd3ff 100644 --- a/test/sls-esbuild-esm/package.json +++ b/test/sls-esbuild-esm/package.json @@ -5,7 +5,9 @@ "type": "module", "main": "index.js", "scripts": { - "deploy": "serverless deploy", + "deploy": "serverless deploy --region eu-west-1", + "deploy:localstack": "serverless deploy --region eu-west-1", + "install:localstack": "npm install --save-dev serverless-localstack", "destroy": "serverless remove" }, "keywords": [], @@ -21,4 +23,4 @@ "@tsconfig/node22": "^22.0.2", "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/terraform-basic/package.json b/test/terraform-basic/package.json index f8121af3..3a7c3e68 100644 --- a/test/terraform-basic/package.json +++ b/test/terraform-basic/package.json @@ -4,11 +4,14 @@ "description": "", "main": "index.js", "scripts": { - "init": "./create_bucket.sh lld-terraform-basic-marko && terraform init -backend-config=\"bucket=lld-terraform-basic-marko\"", + "init": "./create_bucket.sh lld-terraform-basic-marko && terraform init -backend-config=\"bucket=lld-terraform-basic-marko\" -backend-config=\"region=eu-west-1\"", + "init:localstack": "./create_bucket.sh lld-terraform-basic && tflocal init -backend-config=\"bucket=lld-terraform-basic\" -backend-config=\"region=eu-west-1\"", + "install:localstack": "pip install terraform-local", "build_test-ts-esmodule": "cd services/testTsEsModule && npx tsc && cp package.json ./dist && cd ../..", "build_test-ts-commonjs": "cd services/testTsCommonJs && npx tsc && cp package.json ./dist && cd ../..", "build": "npm run build_test-ts-esmodule && npm run build_test-ts-commonjs", "deploy": "npm run build && terraform apply -auto-approve && terraform output -json > terraform-outputs.json", + "deploy:localstack": "npm run build && tflocal apply -auto-approve && tflocal output -json > terraform-outputs.json", "destroy": "npm run build && terraform destroy -auto-approve" }, "keywords": [], @@ -20,4 +23,4 @@ "dependencies": { "@aws-sdk/client-sts": "^3.920.0" } -} +} \ No newline at end of file diff --git a/test/utils/startDebugger.ts b/test/utils/startDebugger.ts index 08b67d6d..98c8cff8 100644 --- a/test/utils/startDebugger.ts +++ b/test/utils/startDebugger.ts @@ -38,6 +38,8 @@ async function startDebuggerInternal(folder: string, args: string[] = []) { argsI.push('-v'); + argsI.push('--region eu-west-1'); + let command = `node ${ testMonorepo ? '' : '../../' }dist/lldebugger.mjs ${argsI?.join(' ')}`;