name: LocalStack Compatibility Check for Infra
run-name: LocalStack Compatibility Check for Infra (The PR is ${{ github.event.pull_request.number }} and the branch name is ${{ github.event.pull_request.head.ref }})
permissions:
  id-token: write
  contents: read
  pull-requests: write
on:
  pull_request:
    branches:
      - 'main'
    paths:
      - 'infra/**'
env:
  ENV_NAME: master
  AWS_REGION: 'us-east-1'
  AWS_SECRET_REGION: 'eu-west-2'
  TFENV_INSTALL_DIR: infra
  NEXUS_USER: svc.nexus@perimeter81.com
  NODE_VERSION: 20
jobs:
  localstack_infra_check:
    runs-on: ubuntu-latest
    services:
      localstack:
        image: localstack/localstack-pro:latest
        env:
          SERVICES: "apigateway,lambda,dynamodb,sqs,sns,s3,iam,cloudwatch,logs,ssm,ec2"
          DEFAULT_REGION: "us-east-1"
          DEBUG: "1"
          LOCALSTACK_AUTH_TOKEN: ${{ secrets.LOCALSTACK_AUTH_TOKEN }}
        ports:
          - "127.0.0.1:4566:4566" # LocalStack Gateway
          - "127.0.0.1:4510-4550:4510-4550" # external services port range
          - "127.0.0.1:53:53" # DNS config (required for Pro)
          # - "127.0.0.1:53:53/udp"            # DNS config (required for Pro)
          - "127.0.0.1:443:443" # LocalStack HTTPS Gateway (required for Pro)
        volumes:
          - "/var/run/docker.sock:/var/run/docker.sock"
    steps:
      - name: prepare infra to deploy
        uses: perimeter-81/actions/actions/terragrunt/test_resource@main
      - name: run test deployment on localstack
        run: |-
          npm ci
          ./entrypoint-dev.sh
