ローカル環境でのEventBridgeの作成・削除などを行う必要が発生したので、実装してみた。

DockerでLocalStackの起動

version: '2.1'

services:
  localstack:
    container_name: '${LOCALSTACK_DOCKER_NAME-localstack_main}'
    image: localstack/localstack
    network_mode: bridge
    ports:
      - '4566:4566'
      - '4571:4571'
      - '${PORT_WEB_UI-8081}:${PORT_WEB_UI-8081}'
    environment:
      - SERVICES=${SERVICES- }
      - DEBUG=${DEBUG- }
      - DATA_DIR=${DATA_DIR- }
      - PORT_WEB_UI=${PORT_WEB_UI- }
      - LAMBDA_EXECUTOR=${LAMBDA_EXECUTOR- }
      - KINESIS_ERROR_PROBABILITY=${KINESIS_ERROR_PROBABILITY- }
      - DOCKER_HOST=unix:///var/run/docker.sock
      - HOST_TMP_FOLDER=${TMPDIR}
    volumes:
      - '${TMPDIR:-/tmp/localstack}:/tmp/localstack'
      - '/var/run/docker.sock:/var/run/docker.sock'

SDKでエンドポイントを指定

if (STAGE === 'local') params.endpoint = 'http://localhost:4566';
const eventBridgeClient = new AWS.EventBridge({
  ...params,
  ...{apiVersion: '2015-10-07'}
});