From d0fa074d827e4915e98d44c523c916ce56699634 Mon Sep 17 00:00:00 2001 From: William Putra Intan <61998484+williamputraintan@users.noreply.github.com> Date: Wed, 17 Apr 2024 13:27:40 +1000 Subject: [PATCH] =?UTF-8?q?chore:=20remove=20parent=20(of=20=C2=B5-app)=20?= =?UTF-8?q?stack=20in=20`cdk.Stage`=20and=20Refactor=20(#221)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .prettierignore | 4 +- Makefile | 6 +- README.md | 4 +- ...eless-pipeline.ts => statelessPipeline.ts} | 2 +- config/constants.ts | 175 ++++++++++-------- ...ine-stack.ts => statelessPipelineStack.ts} | 44 +++-- lib/workload/components/vpc/index.ts | 14 -- lib/workload/orcabus-stateless-stack.ts | 116 ------------ lib/workload/stateful/stacks/shared/README.md | 2 +- .../stateless/metadata_manager/compose.yml | 3 - .../sequence_run_manager/compose.yml | 10 - .../{ => stacks}/filemanager/.env.example | 0 .../{ => stacks}/filemanager/.gitignore | 0 .../{ => stacks}/filemanager/Cargo.lock | 0 .../{ => stacks}/filemanager/Cargo.toml | 0 .../{ => stacks}/filemanager/Makefile | 0 .../{ => stacks}/filemanager/README.md | 0 .../{ => stacks}/filemanager/build.rs | 0 .../{ => stacks}/filemanager/compose.yml | 0 .../filemanager/database/Dockerfile | 0 .../migrations/0001_add_object_table.sql | 0 .../migrations/0002_add_s3_object_table.sql | 0 .../aws/insert_s3_created_objects.sql | 0 .../aws/insert_s3_deleted_objects.sql | 0 .../aws/update_reordered_for_created.sql | 0 .../aws/update_reordered_for_deleted.sql | 0 .../queries/ingester/insert_objects.sql | 0 .../{ => stacks}/filemanager/deploy/README.md | 0 .../deploy/constructs/functions/function.ts | 2 +- .../deploy/constructs/functions/ingest.ts | 0 .../deploy/constructs/functions/migrate.ts | 0 .../filemanager/deploy/lib/filemanager.ts | 73 +++++--- .../filemanager/docs/ARCHITECTURE.md | 0 .../filemanager-http-lambda/Cargo.toml | 0 .../filemanager-http-lambda/README.md | 0 .../filemanager-http-lambda/src/main.rs | 0 .../filemanager-ingest-lambda/Cargo.toml | 0 .../filemanager-ingest-lambda/README.md | 0 .../filemanager-ingest-lambda/src/main.rs | 0 .../filemanager-migrate-lambda/Cargo.toml | 0 .../filemanager-migrate-lambda/src/main.rs | 0 .../filemanager/filemanager/Cargo.toml | 0 .../filemanager/filemanager/README.md | 0 .../filemanager/src/clients/aws/config.rs | 0 .../filemanager/src/clients/aws/mod.rs | 0 .../filemanager/src/clients/aws/s3.rs | 0 .../filemanager/src/clients/aws/sqs.rs | 0 .../filemanager/src/clients/mod.rs | 0 .../src/database/aws/credentials.rs | 0 .../filemanager/src/database/aws/ingester.rs | 0 .../filemanager/src/database/aws/migration.rs | 0 .../filemanager/src/database/aws/mod.rs | 0 .../filemanager/src/database/mod.rs | 0 .../filemanager/filemanager/src/error.rs | 0 .../filemanager/src/events/aws/collecter.rs | 0 .../filemanager/src/events/aws/message.rs | 0 .../filemanager/src/events/aws/mod.rs | 0 .../filemanager/filemanager/src/events/mod.rs | 0 .../filemanager/src/handlers/aws.rs | 0 .../filemanager/src/handlers/mod.rs | 0 .../filemanager/filemanager/src/lib.rs | 0 .../filemanager/filemanager/src/uuid.rs | 0 .../metadata-manager}/Makefile | 0 .../metadata-manager}/README.md | 2 +- .../metadata-manager}/app/__init__.py | 0 .../metadata-manager}/app/fields.py | 0 .../app/management/__init__.py | 0 .../app/management/commands/__init__.py | 0 .../management/commands/insert_mock_data.py | 0 .../app/migrations/0001_initial.py | 0 .../app/migrations/__init__.py | 0 .../metadata-manager}/app/models/__init__.py | 0 .../metadata-manager}/app/models/base.py | 0 .../app/models/lab/__init__.py | 0 .../app/models/lab/individual.py | 0 .../app/models/lab/library.py | 0 .../app/models/lab/specimen.py | 0 .../app/models/lab/subject.py | 0 .../app/models/pipeline/__init__.py | 0 .../app/models/pipeline/library_run.py | 0 .../metadata-manager}/app/pagination.py | 0 .../metadata-manager}/app/renderers.py | 0 .../metadata-manager}/app/routers.py | 0 .../metadata-manager}/app/serializers.py | 0 .../app/settings/__init__.py | 0 .../metadata-manager}/app/settings/aws.py | 0 .../metadata-manager}/app/settings/base.py | 0 .../metadata-manager}/app/settings/it.py | 0 .../metadata-manager}/app/settings/local.py | 0 .../metadata-manager}/app/tests/__init__.py | 0 .../metadata-manager}/app/tests/factories.py | 0 .../metadata-manager}/app/tests/test_base.py | 0 .../app/tests/test_models.py | 0 .../app/tests/test_viewsets.py | 0 .../metadata-manager}/app/tests/utils.py | 0 .../metadata-manager}/app/urls/__init__.py | 0 .../metadata-manager}/app/urls/base.py | 0 .../metadata-manager}/app/urls/local.py | 0 .../app/viewsets/__init__.py | 0 .../metadata-manager}/app/viewsets/lab.py | 0 .../metadata-manager}/app/wsgi.py | 0 .../stacks/metadata-manager/compose.yml | 3 + .../metadata-manager}/deploy/README.md | 0 .../deploy/construct/api-gw/index.ts | 0 .../deploy/construct/lambda-api/index.ts | 0 .../construct/lambda-migration/index.ts | 0 .../construct/lambda-sync-gsheet/index.ts | 0 .../lambda-sync-gsheet/lambda.Dockerfile | 0 .../metadata-manager}/deploy/stack.ts | 47 +++-- .../deps/requirements-dev.txt | 0 .../deps/requirements-full.txt | 0 .../deps/requirements-slim.Dockerfile | 0 .../deps/requirements-slim.txt | 0 .../deps/requirements-test.txt | 0 .../docs/architecture.drawio.svg | 0 .../metadata-manager}/docs/schema.drawio.svg | 0 .../metadata-manager}/handler/api.py | 0 .../metadata-manager}/handler/migrate.py | 0 .../handler/sync_tracking_sheet.py | 0 .../metadata-manager}/manage.py | 0 .../metadata-manager}/proc/__init__.py | 0 .../proc/service/__init__.py | 0 .../proc/service/tracking_sheet_srv.py | 0 .../metadata-manager}/proc/service/utils.py | 0 .../metadata-manager}/proc/tests/__init__.py | 0 .../proc/tests/test_tracking_sheet_srv.py | 0 .../postgres-manager}/.gitignore | 0 .../postgres-manager}/README.md | 0 .../construct/layer/node_module.Dockerfile | 0 .../postgres-manager/deploy/stack.ts} | 47 +++-- .../function/alter-pg-db-owner.ts | 0 .../function/create-pg-db.ts | 0 .../function/create-pg-iam-role.ts | 0 .../function/create-pg-login-role.ts | 0 .../postgres-manager}/function/type.ts | 0 .../postgres-manager}/function/utils.ts | 0 .../postgres-manager}/package.json | 0 .../postgres-manager}/yarn.lock | 0 .../sequence-run-manager}/.coveragerc | 0 .../sequence-run-manager}/Makefile | 0 .../sequence-run-manager}/README.md | 2 +- .../sequence-run-manager}/api.py | 0 .../stacks/sequence-run-manager/compose.yml | 10 + .../sequence-run-manager}/deploy/README.md | 0 .../deploy/apigw/component.ts | 0 .../sequence-run-manager}/deploy/component.ts | 66 ++++--- .../deps/requirements-dev.txt | 0 .../deps/requirements-test.txt | 0 .../deps/requirements.txt | 0 .../sequence-run-manager}/manage.py | 0 .../sequence-run-manager}/migrate.py | 0 .../sequence_run_manager/__init__.py | 0 .../sequence_run_manager/fields.py | 0 .../management/__init__.py | 0 .../management/commands/__init__.py | 0 .../commands/generate_mock_bssh_event.py | 0 .../management/commands/generate_mock_data.py | 0 .../commands/generate_mock_domain_event.py | 0 .../migrations/0001_initial.py | 0 .../migrations/__init__.py | 0 .../sequence_run_manager/models/__init__.py | 0 .../sequence_run_manager/models/base.py | 0 .../sequence_run_manager/models/sequence.py | 0 .../sequence_run_manager/pagination.py | 0 .../sequence_run_manager/renderers.py | 0 .../sequence_run_manager/routers.py | 0 .../sequence_run_manager/serializers.py | 0 .../sequence_run_manager/settings/__init__.py | 0 .../sequence_run_manager/settings/aws.py | 0 .../sequence_run_manager/settings/base.py | 0 .../sequence_run_manager/settings/it.py | 0 .../sequence_run_manager/settings/local.py | 0 .../sequence_run_manager/tests/__init__.py | 0 .../sequence_run_manager/tests/factories.py | 0 .../sequence_run_manager/tests/test_base.py | 0 .../sequence_run_manager/tests/test_models.py | 0 .../tests/test_viewsets.py | 0 .../sequence_run_manager/urls/__init__.py | 0 .../sequence_run_manager/urls/base.py | 0 .../sequence_run_manager/urls/local.py | 0 .../sequence_run_manager/viewsets/__init__.py | 0 .../sequence_run_manager/viewsets/sequence.py | 0 .../sequence_run_manager/wsgi.py | 0 .../sequence_run_manager_proc/__init__.py | 0 .../domain/__init__.py | 0 .../domain/sequence.py | 0 .../domain/sequencerunstatechange/AWSEvent.py | 0 .../SequenceRunStateChange.py | 0 .../domain/sequencerunstatechange/__init__.py | 0 .../sequencerunstatechange/marshaller.py | 0 .../lambdas/__init__.py | 0 .../lambdas/bssh_event.py | 0 .../services/__init__.py | 0 .../services/sequence_srv.py | 0 .../tests/__init__.py | 0 .../sequence_run_manager_proc/tests/case.py | 0 .../tests/test_bssh_event.py | 0 .../tests/test_sequence_domain.py | 0 .../tests/test_sequence_srv.py | 0 .../statelessStackCollectionClass.ts | 75 ++++++++ package.json | 2 +- ...-deployment.test.ts => deployment.test.ts} | 94 ++++------ ...less-pipeline.test.ts => pipeline.test.ts} | 6 +- 203 files changed, 405 insertions(+), 404 deletions(-) rename bin/{stateless-pipeline.ts => statelessPipeline.ts} (84%) rename lib/pipeline/{orcabus-stateless-pipeline-stack.ts => statelessPipelineStack.ts} (85%) delete mode 100644 lib/workload/components/vpc/index.ts delete mode 100644 lib/workload/orcabus-stateless-stack.ts delete mode 100644 lib/workload/stateless/metadata_manager/compose.yml delete mode 100644 lib/workload/stateless/sequence_run_manager/compose.yml rename lib/workload/stateless/{ => stacks}/filemanager/.env.example (100%) rename lib/workload/stateless/{ => stacks}/filemanager/.gitignore (100%) rename lib/workload/stateless/{ => stacks}/filemanager/Cargo.lock (100%) rename lib/workload/stateless/{ => stacks}/filemanager/Cargo.toml (100%) rename lib/workload/stateless/{ => stacks}/filemanager/Makefile (100%) rename lib/workload/stateless/{ => stacks}/filemanager/README.md (100%) rename lib/workload/stateless/{ => stacks}/filemanager/build.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/compose.yml (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/Dockerfile (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/migrations/0001_add_object_table.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/migrations/0002_add_s3_object_table.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/queries/ingester/aws/insert_s3_created_objects.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/queries/ingester/aws/insert_s3_deleted_objects.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/queries/ingester/aws/update_reordered_for_created.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/queries/ingester/aws/update_reordered_for_deleted.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/database/queries/ingester/insert_objects.sql (100%) rename lib/workload/stateless/{ => stacks}/filemanager/deploy/README.md (100%) rename lib/workload/stateless/{ => stacks}/filemanager/deploy/constructs/functions/function.ts (98%) rename lib/workload/stateless/{ => stacks}/filemanager/deploy/constructs/functions/ingest.ts (100%) rename lib/workload/stateless/{ => stacks}/filemanager/deploy/constructs/functions/migrate.ts (100%) rename lib/workload/stateless/{ => stacks}/filemanager/deploy/lib/filemanager.ts (56%) rename lib/workload/stateless/{ => stacks}/filemanager/docs/ARCHITECTURE.md (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-http-lambda/Cargo.toml (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-http-lambda/README.md (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-http-lambda/src/main.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-ingest-lambda/Cargo.toml (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-ingest-lambda/README.md (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-ingest-lambda/src/main.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-migrate-lambda/Cargo.toml (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager-migrate-lambda/src/main.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/Cargo.toml (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/README.md (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/clients/aws/config.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/clients/aws/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/clients/aws/s3.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/clients/aws/sqs.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/clients/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/database/aws/credentials.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/database/aws/ingester.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/database/aws/migration.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/database/aws/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/database/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/error.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/events/aws/collecter.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/events/aws/message.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/events/aws/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/events/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/handlers/aws.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/handlers/mod.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/lib.rs (100%) rename lib/workload/stateless/{ => stacks}/filemanager/filemanager/src/uuid.rs (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/Makefile (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/README.md (98%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/fields.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/management/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/management/commands/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/management/commands/insert_mock_data.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/migrations/0001_initial.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/migrations/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/base.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/lab/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/lab/individual.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/lab/library.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/lab/specimen.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/lab/subject.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/pipeline/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/models/pipeline/library_run.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/pagination.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/renderers.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/routers.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/serializers.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/settings/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/settings/aws.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/settings/base.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/settings/it.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/settings/local.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/tests/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/tests/factories.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/tests/test_base.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/tests/test_models.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/tests/test_viewsets.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/tests/utils.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/urls/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/urls/base.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/urls/local.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/viewsets/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/viewsets/lab.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/app/wsgi.py (100%) create mode 100644 lib/workload/stateless/stacks/metadata-manager/compose.yml rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/README.md (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/construct/api-gw/index.ts (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/construct/lambda-api/index.ts (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/construct/lambda-migration/index.ts (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/construct/lambda-sync-gsheet/index.ts (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/construct/lambda-sync-gsheet/lambda.Dockerfile (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deploy/stack.ts (76%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deps/requirements-dev.txt (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deps/requirements-full.txt (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deps/requirements-slim.Dockerfile (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deps/requirements-slim.txt (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/deps/requirements-test.txt (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/docs/architecture.drawio.svg (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/docs/schema.drawio.svg (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/handler/api.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/handler/migrate.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/handler/sync_tracking_sheet.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/manage.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/proc/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/proc/service/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/proc/service/tracking_sheet_srv.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/proc/service/utils.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/proc/tests/__init__.py (100%) rename lib/workload/stateless/{metadata_manager => stacks/metadata-manager}/proc/tests/test_tracking_sheet_srv.py (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/.gitignore (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/README.md (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/deploy/construct/layer/node_module.Dockerfile (100%) rename lib/workload/stateless/{postgres_manager/deploy/postgres-manager-stack.ts => stacks/postgres-manager/deploy/stack.ts} (87%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/function/alter-pg-db-owner.ts (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/function/create-pg-db.ts (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/function/create-pg-iam-role.ts (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/function/create-pg-login-role.ts (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/function/type.ts (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/function/utils.ts (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/package.json (100%) rename lib/workload/stateless/{postgres_manager => stacks/postgres-manager}/yarn.lock (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/.coveragerc (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/Makefile (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/README.md (98%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/api.py (100%) create mode 100644 lib/workload/stateless/stacks/sequence-run-manager/compose.yml rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/deploy/README.md (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/deploy/apigw/component.ts (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/deploy/component.ts (73%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/deps/requirements-dev.txt (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/deps/requirements-test.txt (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/deps/requirements.txt (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/manage.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/migrate.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/fields.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/management/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/management/commands/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/management/commands/generate_mock_bssh_event.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/management/commands/generate_mock_data.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/management/commands/generate_mock_domain_event.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/migrations/0001_initial.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/migrations/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/models/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/models/base.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/models/sequence.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/pagination.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/renderers.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/routers.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/serializers.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/settings/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/settings/aws.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/settings/base.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/settings/it.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/settings/local.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/tests/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/tests/factories.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/tests/test_base.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/tests/test_models.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/tests/test_viewsets.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/urls/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/urls/base.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/urls/local.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/viewsets/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/viewsets/sequence.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager/wsgi.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/domain/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/domain/sequence.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/domain/sequencerunstatechange/AWSEvent.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/domain/sequencerunstatechange/SequenceRunStateChange.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/domain/sequencerunstatechange/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/domain/sequencerunstatechange/marshaller.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/lambdas/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/lambdas/bssh_event.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/services/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/services/sequence_srv.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/tests/__init__.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/tests/case.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/tests/test_bssh_event.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/tests/test_sequence_domain.py (100%) rename lib/workload/stateless/{sequence_run_manager => stacks/sequence-run-manager}/sequence_run_manager_proc/tests/test_sequence_srv.py (100%) create mode 100644 lib/workload/stateless/statelessStackCollectionClass.ts rename test/stateless/{stateless-deployment.test.ts => deployment.test.ts} (50%) rename test/stateless/{stateless-pipeline.test.ts => pipeline.test.ts} (88%) diff --git a/.prettierignore b/.prettierignore index 0e741880b..5d3720afe 100644 --- a/.prettierignore +++ b/.prettierignore @@ -33,5 +33,5 @@ openapi/ venv/ # TODO still early days let ignore prettier them (microservice apps) for now -lib/workload/stateless/filemanager/ -lib/workload/stateless/sequence_run_manager/ +lib/workload/stateless/stacks/filemanager/ +lib/workload/stateless/stacks/sequence-run-manager/ diff --git a/Makefile b/Makefile index dc0849e70..a81317b97 100644 --- a/Makefile +++ b/Makefile @@ -30,9 +30,9 @@ test-stateless: # Note by running `make suite` target from repo root means your local dev env is okay with all app toolchains i.e. # Python (conda or venv), Rust and Cargo, TypeScript and Node environment, Docker and Container runtimes test-suite: - @(cd lib/workload/stateless/sequence_run_manager && $(MAKE) test) - @(cd lib/workload/stateless/metadata_manager && $(MAKE) test) - @(cd lib/workload/stateless/filemanager && $(MAKE) test) + @(cd lib/workload/stateless/stacks/sequence-run-manager && $(MAKE) test) + @(cd lib/workload/stateless/stacks/metadata-manager && $(MAKE) test) + @(cd lib/workload/stateless/stacks/filemanager && $(MAKE) test) # The default outer `test` target only run the top level cdk application unit tests under `./test` test: test-stateless test-stateful test-suite diff --git a/README.md b/README.md index f1f0e741c..7affa25c6 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ At the top level, the Git repository root is _the CDK TypeScript project_. It is Please note; this is the _INVERSE_ of some typical standalone project setup such that the repo root of the project is your app toolchain codebase and the deployment code are arranged under some arbitrary subdirectory like `./deploy/`. We **do not** do this in this repo as we anticipate that we are going to deploy multiple of closely related micro applications. -In this repo, we flip this view such that the Git repo root is the TypeScript CDK project; that wraps our applications into `./lib/` directory. You may [sparse checkout](https://git-scm.com/docs/git-sparse-checkout) or directly open subdirectory to set up the application project alone if you wish; e.g. `webstorm lib/workload/stateless/metadata_manager` or `code lib/workload/stateless/metadata_manager` or `pycharm lib/workload/stateless/sequence_run_manager` or `rustrover lib/workload/stateless/filemanager`. However, `code .` is a CDK TypeScript project. +In this repo, we flip this view such that the Git repo root is the TypeScript CDK project; that wraps our applications into `./lib/` directory. You may [sparse checkout](https://git-scm.com/docs/git-sparse-checkout) or directly open subdirectory to set up the application project alone if you wish; e.g. `webstorm lib/workload/stateless/stacks/metadata-manager` or `code lib/workload/stateless/stacks/metadata-manager` or `pycharm lib/workload/stateless/stacks/sequence-run-manager` or `rustrover lib/workload/stateless/stacks/filemanager`. However, `code .` is a CDK TypeScript project. There are 2 CDK apps here: @@ -85,7 +85,7 @@ You could list the CDK stacks with the `cdk ls` command to look at the stackId g yarn cdk-stateless ls OrcaBusStatelessPipeline -OrcaBusStatelessPipeline/BetaDeployment/MetadataManager +OrcaBusStatelessPipeline/BetaDeployment/MetadataManagerStack ... ``` diff --git a/bin/stateless-pipeline.ts b/bin/statelessPipeline.ts similarity index 84% rename from bin/stateless-pipeline.ts rename to bin/statelessPipeline.ts index 8bed2c1b4..d9537fdb0 100644 --- a/bin/stateless-pipeline.ts +++ b/bin/statelessPipeline.ts @@ -2,7 +2,7 @@ import 'source-map-support/register'; import * as cdk from 'aws-cdk-lib'; -import { StatelessPipelineStack } from '../lib/pipeline/orcabus-stateless-pipeline-stack'; +import { StatelessPipelineStack } from '../lib/pipeline/statelessPipelineStack'; const AWS_TOOLCHAIN_ACCOUNT = '383856791668'; // Bastion const AWS_TOOLCHAIN_REGION = 'ap-southeast-2'; diff --git a/config/constants.ts b/config/constants.ts index aa81c72c8..e74e2aab3 100644 --- a/config/constants.ts +++ b/config/constants.ts @@ -1,15 +1,18 @@ import { AuroraPostgresEngineVersion } from 'aws-cdk-lib/aws-rds'; -import { OrcaBusStatelessConfig } from '../lib/workload/orcabus-stateless-stack'; +import { VpcLookupOptions } from 'aws-cdk-lib/aws-ec2'; import { Duration, RemovalPolicy } from 'aws-cdk-lib'; import { EventSourceProps } from '../lib/workload/stateful/stacks/shared/constructs/event-source'; -import { DbAuthType } from '../lib/workload/stateless/postgres_manager/function/type'; +import { DbAuthType } from '../lib/workload/stateless/stacks/postgres-manager/function/type'; import { FILEMANAGER_SERVICE_NAME, FilemanagerConfig, -} from '../lib/workload/stateless/filemanager/deploy/lib/filemanager'; +} from '../lib/workload/stateless/stacks/filemanager/deploy/lib/filemanager'; import { IcaEventPipeStackProps } from '../lib/workload/stateful/stacks/ica-event-pipe/stack'; import { StatefulStackCollectionProps } from '../lib/workload/stateful/statefulStackCollectionClass'; -import { VpcLookupOptions } from 'aws-cdk-lib/aws-ec2'; +import { StatelessStackCollectionProps } from '../lib/workload/stateless/statelessStackCollectionClass'; +import { SequenceRunManagerStackProps } from '../lib/workload/stateless/stacks/sequence-run-manager/deploy/component'; +import { MetadataManagerStackProps } from '../lib/workload/stateless/stacks/metadata-manager/deploy/stack'; +import { PostgresManagerStackProps } from '../lib/workload/stateless/stacks/postgres-manager/deploy/stack'; const region = 'ap-southeast-2'; @@ -53,7 +56,7 @@ const icaEventPipeProps: IcaEventPipeStackProps = { const serviceUserSecretName = 'orcabus/token-service-user'; // pragma: allowlist secret const jwtSecretName = 'orcabus/token-service-jwt'; // pragma: allowlist secret -const orcaBusStatefulConfig = { +const statefulConfig = { schemaRegistryProps: { registryName: regName, description: 'Registry for OrcaBus Events', @@ -92,48 +95,61 @@ const orcaBusStatefulConfig = { }, }; -const orcaBusStatelessConfig = { - multiSchemaConstructProps: { - registryName: regName, - schemas: [ - { - schemaName: 'BclConvertWorkflowRequest', - schemaDescription: 'Request event for BclConvertWorkflow', - schemaType: 'OpenApi3', - schemaLocation: __dirname + '/event_schemas/BclConvertWorkflowRequest.json', - }, - { - schemaName: 'DragenWgsQcWorkflowRequest', - schemaDescription: 'Request event for DragenWgsQcWorkflowRequest', - schemaType: 'OpenApi3', - schemaLocation: __dirname + '/event_schemas/DragenWgsQcWorkflowRequest.json', - }, - ], - }, - eventBusName: eventBusName, - computeSecurityGroupName: computeSecurityGroupName, - rdsMasterSecretName: rdsMasterSecretName, - postgresManagerConfig: { - masterSecretName: rdsMasterSecretName, - dbClusterIdentifier: dbClusterIdentifier, - clusterResourceIdParameterName: dbClusterResourceIdParameterName, - dbPort: databasePort, - microserviceDbConfig: [ - { - name: 'sequence_run_manager', - authType: DbAuthType.USERNAME_PASSWORD, - }, - { - name: 'metadata_manager', - authType: DbAuthType.USERNAME_PASSWORD, - }, - { name: FILEMANAGER_SERVICE_NAME, authType: DbAuthType.RDS_IAM }, - ], - secretRotationSchedule: Duration.days(7), - }, - metadataManagerConfig: {}, +const sequenceRunManagerStackProps: SequenceRunManagerStackProps = { + vpcProps, + lambdaSecurityGroupName: computeSecurityGroupName, + mainBusName: eventBusName, +}; + +const metadataManagerStackProps: MetadataManagerStackProps = { + vpcProps, + lambdaSecurityGroupName: computeSecurityGroupName, }; +const postgresManagerStackProps: PostgresManagerStackProps = { + vpcProps, + lambdaSecurityGroupName: computeSecurityGroupName, + masterSecretName: rdsMasterSecretName, + dbClusterIdentifier: dbClusterIdentifier, + clusterResourceIdParameterName: dbClusterResourceIdParameterName, + dbPort: databasePort, + microserviceDbConfig: [ + { + name: 'sequence_run_manager', + authType: DbAuthType.USERNAME_PASSWORD, + }, + { + name: 'metadata_manager', + authType: DbAuthType.USERNAME_PASSWORD, + }, + { name: FILEMANAGER_SERVICE_NAME, authType: DbAuthType.RDS_IAM }, + ], + secretRotationSchedule: Duration.days(7), +}; + +// const statelessConfig = { +// multiSchemaConstructProps: { +// registryName: regName, +// schemas: [ +// { +// schemaName: 'BclConvertWorkflowRequest', +// schemaDescription: 'Request event for BclConvertWorkflow', +// schemaType: 'OpenApi3', +// schemaLocation: __dirname + '/event_schemas/BclConvertWorkflowRequest.json', +// }, +// { +// schemaName: 'DragenWgsQcWorkflowRequest', +// schemaDescription: 'Request event for DragenWgsQcWorkflowRequest', +// schemaType: 'OpenApi3', +// schemaLocation: __dirname + '/event_schemas/DragenWgsQcWorkflowRequest.json', +// }, +// ], +// }, +// eventBusName: eventBusName, +// computeSecurityGroupName: computeSecurityGroupName, +// rdsMasterSecretName: rdsMasterSecretName, +// }; + const eventSourceConfig = (bucket: string): EventSourceProps => { return { queueName: eventSourceQueueName, @@ -148,11 +164,14 @@ const eventSourceConfig = (bucket: string): EventSourceProps => { const filemanagerConfig = (bucket: string): FilemanagerConfig => { return { + securityGroupName: computeSecurityGroupName, + vpcProps, eventSourceQueueName: eventSourceQueueName, databaseClusterEndpointHostParameter: - orcaBusStatefulConfig.databaseProps.clusterEndpointHostParameterName, + statefulConfig.databaseProps.clusterEndpointHostParameterName, port: databasePort, eventSourceBuckets: [bucket], + migrateDatabase: true, }; }; @@ -162,7 +181,7 @@ interface EnvironmentConfig { accountId: string; stackProps: { statefulConfig: StatefulStackCollectionProps; - orcaBusStatelessConfig: OrcaBusStatelessConfig; + statelessConfig: StatelessStackCollectionProps; }; } @@ -191,10 +210,10 @@ export const getEnvironmentConfig = ( statefulConfig: { sharedStackProps: { vpcProps, - schemaRegistryProps: orcaBusStatefulConfig.schemaRegistryProps, - eventBusProps: orcaBusStatefulConfig.eventBusProps, + schemaRegistryProps: statefulConfig.schemaRegistryProps, + eventBusProps: statefulConfig.eventBusProps, databaseProps: { - ...orcaBusStatefulConfig.databaseProps, + ...statefulConfig.databaseProps, numberOfInstance: 1, minACU: 0.5, maxACU: 16, @@ -202,15 +221,17 @@ export const getEnvironmentConfig = ( enablePerformanceInsights: true, removalPolicy: RemovalPolicy.DESTROY, }, - computeProps: orcaBusStatefulConfig.computeProps, + computeProps: statefulConfig.computeProps, eventSourceProps: eventSourceConfig(devBucket), }, - tokenServiceStackProps: orcaBusStatefulConfig.tokenServiceProps, - icaEventPipeStackProps: orcaBusStatefulConfig.icaEventPipeProps, + tokenServiceStackProps: statefulConfig.tokenServiceProps, + icaEventPipeStackProps: statefulConfig.icaEventPipeProps, }, - orcaBusStatelessConfig: { - ...orcaBusStatelessConfig, - filemanagerConfig: filemanagerConfig(devBucket), + statelessConfig: { + postgresManagerStackProps: postgresManagerStackProps, + metadataManagerStackProps: metadataManagerStackProps, + sequenceRunManagerStackProps: sequenceRunManagerStackProps, + fileManagerStackProps: filemanagerConfig(devBucket), }, }, }; @@ -225,10 +246,10 @@ export const getEnvironmentConfig = ( statefulConfig: { sharedStackProps: { vpcProps, - schemaRegistryProps: orcaBusStatefulConfig.schemaRegistryProps, - eventBusProps: orcaBusStatefulConfig.eventBusProps, + schemaRegistryProps: statefulConfig.schemaRegistryProps, + eventBusProps: statefulConfig.eventBusProps, databaseProps: { - ...orcaBusStatefulConfig.databaseProps, + ...statefulConfig.databaseProps, numberOfInstance: 1, minACU: 0.5, maxACU: 16, @@ -236,15 +257,17 @@ export const getEnvironmentConfig = ( enablePerformanceInsights: true, removalPolicy: RemovalPolicy.DESTROY, }, - computeProps: orcaBusStatefulConfig.computeProps, + computeProps: statefulConfig.computeProps, eventSourceProps: eventSourceConfig(stgBucket), }, - tokenServiceStackProps: orcaBusStatefulConfig.tokenServiceProps, - icaEventPipeStackProps: orcaBusStatefulConfig.icaEventPipeProps, + tokenServiceStackProps: statefulConfig.tokenServiceProps, + icaEventPipeStackProps: statefulConfig.icaEventPipeProps, }, - orcaBusStatelessConfig: { - ...orcaBusStatelessConfig, - filemanagerConfig: filemanagerConfig(stgBucket), + statelessConfig: { + postgresManagerStackProps: postgresManagerStackProps, + metadataManagerStackProps: metadataManagerStackProps, + sequenceRunManagerStackProps: sequenceRunManagerStackProps, + fileManagerStackProps: filemanagerConfig(stgBucket), }, }, }; @@ -259,31 +282,33 @@ export const getEnvironmentConfig = ( statefulConfig: { sharedStackProps: { vpcProps, - schemaRegistryProps: orcaBusStatefulConfig.schemaRegistryProps, - eventBusProps: orcaBusStatefulConfig.eventBusProps, + schemaRegistryProps: statefulConfig.schemaRegistryProps, + eventBusProps: statefulConfig.eventBusProps, databaseProps: { - ...orcaBusStatefulConfig.databaseProps, + ...statefulConfig.databaseProps, numberOfInstance: 1, minACU: 0.5, maxACU: 16, removalPolicy: RemovalPolicy.RETAIN, }, - computeProps: orcaBusStatefulConfig.computeProps, + computeProps: statefulConfig.computeProps, eventSourceProps: eventSourceConfig(prodBucket), }, - tokenServiceStackProps: orcaBusStatefulConfig.tokenServiceProps, - icaEventPipeStackProps: orcaBusStatefulConfig.icaEventPipeProps, + tokenServiceStackProps: statefulConfig.tokenServiceProps, + icaEventPipeStackProps: statefulConfig.icaEventPipeProps, }, - orcaBusStatelessConfig: { - ...orcaBusStatelessConfig, - filemanagerConfig: filemanagerConfig(prodBucket), + statelessConfig: { + postgresManagerStackProps: postgresManagerStackProps, + metadataManagerStackProps: metadataManagerStackProps, + sequenceRunManagerStackProps: sequenceRunManagerStackProps, + fileManagerStackProps: filemanagerConfig(prodBucket), }, }, }; break; } - // validateSecretName(config.stackProps.orcaBusStatefulConfig.databaseProps.masterSecretName); + // validateSecretName(config.stackProps.statefulConfig.databaseProps.masterSecretName); return config; }; diff --git a/lib/pipeline/orcabus-stateless-pipeline-stack.ts b/lib/pipeline/statelessPipelineStack.ts similarity index 85% rename from lib/pipeline/orcabus-stateless-pipeline-stack.ts rename to lib/pipeline/statelessPipelineStack.ts index 20b4588aa..ee1f6a8ad 100644 --- a/lib/pipeline/orcabus-stateless-pipeline-stack.ts +++ b/lib/pipeline/statelessPipelineStack.ts @@ -7,7 +7,12 @@ import * as iam from 'aws-cdk-lib/aws-iam'; import * as chatbot from 'aws-cdk-lib/aws-chatbot'; import * as codepipeline from 'aws-cdk-lib/aws-codepipeline'; import * as codestarnotifications from 'aws-cdk-lib/aws-codestarnotifications'; -import { OrcaBusStatelessConfig, OrcaBusStatelessStack } from '../workload/orcabus-stateless-stack'; + +import { + StatelessStackCollection, + StatelessStackCollectionProps, +} from '../workload/stateless/statelessStackCollectionClass'; + import { getEnvironmentConfig } from '../../config/constants'; export class StatelessPipelineStack extends cdk.Stack { @@ -99,9 +104,15 @@ export class StatelessPipelineStack extends cdk.Stack { const betaConfig = getEnvironmentConfig('beta'); if (!betaConfig) throw new Error(`No 'Beta' account configuration`); pipeline.addStage( - new OrcaBusStatelessDeploymentStage(this, 'BetaDeployment', betaConfig.stackProps, { - account: betaConfig.accountId, - }) + new OrcaBusStatelessDeploymentStage( + this, + 'BetaDeployment', + betaConfig.stackProps.statelessConfig, + { + account: betaConfig.accountId, + region: betaConfig.region, + } + ) ); // Since the stateless stack might need to reference the stateful resources (e.g. db, sg), we might comment this out @@ -117,9 +128,10 @@ export class StatelessPipelineStack extends cdk.Stack { // new OrcaBusStatelessDeploymentStage( // this, // 'GammaDeployment', - // gammaConfig.stackProps, + // gammaConfig.stackProps.statelessConfig, // { // account: gammaConfig.accountId, + // region: gammaConfig.region, // } // ), // { pre: [new pipelines.ManualApprovalStep('PromoteToGamma')] } @@ -131,9 +143,15 @@ export class StatelessPipelineStack extends cdk.Stack { // const prodConfig = getEnvironmentConfig('prod'); // if (!prodConfig) throw new Error(`No 'Prod' account configuration`); // pipeline.addStage( - // new OrcaBusStatelessDeploymentStage(this, 'ProdDeployment', prodConfig.stackProps, { - // account: prodConfig?.accountId, - // }), + // new OrcaBusStatelessDeploymentStage( + // this, + // 'ProdDeployment', + // prodConfig.stackProps.statelessConfig, + // { + // account: prodConfig.accountId, + // region: prodConfig.region, + // } + // ), // { pre: [new pipelines.ManualApprovalStep('PromoteToProd')] } // ); @@ -166,13 +184,11 @@ class OrcaBusStatelessDeploymentStage extends cdk.Stage { constructor( scope: Construct, environmentName: string, - stackProps: { - orcaBusStatelessConfig: OrcaBusStatelessConfig; - }, - env?: cdk.Environment + statelessStackCollectionProps: StatelessStackCollectionProps, + env: cdk.Environment ) { - super(scope, environmentName, { env: { account: env?.account, region: 'ap-southeast-2' } }); + super(scope, environmentName, { env: env }); - new OrcaBusStatelessStack(this, 'OrcaBusStatelessStack', stackProps.orcaBusStatelessConfig); + new StatelessStackCollection(this, env, statelessStackCollectionProps); } } diff --git a/lib/workload/components/vpc/index.ts b/lib/workload/components/vpc/index.ts deleted file mode 100644 index 62f7d260b..000000000 --- a/lib/workload/components/vpc/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { aws_ec2 } from 'aws-cdk-lib'; -import { Construct } from 'constructs'; - -export function getVpc(scope: Construct) { - const vpcName = 'main-vpc'; - const vpcTags = { - Stack: 'networking', - }; - - return aws_ec2.Vpc.fromLookup(scope, 'MainVpc', { - vpcName: scope.node.tryGetContext(vpcName), - tags: vpcTags, - }); -} diff --git a/lib/workload/orcabus-stateless-stack.ts b/lib/workload/orcabus-stateless-stack.ts deleted file mode 100644 index c079670d4..000000000 --- a/lib/workload/orcabus-stateless-stack.ts +++ /dev/null @@ -1,116 +0,0 @@ -import * as cdk from 'aws-cdk-lib'; -import { Arn } from 'aws-cdk-lib'; -import { Construct } from 'constructs'; -import { getVpc } from './components/vpc'; -import { MultiSchemaConstructProps } from './stateless/schema/component'; -import { IVpc, ISecurityGroup, SecurityGroup } from 'aws-cdk-lib/aws-ec2'; -import { Filemanager, FilemanagerConfig } from './stateless/filemanager/deploy/lib/filemanager'; -import { Queue } from 'aws-cdk-lib/aws-sqs'; -import { - PostgresManagerStack, - PostgresManagerConfig, -} from './stateless/postgres_manager/deploy/postgres-manager-stack'; -import { - MetadataManagerStack, - MetadataManagerConfig, -} from './stateless/metadata_manager/deploy/stack'; -import { SequenceRunManagerStack } from './stateless/sequence_run_manager/deploy/component'; -import { EventBus, IEventBus } from 'aws-cdk-lib/aws-events'; - -export interface OrcaBusStatelessConfig { - multiSchemaConstructProps: MultiSchemaConstructProps; - eventBusName: string; - computeSecurityGroupName: string; - rdsMasterSecretName: string; - postgresManagerConfig: PostgresManagerConfig; - metadataManagerConfig: MetadataManagerConfig; - filemanagerConfig: FilemanagerConfig; -} - -export class OrcaBusStatelessStack extends cdk.Stack { - private readonly vpc: IVpc; - private readonly lambdaSecurityGroup: ISecurityGroup; - private readonly mainBus: IEventBus; - - // microservice stacks - microserviceStackArray: cdk.Stack[] = []; - - constructor(scope: Construct, id: string, props: cdk.StackProps & OrcaBusStatelessConfig) { - super(scope, id, props); - - // --- Constructs from Stateful stack or pre-existing resources - - this.vpc = getVpc(this); - - this.lambdaSecurityGroup = SecurityGroup.fromLookupByName( - this, - 'OrcaBusLambdaSecurityGroup', - props.computeSecurityGroupName, - this.vpc - ); - - this.mainBus = EventBus.fromEventBusName(this, 'OrcaBusMain', props.eventBusName); - - // --- Create Stateless resources - - // new MultiSchemaConstruct(this, 'MultiSchema', props.multiSchemaConstructProps); - - // hook microservice construct components here - - this.microserviceStackArray.push(this.createSequenceRunManager(props)); - this.microserviceStackArray.push(this.createPostgresManager(props.postgresManagerConfig)); - this.microserviceStackArray.push(this.createMetadataManager(props.metadataManagerConfig)); - this.microserviceStackArray.push(this.createFilemanager(props.filemanagerConfig)); - } - - private createSequenceRunManager(props: cdk.StackProps) { - return new SequenceRunManagerStack(this, 'SequenceRunManager', { - securityGroups: [this.lambdaSecurityGroup], - vpc: this.vpc, - mainBus: this.mainBus, - ...props, - }); - } - - private createPostgresManager(config: PostgresManagerConfig) { - return new PostgresManagerStack(this, 'PostgresManager', { - ...config, - vpc: this.vpc, - lambdaSecurityGroup: this.lambdaSecurityGroup, - }); - } - - private createMetadataManager(config: MetadataManagerConfig) { - return new MetadataManagerStack(this, 'MetadataManager', { - vpc: this.vpc, - lambdaSecurityGroups: this.lambdaSecurityGroup, - ...config, - }); - } - - private createFilemanager(config: FilemanagerConfig) { - // Opting to reconstruct the dependencies here, and pass them into the service as constructs. - const queue = Queue.fromQueueArn( - this, - 'FilemanagerQueue', - Arn.format( - { - resource: config.eventSourceQueueName, - service: 'sqs', - }, - this - ) - ); - - return new Filemanager(this, 'Filemanager', { - buckets: config.eventSourceBuckets, - buildEnvironment: {}, - databaseClusterEndpointHostParameter: config.databaseClusterEndpointHostParameter, - port: config.port, - securityGroup: this.lambdaSecurityGroup, - eventSources: [queue], - migrateDatabase: true, - vpc: this.vpc, - }); - } -} diff --git a/lib/workload/stateful/stacks/shared/README.md b/lib/workload/stateful/stacks/shared/README.md index bb6229fce..9b07614c8 100644 --- a/lib/workload/stateful/stacks/shared/README.md +++ b/lib/workload/stateful/stacks/shared/README.md @@ -15,7 +15,7 @@ task on PostgreSQL. RDS IAM is enabled for the cluster and, therefore is encouraged to be used rather than relying on username-password approach to log into your database. You could choose the type of authentication upon creating a role at the RDS when using the `PostgresManager`. -Please check the: [PostgresManager](../../../stateless/postgres_manager/README.md) +Please check: [PostgresManager](../../../stateless/stacks/postgres-manager/README.md) ## Event Source diff --git a/lib/workload/stateless/metadata_manager/compose.yml b/lib/workload/stateless/metadata_manager/compose.yml deleted file mode 100644 index a78de2c63..000000000 --- a/lib/workload/stateless/metadata_manager/compose.yml +++ /dev/null @@ -1,3 +0,0 @@ -include: - - path: - - ../../../../shared/mock-db.yml diff --git a/lib/workload/stateless/sequence_run_manager/compose.yml b/lib/workload/stateless/sequence_run_manager/compose.yml deleted file mode 100644 index e1659a410..000000000 --- a/lib/workload/stateless/sequence_run_manager/compose.yml +++ /dev/null @@ -1,10 +0,0 @@ -include: - - path: -# - ../../../../shared/mock-ica.yml - - ../../../../shared/mock-aws.yml - - ../../../../shared/mock-db.yml - -#services: -# -# myapp: -# image: myapp diff --git a/lib/workload/stateless/filemanager/.env.example b/lib/workload/stateless/stacks/filemanager/.env.example similarity index 100% rename from lib/workload/stateless/filemanager/.env.example rename to lib/workload/stateless/stacks/filemanager/.env.example diff --git a/lib/workload/stateless/filemanager/.gitignore b/lib/workload/stateless/stacks/filemanager/.gitignore similarity index 100% rename from lib/workload/stateless/filemanager/.gitignore rename to lib/workload/stateless/stacks/filemanager/.gitignore diff --git a/lib/workload/stateless/filemanager/Cargo.lock b/lib/workload/stateless/stacks/filemanager/Cargo.lock similarity index 100% rename from lib/workload/stateless/filemanager/Cargo.lock rename to lib/workload/stateless/stacks/filemanager/Cargo.lock diff --git a/lib/workload/stateless/filemanager/Cargo.toml b/lib/workload/stateless/stacks/filemanager/Cargo.toml similarity index 100% rename from lib/workload/stateless/filemanager/Cargo.toml rename to lib/workload/stateless/stacks/filemanager/Cargo.toml diff --git a/lib/workload/stateless/filemanager/Makefile b/lib/workload/stateless/stacks/filemanager/Makefile similarity index 100% rename from lib/workload/stateless/filemanager/Makefile rename to lib/workload/stateless/stacks/filemanager/Makefile diff --git a/lib/workload/stateless/filemanager/README.md b/lib/workload/stateless/stacks/filemanager/README.md similarity index 100% rename from lib/workload/stateless/filemanager/README.md rename to lib/workload/stateless/stacks/filemanager/README.md diff --git a/lib/workload/stateless/filemanager/build.rs b/lib/workload/stateless/stacks/filemanager/build.rs similarity index 100% rename from lib/workload/stateless/filemanager/build.rs rename to lib/workload/stateless/stacks/filemanager/build.rs diff --git a/lib/workload/stateless/filemanager/compose.yml b/lib/workload/stateless/stacks/filemanager/compose.yml similarity index 100% rename from lib/workload/stateless/filemanager/compose.yml rename to lib/workload/stateless/stacks/filemanager/compose.yml diff --git a/lib/workload/stateless/filemanager/database/Dockerfile b/lib/workload/stateless/stacks/filemanager/database/Dockerfile similarity index 100% rename from lib/workload/stateless/filemanager/database/Dockerfile rename to lib/workload/stateless/stacks/filemanager/database/Dockerfile diff --git a/lib/workload/stateless/filemanager/database/migrations/0001_add_object_table.sql b/lib/workload/stateless/stacks/filemanager/database/migrations/0001_add_object_table.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/migrations/0001_add_object_table.sql rename to lib/workload/stateless/stacks/filemanager/database/migrations/0001_add_object_table.sql diff --git a/lib/workload/stateless/filemanager/database/migrations/0002_add_s3_object_table.sql b/lib/workload/stateless/stacks/filemanager/database/migrations/0002_add_s3_object_table.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/migrations/0002_add_s3_object_table.sql rename to lib/workload/stateless/stacks/filemanager/database/migrations/0002_add_s3_object_table.sql diff --git a/lib/workload/stateless/filemanager/database/queries/ingester/aws/insert_s3_created_objects.sql b/lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/insert_s3_created_objects.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/queries/ingester/aws/insert_s3_created_objects.sql rename to lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/insert_s3_created_objects.sql diff --git a/lib/workload/stateless/filemanager/database/queries/ingester/aws/insert_s3_deleted_objects.sql b/lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/insert_s3_deleted_objects.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/queries/ingester/aws/insert_s3_deleted_objects.sql rename to lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/insert_s3_deleted_objects.sql diff --git a/lib/workload/stateless/filemanager/database/queries/ingester/aws/update_reordered_for_created.sql b/lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/update_reordered_for_created.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/queries/ingester/aws/update_reordered_for_created.sql rename to lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/update_reordered_for_created.sql diff --git a/lib/workload/stateless/filemanager/database/queries/ingester/aws/update_reordered_for_deleted.sql b/lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/update_reordered_for_deleted.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/queries/ingester/aws/update_reordered_for_deleted.sql rename to lib/workload/stateless/stacks/filemanager/database/queries/ingester/aws/update_reordered_for_deleted.sql diff --git a/lib/workload/stateless/filemanager/database/queries/ingester/insert_objects.sql b/lib/workload/stateless/stacks/filemanager/database/queries/ingester/insert_objects.sql similarity index 100% rename from lib/workload/stateless/filemanager/database/queries/ingester/insert_objects.sql rename to lib/workload/stateless/stacks/filemanager/database/queries/ingester/insert_objects.sql diff --git a/lib/workload/stateless/filemanager/deploy/README.md b/lib/workload/stateless/stacks/filemanager/deploy/README.md similarity index 100% rename from lib/workload/stateless/filemanager/deploy/README.md rename to lib/workload/stateless/stacks/filemanager/deploy/README.md diff --git a/lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts b/lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/function.ts similarity index 98% rename from lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts rename to lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/function.ts index 5f158a811..ae8a42829 100644 --- a/lib/workload/stateless/filemanager/deploy/constructs/functions/function.ts +++ b/lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/function.ts @@ -8,7 +8,7 @@ import path from 'path'; import { exec } from 'cargo-lambda-cdk/lib/util'; import { randomUUID } from 'node:crypto'; import { print } from 'aws-cdk/lib/logging'; -import { PostgresManagerStack } from '../../../../postgres_manager/deploy/postgres-manager-stack'; +import { PostgresManagerStack } from '../../../../postgres-manager/deploy/stack'; import { FILEMANAGER_SERVICE_NAME } from '../../lib/filemanager'; /** diff --git a/lib/workload/stateless/filemanager/deploy/constructs/functions/ingest.ts b/lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/ingest.ts similarity index 100% rename from lib/workload/stateless/filemanager/deploy/constructs/functions/ingest.ts rename to lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/ingest.ts diff --git a/lib/workload/stateless/filemanager/deploy/constructs/functions/migrate.ts b/lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/migrate.ts similarity index 100% rename from lib/workload/stateless/filemanager/deploy/constructs/functions/migrate.ts rename to lib/workload/stateless/stacks/filemanager/deploy/constructs/functions/migrate.ts diff --git a/lib/workload/stateless/filemanager/deploy/lib/filemanager.ts b/lib/workload/stateless/stacks/filemanager/deploy/lib/filemanager.ts similarity index 56% rename from lib/workload/stateless/filemanager/deploy/lib/filemanager.ts rename to lib/workload/stateless/stacks/filemanager/deploy/lib/filemanager.ts index 88e4ef6d5..1088407d1 100644 --- a/lib/workload/stateless/filemanager/deploy/lib/filemanager.ts +++ b/lib/workload/stateless/stacks/filemanager/deploy/lib/filemanager.ts @@ -3,10 +3,11 @@ import { EventSourceProps, IngestFunction } from '../constructs/functions/ingest import { MigrateFunction } from '../constructs/functions/migrate'; import * as fn from '../constructs/functions/function'; import { DatabaseProps } from '../constructs/functions/function'; -import { IVpc } from 'aws-cdk-lib/aws-ec2'; -import { Stack, StackProps } from 'aws-cdk-lib'; +import { Vpc, SecurityGroup, VpcLookupOptions } from 'aws-cdk-lib/aws-ec2'; +import { Arn, Stack, StackProps } from 'aws-cdk-lib'; import { StringParameter } from 'aws-cdk-lib/aws-ssm'; -import { ProviderFunction } from '../../../../components/provider_function'; +import { ProviderFunction } from '../../../../../components/provider_function'; +import { Queue } from 'aws-cdk-lib/aws-sqs'; export const FILEMANAGER_SERVICE_NAME = 'filemanager'; @@ -26,25 +27,24 @@ export type FilemanagerConfig = Omit & * The parameter name that contains the database cluster endpoint. */ databaseClusterEndpointHostParameter: string; + /** + * The parameter name that contains the database cluster endpoint. + */ + vpcProps: VpcLookupOptions; + /** + * Whether to initialize a database migration. + */ + migrateDatabase?: boolean; + /** + * The security group name to be attached to lambdas. + */ + securityGroupName: string; } /** * Props for the filemanager stack. */ -export type FilemanagerProps = StackProps & EventSourceProps & fn.FunctionPropsNoPackage & Omit & { - /** - * VPC to use for filemanager. - */ - readonly vpc: IVpc, - /** - * Whether to initialize a database migration. - */ - readonly migrateDatabase?: boolean; - /** - * The parameter name that contains the database cluster endpoint. - */ - readonly databaseClusterEndpointHostParameter: string; -}; +export type FilemanagerProps = StackProps & FilemanagerConfig; /** * Construct used to configure the filemanager. @@ -53,6 +53,15 @@ export class Filemanager extends Stack { constructor(scope: Construct, id: string, props: FilemanagerProps) { super(scope, id, props); + const vpc = Vpc.fromLookup(this, 'MainVpc', props.vpcProps); + + const lambdaSecurityGroup = SecurityGroup.fromLookupByName( + this, + 'OrcaBusLambdaSecurityGroup', + props.securityGroupName, + vpc + ); + const host = StringParameter.valueForStringParameter( this, props.databaseClusterEndpointHostParameter @@ -60,29 +69,37 @@ export class Filemanager extends Stack { if (props?.migrateDatabase) { const migrateFunction = new MigrateFunction(this, 'MigrateFunction', { - vpc: props.vpc, + vpc: vpc, host: host, port: props.port, - securityGroup: props.securityGroup, - buildEnvironment: props?.buildEnvironment, - rustLog: props?.rustLog, + securityGroup: lambdaSecurityGroup, }); new ProviderFunction(this, 'MigrateProviderFunction', { - vpc: props.vpc, + vpc: vpc, function: migrateFunction.function, }); } + const queue = Queue.fromQueueArn( + this, + 'FilemanagerQueue', + Arn.format( + { + resource: props.eventSourceQueueName, + service: 'sqs', + }, + this + ) + ); + new IngestFunction(this, 'IngestLambda', { - vpc: props.vpc, + vpc: vpc, host: host, port: props.port, - securityGroup: props.securityGroup, - eventSources: props.eventSources, - buckets: props.buckets, - buildEnvironment: props?.buildEnvironment, - rustLog: props?.rustLog, + securityGroup: lambdaSecurityGroup, + eventSources: [queue], + buckets: props.eventSourceBuckets, }); } } diff --git a/lib/workload/stateless/filemanager/docs/ARCHITECTURE.md b/lib/workload/stateless/stacks/filemanager/docs/ARCHITECTURE.md similarity index 100% rename from lib/workload/stateless/filemanager/docs/ARCHITECTURE.md rename to lib/workload/stateless/stacks/filemanager/docs/ARCHITECTURE.md diff --git a/lib/workload/stateless/filemanager/filemanager-http-lambda/Cargo.toml b/lib/workload/stateless/stacks/filemanager/filemanager-http-lambda/Cargo.toml similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-http-lambda/Cargo.toml rename to lib/workload/stateless/stacks/filemanager/filemanager-http-lambda/Cargo.toml diff --git a/lib/workload/stateless/filemanager/filemanager-http-lambda/README.md b/lib/workload/stateless/stacks/filemanager/filemanager-http-lambda/README.md similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-http-lambda/README.md rename to lib/workload/stateless/stacks/filemanager/filemanager-http-lambda/README.md diff --git a/lib/workload/stateless/filemanager/filemanager-http-lambda/src/main.rs b/lib/workload/stateless/stacks/filemanager/filemanager-http-lambda/src/main.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-http-lambda/src/main.rs rename to lib/workload/stateless/stacks/filemanager/filemanager-http-lambda/src/main.rs diff --git a/lib/workload/stateless/filemanager/filemanager-ingest-lambda/Cargo.toml b/lib/workload/stateless/stacks/filemanager/filemanager-ingest-lambda/Cargo.toml similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-ingest-lambda/Cargo.toml rename to lib/workload/stateless/stacks/filemanager/filemanager-ingest-lambda/Cargo.toml diff --git a/lib/workload/stateless/filemanager/filemanager-ingest-lambda/README.md b/lib/workload/stateless/stacks/filemanager/filemanager-ingest-lambda/README.md similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-ingest-lambda/README.md rename to lib/workload/stateless/stacks/filemanager/filemanager-ingest-lambda/README.md diff --git a/lib/workload/stateless/filemanager/filemanager-ingest-lambda/src/main.rs b/lib/workload/stateless/stacks/filemanager/filemanager-ingest-lambda/src/main.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-ingest-lambda/src/main.rs rename to lib/workload/stateless/stacks/filemanager/filemanager-ingest-lambda/src/main.rs diff --git a/lib/workload/stateless/filemanager/filemanager-migrate-lambda/Cargo.toml b/lib/workload/stateless/stacks/filemanager/filemanager-migrate-lambda/Cargo.toml similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-migrate-lambda/Cargo.toml rename to lib/workload/stateless/stacks/filemanager/filemanager-migrate-lambda/Cargo.toml diff --git a/lib/workload/stateless/filemanager/filemanager-migrate-lambda/src/main.rs b/lib/workload/stateless/stacks/filemanager/filemanager-migrate-lambda/src/main.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager-migrate-lambda/src/main.rs rename to lib/workload/stateless/stacks/filemanager/filemanager-migrate-lambda/src/main.rs diff --git a/lib/workload/stateless/filemanager/filemanager/Cargo.toml b/lib/workload/stateless/stacks/filemanager/filemanager/Cargo.toml similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/Cargo.toml rename to lib/workload/stateless/stacks/filemanager/filemanager/Cargo.toml diff --git a/lib/workload/stateless/filemanager/filemanager/README.md b/lib/workload/stateless/stacks/filemanager/filemanager/README.md similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/README.md rename to lib/workload/stateless/stacks/filemanager/filemanager/README.md diff --git a/lib/workload/stateless/filemanager/filemanager/src/clients/aws/config.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/config.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/clients/aws/config.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/config.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/clients/aws/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/clients/aws/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/clients/aws/s3.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/s3.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/clients/aws/s3.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/s3.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/clients/aws/sqs.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/sqs.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/clients/aws/sqs.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/clients/aws/sqs.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/clients/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/clients/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/clients/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/clients/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/database/aws/credentials.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/credentials.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/database/aws/credentials.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/credentials.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/database/aws/ingester.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/ingester.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/database/aws/ingester.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/ingester.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/database/aws/migration.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/migration.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/database/aws/migration.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/migration.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/database/aws/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/database/aws/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/database/aws/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/database/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/database/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/database/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/database/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/error.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/error.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/error.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/error.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/events/aws/collecter.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/events/aws/collecter.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/events/aws/collecter.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/events/aws/collecter.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/events/aws/message.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/events/aws/message.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/events/aws/message.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/events/aws/message.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/events/aws/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/events/aws/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/events/aws/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/events/aws/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/events/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/events/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/events/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/events/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/handlers/aws.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/handlers/aws.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/handlers/aws.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/handlers/aws.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/handlers/mod.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/handlers/mod.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/handlers/mod.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/handlers/mod.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/lib.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/lib.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/lib.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/lib.rs diff --git a/lib/workload/stateless/filemanager/filemanager/src/uuid.rs b/lib/workload/stateless/stacks/filemanager/filemanager/src/uuid.rs similarity index 100% rename from lib/workload/stateless/filemanager/filemanager/src/uuid.rs rename to lib/workload/stateless/stacks/filemanager/filemanager/src/uuid.rs diff --git a/lib/workload/stateless/metadata_manager/Makefile b/lib/workload/stateless/stacks/metadata-manager/Makefile similarity index 100% rename from lib/workload/stateless/metadata_manager/Makefile rename to lib/workload/stateless/stacks/metadata-manager/Makefile diff --git a/lib/workload/stateless/metadata_manager/README.md b/lib/workload/stateless/stacks/metadata-manager/README.md similarity index 98% rename from lib/workload/stateless/metadata_manager/README.md rename to lib/workload/stateless/stacks/metadata-manager/README.md index 84e2add48..f94000b88 100644 --- a/lib/workload/stateless/metadata_manager/README.md +++ b/lib/workload/stateless/stacks/metadata-manager/README.md @@ -69,7 +69,7 @@ Python 3.12.2 You would need to go to this microservice app directory from the root project ```bash -cd lib/workload/stateless/metadata_manager +cd lib/workload/stateless/stacks/metadata-manager ``` ### Setup diff --git a/lib/workload/stateless/metadata_manager/app/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/fields.py b/lib/workload/stateless/stacks/metadata-manager/app/fields.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/fields.py rename to lib/workload/stateless/stacks/metadata-manager/app/fields.py diff --git a/lib/workload/stateless/metadata_manager/app/management/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/management/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/management/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/management/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/management/commands/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/management/commands/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/management/commands/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/management/commands/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/management/commands/insert_mock_data.py b/lib/workload/stateless/stacks/metadata-manager/app/management/commands/insert_mock_data.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/management/commands/insert_mock_data.py rename to lib/workload/stateless/stacks/metadata-manager/app/management/commands/insert_mock_data.py diff --git a/lib/workload/stateless/metadata_manager/app/migrations/0001_initial.py b/lib/workload/stateless/stacks/metadata-manager/app/migrations/0001_initial.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/migrations/0001_initial.py rename to lib/workload/stateless/stacks/metadata-manager/app/migrations/0001_initial.py diff --git a/lib/workload/stateless/metadata_manager/app/migrations/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/migrations/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/migrations/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/migrations/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/models/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/models/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/models/base.py b/lib/workload/stateless/stacks/metadata-manager/app/models/base.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/base.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/base.py diff --git a/lib/workload/stateless/metadata_manager/app/models/lab/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/models/lab/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/lab/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/lab/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/models/lab/individual.py b/lib/workload/stateless/stacks/metadata-manager/app/models/lab/individual.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/lab/individual.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/lab/individual.py diff --git a/lib/workload/stateless/metadata_manager/app/models/lab/library.py b/lib/workload/stateless/stacks/metadata-manager/app/models/lab/library.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/lab/library.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/lab/library.py diff --git a/lib/workload/stateless/metadata_manager/app/models/lab/specimen.py b/lib/workload/stateless/stacks/metadata-manager/app/models/lab/specimen.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/lab/specimen.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/lab/specimen.py diff --git a/lib/workload/stateless/metadata_manager/app/models/lab/subject.py b/lib/workload/stateless/stacks/metadata-manager/app/models/lab/subject.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/lab/subject.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/lab/subject.py diff --git a/lib/workload/stateless/metadata_manager/app/models/pipeline/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/models/pipeline/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/pipeline/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/pipeline/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/models/pipeline/library_run.py b/lib/workload/stateless/stacks/metadata-manager/app/models/pipeline/library_run.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/models/pipeline/library_run.py rename to lib/workload/stateless/stacks/metadata-manager/app/models/pipeline/library_run.py diff --git a/lib/workload/stateless/metadata_manager/app/pagination.py b/lib/workload/stateless/stacks/metadata-manager/app/pagination.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/pagination.py rename to lib/workload/stateless/stacks/metadata-manager/app/pagination.py diff --git a/lib/workload/stateless/metadata_manager/app/renderers.py b/lib/workload/stateless/stacks/metadata-manager/app/renderers.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/renderers.py rename to lib/workload/stateless/stacks/metadata-manager/app/renderers.py diff --git a/lib/workload/stateless/metadata_manager/app/routers.py b/lib/workload/stateless/stacks/metadata-manager/app/routers.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/routers.py rename to lib/workload/stateless/stacks/metadata-manager/app/routers.py diff --git a/lib/workload/stateless/metadata_manager/app/serializers.py b/lib/workload/stateless/stacks/metadata-manager/app/serializers.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/serializers.py rename to lib/workload/stateless/stacks/metadata-manager/app/serializers.py diff --git a/lib/workload/stateless/metadata_manager/app/settings/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/settings/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/settings/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/settings/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/settings/aws.py b/lib/workload/stateless/stacks/metadata-manager/app/settings/aws.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/settings/aws.py rename to lib/workload/stateless/stacks/metadata-manager/app/settings/aws.py diff --git a/lib/workload/stateless/metadata_manager/app/settings/base.py b/lib/workload/stateless/stacks/metadata-manager/app/settings/base.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/settings/base.py rename to lib/workload/stateless/stacks/metadata-manager/app/settings/base.py diff --git a/lib/workload/stateless/metadata_manager/app/settings/it.py b/lib/workload/stateless/stacks/metadata-manager/app/settings/it.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/settings/it.py rename to lib/workload/stateless/stacks/metadata-manager/app/settings/it.py diff --git a/lib/workload/stateless/metadata_manager/app/settings/local.py b/lib/workload/stateless/stacks/metadata-manager/app/settings/local.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/settings/local.py rename to lib/workload/stateless/stacks/metadata-manager/app/settings/local.py diff --git a/lib/workload/stateless/metadata_manager/app/tests/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/tests/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/tests/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/tests/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/tests/factories.py b/lib/workload/stateless/stacks/metadata-manager/app/tests/factories.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/tests/factories.py rename to lib/workload/stateless/stacks/metadata-manager/app/tests/factories.py diff --git a/lib/workload/stateless/metadata_manager/app/tests/test_base.py b/lib/workload/stateless/stacks/metadata-manager/app/tests/test_base.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/tests/test_base.py rename to lib/workload/stateless/stacks/metadata-manager/app/tests/test_base.py diff --git a/lib/workload/stateless/metadata_manager/app/tests/test_models.py b/lib/workload/stateless/stacks/metadata-manager/app/tests/test_models.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/tests/test_models.py rename to lib/workload/stateless/stacks/metadata-manager/app/tests/test_models.py diff --git a/lib/workload/stateless/metadata_manager/app/tests/test_viewsets.py b/lib/workload/stateless/stacks/metadata-manager/app/tests/test_viewsets.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/tests/test_viewsets.py rename to lib/workload/stateless/stacks/metadata-manager/app/tests/test_viewsets.py diff --git a/lib/workload/stateless/metadata_manager/app/tests/utils.py b/lib/workload/stateless/stacks/metadata-manager/app/tests/utils.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/tests/utils.py rename to lib/workload/stateless/stacks/metadata-manager/app/tests/utils.py diff --git a/lib/workload/stateless/metadata_manager/app/urls/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/urls/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/urls/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/urls/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/urls/base.py b/lib/workload/stateless/stacks/metadata-manager/app/urls/base.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/urls/base.py rename to lib/workload/stateless/stacks/metadata-manager/app/urls/base.py diff --git a/lib/workload/stateless/metadata_manager/app/urls/local.py b/lib/workload/stateless/stacks/metadata-manager/app/urls/local.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/urls/local.py rename to lib/workload/stateless/stacks/metadata-manager/app/urls/local.py diff --git a/lib/workload/stateless/metadata_manager/app/viewsets/__init__.py b/lib/workload/stateless/stacks/metadata-manager/app/viewsets/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/viewsets/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/app/viewsets/__init__.py diff --git a/lib/workload/stateless/metadata_manager/app/viewsets/lab.py b/lib/workload/stateless/stacks/metadata-manager/app/viewsets/lab.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/viewsets/lab.py rename to lib/workload/stateless/stacks/metadata-manager/app/viewsets/lab.py diff --git a/lib/workload/stateless/metadata_manager/app/wsgi.py b/lib/workload/stateless/stacks/metadata-manager/app/wsgi.py similarity index 100% rename from lib/workload/stateless/metadata_manager/app/wsgi.py rename to lib/workload/stateless/stacks/metadata-manager/app/wsgi.py diff --git a/lib/workload/stateless/stacks/metadata-manager/compose.yml b/lib/workload/stateless/stacks/metadata-manager/compose.yml new file mode 100644 index 000000000..bddd63a41 --- /dev/null +++ b/lib/workload/stateless/stacks/metadata-manager/compose.yml @@ -0,0 +1,3 @@ +include: + - path: + - ../../../../../shared/mock-db.yml diff --git a/lib/workload/stateless/metadata_manager/deploy/README.md b/lib/workload/stateless/stacks/metadata-manager/deploy/README.md similarity index 100% rename from lib/workload/stateless/metadata_manager/deploy/README.md rename to lib/workload/stateless/stacks/metadata-manager/deploy/README.md diff --git a/lib/workload/stateless/metadata_manager/deploy/construct/api-gw/index.ts b/lib/workload/stateless/stacks/metadata-manager/deploy/construct/api-gw/index.ts similarity index 100% rename from lib/workload/stateless/metadata_manager/deploy/construct/api-gw/index.ts rename to lib/workload/stateless/stacks/metadata-manager/deploy/construct/api-gw/index.ts diff --git a/lib/workload/stateless/metadata_manager/deploy/construct/lambda-api/index.ts b/lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-api/index.ts similarity index 100% rename from lib/workload/stateless/metadata_manager/deploy/construct/lambda-api/index.ts rename to lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-api/index.ts diff --git a/lib/workload/stateless/metadata_manager/deploy/construct/lambda-migration/index.ts b/lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-migration/index.ts similarity index 100% rename from lib/workload/stateless/metadata_manager/deploy/construct/lambda-migration/index.ts rename to lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-migration/index.ts diff --git a/lib/workload/stateless/metadata_manager/deploy/construct/lambda-sync-gsheet/index.ts b/lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-sync-gsheet/index.ts similarity index 100% rename from lib/workload/stateless/metadata_manager/deploy/construct/lambda-sync-gsheet/index.ts rename to lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-sync-gsheet/index.ts diff --git a/lib/workload/stateless/metadata_manager/deploy/construct/lambda-sync-gsheet/lambda.Dockerfile b/lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-sync-gsheet/lambda.Dockerfile similarity index 100% rename from lib/workload/stateless/metadata_manager/deploy/construct/lambda-sync-gsheet/lambda.Dockerfile rename to lib/workload/stateless/stacks/metadata-manager/deploy/construct/lambda-sync-gsheet/lambda.Dockerfile diff --git a/lib/workload/stateless/metadata_manager/deploy/stack.ts b/lib/workload/stateless/stacks/metadata-manager/deploy/stack.ts similarity index 76% rename from lib/workload/stateless/metadata_manager/deploy/stack.ts rename to lib/workload/stateless/stacks/metadata-manager/deploy/stack.ts index bf8f79f1a..8004c4dfe 100644 --- a/lib/workload/stateless/metadata_manager/deploy/stack.ts +++ b/lib/workload/stateless/stacks/metadata-manager/deploy/stack.ts @@ -1,7 +1,7 @@ import path from 'path'; import { Construct } from 'constructs'; import { Stack, StackProps } from 'aws-cdk-lib'; -import { ISecurityGroup, IVpc } from 'aws-cdk-lib/aws-ec2'; +import { Vpc, VpcLookupOptions, SecurityGroup } from 'aws-cdk-lib/aws-ec2'; import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; import { Schedule } from 'aws-cdk-lib/aws-events'; import { Code, Runtime, Architecture, LayerVersion } from 'aws-cdk-lib/aws-lambda'; @@ -11,38 +11,37 @@ import { LambdaSyncGsheetConstruct } from './construct/lambda-sync-gsheet'; import { LambdaMigrationConstruct } from './construct/lambda-migration'; import { LambdaAPIConstruct } from './construct/lambda-api'; import { ApiGatewayConstruct } from './construct/api-gw'; -import { PostgresManagerStack } from '../../postgres_manager/deploy/postgres-manager-stack'; +import { PostgresManagerStack } from '../../postgres-manager/deploy/stack'; -/** - * this config should be configured at the top (root) cdk app - */ -export type MetadataManagerConfig = { +export type MetadataManagerStackProps = { /** - * the interval where the lambda conduct the sync from the single source of truth data + * VPC (lookup props) that will be used by resources */ - syncInterval?: Schedule; -}; - -/** - * the props expected when the (metadata-manager) stack is constructed - */ -export type MetadataManagerProps = MetadataManagerConfig & { + vpcProps: VpcLookupOptions; /** - * the special security group that will be attached to lambdas (e.g. SG allow to access db cluster) + * Existing security group name to be attached on lambdas */ - lambdaSecurityGroups: ISecurityGroup; + lambdaSecurityGroupName: string; /** - * vpc where the lambdas will deploy + * the interval where the lambda conduct the sync from the single source of truth data */ - vpc: IVpc; + syncInterval?: Schedule; }; export class MetadataManagerStack extends Stack { private readonly MM_RDS_CRED_SECRET_NAME = PostgresManagerStack.formatDbSecretManagerName('metadata_manager'); - constructor(scope: Construct, id: string, props: StackProps & MetadataManagerProps) { - super(scope, id); + constructor(scope: Construct, id: string, props: StackProps & MetadataManagerStackProps) { + super(scope, id, props); + + const vpc = Vpc.fromLookup(this, 'MainVpc', props.vpcProps); + const lambdaSG = SecurityGroup.fromLookupByName( + this, + 'LambdaSecurityGroup', + props.lambdaSecurityGroupName, + vpc + ); // lookup the secret manager resource so we could give lambda permissions to read it const dbSecret = Secret.fromSecretNameV2( @@ -69,13 +68,13 @@ export class MetadataManagerStack extends Stack { DJANGO_SETTINGS_MODULE: 'app.settings.aws', RDS_CRED_SECRET_NAME: this.MM_RDS_CRED_SECRET_NAME, }, - securityGroups: [props.lambdaSecurityGroups], - vpc: props.vpc, - vpcSubnets: { subnets: props.vpc.privateSubnets }, + securityGroups: [lambdaSG], + vpc: vpc, + vpcSubnets: { subnets: vpc.privateSubnets }, architecture: Architecture.ARM_64, }; - // There are 2 lambdas for this app + // There are 3 lambdas for this app // 1. To handle API calls from API-GW // 2. To do migrations // 3. To sync db with external sources (e.g. metadata in gsheet) diff --git a/lib/workload/stateless/metadata_manager/deps/requirements-dev.txt b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-dev.txt similarity index 100% rename from lib/workload/stateless/metadata_manager/deps/requirements-dev.txt rename to lib/workload/stateless/stacks/metadata-manager/deps/requirements-dev.txt diff --git a/lib/workload/stateless/metadata_manager/deps/requirements-full.txt b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-full.txt similarity index 100% rename from lib/workload/stateless/metadata_manager/deps/requirements-full.txt rename to lib/workload/stateless/stacks/metadata-manager/deps/requirements-full.txt diff --git a/lib/workload/stateless/metadata_manager/deps/requirements-slim.Dockerfile b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.Dockerfile similarity index 100% rename from lib/workload/stateless/metadata_manager/deps/requirements-slim.Dockerfile rename to lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.Dockerfile diff --git a/lib/workload/stateless/metadata_manager/deps/requirements-slim.txt b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt similarity index 100% rename from lib/workload/stateless/metadata_manager/deps/requirements-slim.txt rename to lib/workload/stateless/stacks/metadata-manager/deps/requirements-slim.txt diff --git a/lib/workload/stateless/metadata_manager/deps/requirements-test.txt b/lib/workload/stateless/stacks/metadata-manager/deps/requirements-test.txt similarity index 100% rename from lib/workload/stateless/metadata_manager/deps/requirements-test.txt rename to lib/workload/stateless/stacks/metadata-manager/deps/requirements-test.txt diff --git a/lib/workload/stateless/metadata_manager/docs/architecture.drawio.svg b/lib/workload/stateless/stacks/metadata-manager/docs/architecture.drawio.svg similarity index 100% rename from lib/workload/stateless/metadata_manager/docs/architecture.drawio.svg rename to lib/workload/stateless/stacks/metadata-manager/docs/architecture.drawio.svg diff --git a/lib/workload/stateless/metadata_manager/docs/schema.drawio.svg b/lib/workload/stateless/stacks/metadata-manager/docs/schema.drawio.svg similarity index 100% rename from lib/workload/stateless/metadata_manager/docs/schema.drawio.svg rename to lib/workload/stateless/stacks/metadata-manager/docs/schema.drawio.svg diff --git a/lib/workload/stateless/metadata_manager/handler/api.py b/lib/workload/stateless/stacks/metadata-manager/handler/api.py similarity index 100% rename from lib/workload/stateless/metadata_manager/handler/api.py rename to lib/workload/stateless/stacks/metadata-manager/handler/api.py diff --git a/lib/workload/stateless/metadata_manager/handler/migrate.py b/lib/workload/stateless/stacks/metadata-manager/handler/migrate.py similarity index 100% rename from lib/workload/stateless/metadata_manager/handler/migrate.py rename to lib/workload/stateless/stacks/metadata-manager/handler/migrate.py diff --git a/lib/workload/stateless/metadata_manager/handler/sync_tracking_sheet.py b/lib/workload/stateless/stacks/metadata-manager/handler/sync_tracking_sheet.py similarity index 100% rename from lib/workload/stateless/metadata_manager/handler/sync_tracking_sheet.py rename to lib/workload/stateless/stacks/metadata-manager/handler/sync_tracking_sheet.py diff --git a/lib/workload/stateless/metadata_manager/manage.py b/lib/workload/stateless/stacks/metadata-manager/manage.py similarity index 100% rename from lib/workload/stateless/metadata_manager/manage.py rename to lib/workload/stateless/stacks/metadata-manager/manage.py diff --git a/lib/workload/stateless/metadata_manager/proc/__init__.py b/lib/workload/stateless/stacks/metadata-manager/proc/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/proc/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/proc/__init__.py diff --git a/lib/workload/stateless/metadata_manager/proc/service/__init__.py b/lib/workload/stateless/stacks/metadata-manager/proc/service/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/proc/service/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/proc/service/__init__.py diff --git a/lib/workload/stateless/metadata_manager/proc/service/tracking_sheet_srv.py b/lib/workload/stateless/stacks/metadata-manager/proc/service/tracking_sheet_srv.py similarity index 100% rename from lib/workload/stateless/metadata_manager/proc/service/tracking_sheet_srv.py rename to lib/workload/stateless/stacks/metadata-manager/proc/service/tracking_sheet_srv.py diff --git a/lib/workload/stateless/metadata_manager/proc/service/utils.py b/lib/workload/stateless/stacks/metadata-manager/proc/service/utils.py similarity index 100% rename from lib/workload/stateless/metadata_manager/proc/service/utils.py rename to lib/workload/stateless/stacks/metadata-manager/proc/service/utils.py diff --git a/lib/workload/stateless/metadata_manager/proc/tests/__init__.py b/lib/workload/stateless/stacks/metadata-manager/proc/tests/__init__.py similarity index 100% rename from lib/workload/stateless/metadata_manager/proc/tests/__init__.py rename to lib/workload/stateless/stacks/metadata-manager/proc/tests/__init__.py diff --git a/lib/workload/stateless/metadata_manager/proc/tests/test_tracking_sheet_srv.py b/lib/workload/stateless/stacks/metadata-manager/proc/tests/test_tracking_sheet_srv.py similarity index 100% rename from lib/workload/stateless/metadata_manager/proc/tests/test_tracking_sheet_srv.py rename to lib/workload/stateless/stacks/metadata-manager/proc/tests/test_tracking_sheet_srv.py diff --git a/lib/workload/stateless/postgres_manager/.gitignore b/lib/workload/stateless/stacks/postgres-manager/.gitignore similarity index 100% rename from lib/workload/stateless/postgres_manager/.gitignore rename to lib/workload/stateless/stacks/postgres-manager/.gitignore diff --git a/lib/workload/stateless/postgres_manager/README.md b/lib/workload/stateless/stacks/postgres-manager/README.md similarity index 100% rename from lib/workload/stateless/postgres_manager/README.md rename to lib/workload/stateless/stacks/postgres-manager/README.md diff --git a/lib/workload/stateless/postgres_manager/deploy/construct/layer/node_module.Dockerfile b/lib/workload/stateless/stacks/postgres-manager/deploy/construct/layer/node_module.Dockerfile similarity index 100% rename from lib/workload/stateless/postgres_manager/deploy/construct/layer/node_module.Dockerfile rename to lib/workload/stateless/stacks/postgres-manager/deploy/construct/layer/node_module.Dockerfile diff --git a/lib/workload/stateless/postgres_manager/deploy/postgres-manager-stack.ts b/lib/workload/stateless/stacks/postgres-manager/deploy/stack.ts similarity index 87% rename from lib/workload/stateless/postgres_manager/deploy/postgres-manager-stack.ts rename to lib/workload/stateless/stacks/postgres-manager/deploy/stack.ts index a7054ad2e..f8252795f 100644 --- a/lib/workload/stateless/postgres_manager/deploy/postgres-manager-stack.ts +++ b/lib/workload/stateless/stacks/postgres-manager/deploy/stack.ts @@ -3,7 +3,7 @@ import { Construct } from 'constructs'; import * as lambda from 'aws-cdk-lib/aws-lambda'; import * as nodejs from 'aws-cdk-lib/aws-lambda-nodejs'; import * as secretsmanager from 'aws-cdk-lib/aws-secretsmanager'; -import * as ec2 from 'aws-cdk-lib/aws-ec2'; +import { Vpc, VpcLookupOptions, SubnetType, SecurityGroup } from 'aws-cdk-lib/aws-ec2'; import * as iam from 'aws-cdk-lib/aws-iam'; import * as rds from 'aws-cdk-lib/aws-rds'; import * as ssm from 'aws-cdk-lib/aws-ssm'; @@ -11,7 +11,7 @@ import * as sm from 'aws-cdk-lib/aws-secretsmanager'; import { MicroserviceConfig, DbAuthType } from '../function/type'; import package_json from '../package.json'; -export type PostgresManagerConfig = { +export type PostgresManagerStackProps = { masterSecretName: string; dbClusterIdentifier: string; microserviceDbConfig: MicroserviceConfig; @@ -21,21 +21,30 @@ export type PostgresManagerConfig = { * The schedule (in Duration) that will rotate the microservice app secret */ secretRotationSchedule: Duration; -}; - -export type PostgresManagerProps = PostgresManagerConfig & { - vpc: ec2.IVpc; - lambdaSecurityGroup: ec2.ISecurityGroup; + /** + * VPC (lookup props) that will be used by resources + */ + vpcProps: VpcLookupOptions; + /** + * Existing security group name to be attached on lambdas + */ + lambdaSecurityGroupName: string; }; export class PostgresManagerStack extends Stack { // From default: https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_rds.DatabaseSecret.html#excludecharacters readonly passExcludedCharacter = '" %+~`#$&()|[]{}:;' + `<>?!'/@"\\")*`; - constructor(scope: Construct, id: string, props: StackProps & PostgresManagerProps) { - super(scope, id); + constructor(scope: Construct, id: string, props: StackProps & PostgresManagerStackProps) { + super(scope, id, props); - const { dbClusterIdentifier, microserviceDbConfig } = props; + const vpc = Vpc.fromLookup(this, 'MainVpc', props.vpcProps); + const lambdaSG = SecurityGroup.fromLookupByName( + this, + 'LambdaSecurityGroup', + props.lambdaSecurityGroupName, + vpc + ); const masterSecret = secretsmanager.Secret.fromSecretNameV2( this, @@ -49,7 +58,7 @@ export class PostgresManagerStack extends Stack { ); const dbCluster = rds.DatabaseCluster.fromDatabaseClusterAttributes(this, 'OrcabusDbCluster', { - clusterIdentifier: dbClusterIdentifier, + clusterIdentifier: props.dbClusterIdentifier, clusterResourceIdentifier: dbClusterResourceId, port: props.dbPort, }); @@ -75,11 +84,11 @@ export class PostgresManagerStack extends Stack { RDS_SECRET_MANAGER_NAME: masterSecret.secretName, MICROSERVICE_CONFIG: JSON.stringify(props.microserviceDbConfig), }, - vpc: props.vpc, + vpc: vpc, vpcSubnets: { - subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS, + subnetType: SubnetType.PRIVATE_WITH_EGRESS, }, - securityGroups: [props.lambdaSecurityGroup], + securityGroups: [lambdaSG], }; // 1. lambda responsible on db creation @@ -99,7 +108,7 @@ export class PostgresManagerStack extends Stack { masterSecret.grantRead(initiatePgRdsIam); // create iam-policy that could be assumed when using the rds-iam - for (const microservice of microserviceDbConfig) { + for (const microservice of props.microserviceDbConfig) { if (microservice.authType == DbAuthType.RDS_IAM) { const iamPolicy = new iam.ManagedPolicy(this, `${microservice.name}RdsIamPolicy`, { managedPolicyName: PostgresManagerStack.formatRdsPolicyName(microservice.name), @@ -118,7 +127,7 @@ export class PostgresManagerStack extends Stack { }; const secretManagerArray = []; - for (const microservice of microserviceDbConfig) { + for (const microservice of props.microserviceDbConfig) { if (microservice.authType == DbAuthType.USERNAME_PASSWORD) { // create secret manager for specific ยต-app const microSM = new sm.Secret(this, `${microservice.name}UserPassCred`, { @@ -143,10 +152,10 @@ export class PostgresManagerStack extends Stack { secret: microSM, target: dbCluster, automaticallyAfter: props.secretRotationSchedule, - securityGroup: props.lambdaSecurityGroup, - vpc: props.vpc, + securityGroup: lambdaSG, + vpc: vpc, vpcSubnets: { - subnetType: ec2.SubnetType.PRIVATE_WITH_EGRESS, + subnetType: SubnetType.PRIVATE_WITH_EGRESS, }, }); diff --git a/lib/workload/stateless/postgres_manager/function/alter-pg-db-owner.ts b/lib/workload/stateless/stacks/postgres-manager/function/alter-pg-db-owner.ts similarity index 100% rename from lib/workload/stateless/postgres_manager/function/alter-pg-db-owner.ts rename to lib/workload/stateless/stacks/postgres-manager/function/alter-pg-db-owner.ts diff --git a/lib/workload/stateless/postgres_manager/function/create-pg-db.ts b/lib/workload/stateless/stacks/postgres-manager/function/create-pg-db.ts similarity index 100% rename from lib/workload/stateless/postgres_manager/function/create-pg-db.ts rename to lib/workload/stateless/stacks/postgres-manager/function/create-pg-db.ts diff --git a/lib/workload/stateless/postgres_manager/function/create-pg-iam-role.ts b/lib/workload/stateless/stacks/postgres-manager/function/create-pg-iam-role.ts similarity index 100% rename from lib/workload/stateless/postgres_manager/function/create-pg-iam-role.ts rename to lib/workload/stateless/stacks/postgres-manager/function/create-pg-iam-role.ts diff --git a/lib/workload/stateless/postgres_manager/function/create-pg-login-role.ts b/lib/workload/stateless/stacks/postgres-manager/function/create-pg-login-role.ts similarity index 100% rename from lib/workload/stateless/postgres_manager/function/create-pg-login-role.ts rename to lib/workload/stateless/stacks/postgres-manager/function/create-pg-login-role.ts diff --git a/lib/workload/stateless/postgres_manager/function/type.ts b/lib/workload/stateless/stacks/postgres-manager/function/type.ts similarity index 100% rename from lib/workload/stateless/postgres_manager/function/type.ts rename to lib/workload/stateless/stacks/postgres-manager/function/type.ts diff --git a/lib/workload/stateless/postgres_manager/function/utils.ts b/lib/workload/stateless/stacks/postgres-manager/function/utils.ts similarity index 100% rename from lib/workload/stateless/postgres_manager/function/utils.ts rename to lib/workload/stateless/stacks/postgres-manager/function/utils.ts diff --git a/lib/workload/stateless/postgres_manager/package.json b/lib/workload/stateless/stacks/postgres-manager/package.json similarity index 100% rename from lib/workload/stateless/postgres_manager/package.json rename to lib/workload/stateless/stacks/postgres-manager/package.json diff --git a/lib/workload/stateless/postgres_manager/yarn.lock b/lib/workload/stateless/stacks/postgres-manager/yarn.lock similarity index 100% rename from lib/workload/stateless/postgres_manager/yarn.lock rename to lib/workload/stateless/stacks/postgres-manager/yarn.lock diff --git a/lib/workload/stateless/sequence_run_manager/.coveragerc b/lib/workload/stateless/stacks/sequence-run-manager/.coveragerc similarity index 100% rename from lib/workload/stateless/sequence_run_manager/.coveragerc rename to lib/workload/stateless/stacks/sequence-run-manager/.coveragerc diff --git a/lib/workload/stateless/sequence_run_manager/Makefile b/lib/workload/stateless/stacks/sequence-run-manager/Makefile similarity index 100% rename from lib/workload/stateless/sequence_run_manager/Makefile rename to lib/workload/stateless/stacks/sequence-run-manager/Makefile diff --git a/lib/workload/stateless/sequence_run_manager/README.md b/lib/workload/stateless/stacks/sequence-run-manager/README.md similarity index 98% rename from lib/workload/stateless/sequence_run_manager/README.md rename to lib/workload/stateless/stacks/sequence-run-manager/README.md index 2567cd269..522b9a27a 100644 --- a/lib/workload/stateless/sequence_run_manager/README.md +++ b/lib/workload/stateless/stacks/sequence-run-manager/README.md @@ -10,7 +10,7 @@ Namespace: orcabus.srm - Go to Django project root ``` -cd lib/workload/stateless/sequence_run_manager +cd lib/workload/stateless/stacks/sequence_run_manager ``` _*If you are PyCharmer and opening the whole `orcabus` project (i.e. not doing sparse checkout or not opening directly at this level) then annotate this level `sequence_run_manager` directory as "source" directory in the project structure dialog._ diff --git a/lib/workload/stateless/sequence_run_manager/api.py b/lib/workload/stateless/stacks/sequence-run-manager/api.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/api.py rename to lib/workload/stateless/stacks/sequence-run-manager/api.py diff --git a/lib/workload/stateless/stacks/sequence-run-manager/compose.yml b/lib/workload/stateless/stacks/sequence-run-manager/compose.yml new file mode 100644 index 000000000..271c25b71 --- /dev/null +++ b/lib/workload/stateless/stacks/sequence-run-manager/compose.yml @@ -0,0 +1,10 @@ +include: + - path: +# - ../../../../../shared/mock-ica.yml + - ../../../../../shared/mock-aws.yml + - ../../../../../shared/mock-db.yml + +#services: +# +# myapp: +# image: myapp diff --git a/lib/workload/stateless/sequence_run_manager/deploy/README.md b/lib/workload/stateless/stacks/sequence-run-manager/deploy/README.md similarity index 100% rename from lib/workload/stateless/sequence_run_manager/deploy/README.md rename to lib/workload/stateless/stacks/sequence-run-manager/deploy/README.md diff --git a/lib/workload/stateless/sequence_run_manager/deploy/apigw/component.ts b/lib/workload/stateless/stacks/sequence-run-manager/deploy/apigw/component.ts similarity index 100% rename from lib/workload/stateless/sequence_run_manager/deploy/apigw/component.ts rename to lib/workload/stateless/stacks/sequence-run-manager/deploy/apigw/component.ts diff --git a/lib/workload/stateless/sequence_run_manager/deploy/component.ts b/lib/workload/stateless/stacks/sequence-run-manager/deploy/component.ts similarity index 73% rename from lib/workload/stateless/sequence_run_manager/deploy/component.ts rename to lib/workload/stateless/stacks/sequence-run-manager/deploy/component.ts index db98b5309..454aa5695 100644 --- a/lib/workload/stateless/sequence_run_manager/deploy/component.ts +++ b/lib/workload/stateless/stacks/sequence-run-manager/deploy/component.ts @@ -2,37 +2,48 @@ import path from 'path'; import * as cdk from 'aws-cdk-lib'; import { aws_lambda, aws_secretsmanager, Duration, Stack } from 'aws-cdk-lib'; import { Construct } from 'constructs'; -import { ISecurityGroup, IVpc } from 'aws-cdk-lib/aws-ec2'; -import { IEventBus } from 'aws-cdk-lib/aws-events'; +import { ISecurityGroup, IVpc, SecurityGroup, Vpc, VpcLookupOptions } from 'aws-cdk-lib/aws-ec2'; +import { EventBus, IEventBus } from 'aws-cdk-lib/aws-events'; import { PythonFunction, PythonLayerVersion } from '@aws-cdk/aws-lambda-python-alpha'; import { HttpLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations'; import { HttpMethod, HttpRoute, HttpRouteKey } from 'aws-cdk-lib/aws-apigatewayv2'; import { ManagedPolicy, Role, ServicePrincipal } from 'aws-cdk-lib/aws-iam'; import { SRMApiGatewayConstruct } from './apigw/component'; import { Architecture } from 'aws-cdk-lib/aws-lambda'; -import { PostgresManagerStack } from '../../postgres_manager/deploy/postgres-manager-stack'; +import { PostgresManagerStack } from '../../postgres-manager/deploy/stack'; -export interface SequenceRunManagerProps { - securityGroups: ISecurityGroup[]; - vpc: IVpc; - mainBus: IEventBus; +export interface SequenceRunManagerStackProps { + lambdaSecurityGroupName: string; + vpcProps: VpcLookupOptions; + mainBusName: string; } export class SequenceRunManagerStack extends Stack { - private readonly secretId: string = PostgresManagerStack.formatDbSecretManagerName('sequence_run_manager'); - private readonly apiName: string = 'SequenceRunManager'; // apiNamespace `/srm/v1` is handled by Django Router + private readonly secretId: string = + PostgresManagerStack.formatDbSecretManagerName('sequence_run_manager'); + private readonly apiName: string = 'SequenceRunManager'; // apiNamespace `/srm/v1` is handled by Django Router private readonly id: string; - private readonly props: SequenceRunManagerProps; private readonly baseLayer: PythonLayerVersion; private readonly lambdaEnv; private readonly lambdaRuntimePythonVersion: aws_lambda.Runtime = aws_lambda.Runtime.PYTHON_3_12; private readonly lambdaRole: Role; + private readonly vpc: IVpc; + private readonly lambdaSG: ISecurityGroup; + private readonly mainBus: IEventBus; - constructor(scope: Construct, id: string, props: cdk.StackProps & SequenceRunManagerProps) { - super(scope, id); + constructor(scope: Construct, id: string, props: cdk.StackProps & SequenceRunManagerStackProps) { + super(scope, id, props); this.id = id; - this.props = props; + + this.mainBus = EventBus.fromEventBusName(this, 'OrcaBusMain', props.mainBusName); + this.vpc = Vpc.fromLookup(this, 'MainVpc', props.vpcProps); + this.lambdaSG = SecurityGroup.fromLookupByName( + this, + 'LambdaSecurityGroup', + props.lambdaSecurityGroupName, + this.vpc + ); this.lambdaRole = new Role(this, this.id + 'Role', { assumedBy: new ServicePrincipal('lambda.amazonaws.com'), @@ -42,21 +53,25 @@ export class SequenceRunManagerStack extends Stack { // we should improve this at some point down the track. // See https://github.com/umccr/orcabus/issues/174 this.lambdaRole.addManagedPolicy( - ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaBasicExecutionRole'), + ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaBasicExecutionRole') ); this.lambdaRole.addManagedPolicy( - ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaVPCAccessExecutionRole'), + ManagedPolicy.fromAwsManagedPolicyName('service-role/AWSLambdaVPCAccessExecutionRole') ); this.lambdaRole.addManagedPolicy( - ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMReadOnlyAccess'), + ManagedPolicy.fromAwsManagedPolicyName('AmazonSSMReadOnlyAccess') ); - const dbSecret = aws_secretsmanager.Secret.fromSecretNameV2(this, this.id + 'dbSecret', this.secretId); + const dbSecret = aws_secretsmanager.Secret.fromSecretNameV2( + this, + this.id + 'dbSecret', + this.secretId + ); dbSecret.grantRead(this.lambdaRole); this.lambdaEnv = { DJANGO_SETTINGS_MODULE: 'sequence_run_manager.settings.aws', - EVENT_BUS_NAME: this.props.mainBus.eventBusName, + EVENT_BUS_NAME: this.mainBus.eventBusName, SECRET_ID: this.secretId, }; @@ -77,9 +92,9 @@ export class SequenceRunManagerStack extends Stack { runtime: this.lambdaRuntimePythonVersion, layers: [this.baseLayer], environment: this.lambdaEnv, - securityGroups: this.props.securityGroups, - vpc: this.props.vpc, - vpcSubnets: { subnets: this.props.vpc.privateSubnets }, + securityGroups: [this.lambdaSG], + vpc: this.vpc, + vpcSubnets: { subnets: this.vpc.privateSubnets }, role: this.lambdaRole, architecture: Architecture.ARM_64, ...props, @@ -101,7 +116,12 @@ export class SequenceRunManagerStack extends Stack { timeout: Duration.seconds(28), }); - const srmApi = new SRMApiGatewayConstruct(this, this.id + 'SRMApiGatewayConstruct', this.apiName, this.region); + const srmApi = new SRMApiGatewayConstruct( + this, + this.id + 'SRMApiGatewayConstruct', + this.apiName, + this.region + ); const httpApi = srmApi.httpApi; const apiIntegration = new HttpLambdaIntegration(this.id + 'ApiIntegration', apiFn); @@ -120,7 +140,7 @@ export class SequenceRunManagerStack extends Stack { timeout: Duration.minutes(2), }); - this.props.mainBus.grantPutEventsTo(procSqsFn); + this.mainBus.grantPutEventsTo(procSqsFn); // this.setupEventRule(procSqsFn); // TODO comment this out for now } diff --git a/lib/workload/stateless/sequence_run_manager/deps/requirements-dev.txt b/lib/workload/stateless/stacks/sequence-run-manager/deps/requirements-dev.txt similarity index 100% rename from lib/workload/stateless/sequence_run_manager/deps/requirements-dev.txt rename to lib/workload/stateless/stacks/sequence-run-manager/deps/requirements-dev.txt diff --git a/lib/workload/stateless/sequence_run_manager/deps/requirements-test.txt b/lib/workload/stateless/stacks/sequence-run-manager/deps/requirements-test.txt similarity index 100% rename from lib/workload/stateless/sequence_run_manager/deps/requirements-test.txt rename to lib/workload/stateless/stacks/sequence-run-manager/deps/requirements-test.txt diff --git a/lib/workload/stateless/sequence_run_manager/deps/requirements.txt b/lib/workload/stateless/stacks/sequence-run-manager/deps/requirements.txt similarity index 100% rename from lib/workload/stateless/sequence_run_manager/deps/requirements.txt rename to lib/workload/stateless/stacks/sequence-run-manager/deps/requirements.txt diff --git a/lib/workload/stateless/sequence_run_manager/manage.py b/lib/workload/stateless/stacks/sequence-run-manager/manage.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/manage.py rename to lib/workload/stateless/stacks/sequence-run-manager/manage.py diff --git a/lib/workload/stateless/sequence_run_manager/migrate.py b/lib/workload/stateless/stacks/sequence-run-manager/migrate.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/migrate.py rename to lib/workload/stateless/stacks/sequence-run-manager/migrate.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/fields.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/fields.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/fields.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/fields.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/generate_mock_bssh_event.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/generate_mock_bssh_event.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/generate_mock_bssh_event.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/generate_mock_bssh_event.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/generate_mock_data.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/generate_mock_data.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/generate_mock_data.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/generate_mock_data.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/generate_mock_domain_event.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/generate_mock_domain_event.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/management/commands/generate_mock_domain_event.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/management/commands/generate_mock_domain_event.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/migrations/0001_initial.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/migrations/0001_initial.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/migrations/0001_initial.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/migrations/0001_initial.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/migrations/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/migrations/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/migrations/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/migrations/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/models/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/models/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/models/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/models/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/models/base.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/models/base.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/models/base.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/models/base.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/models/sequence.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/models/sequence.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/models/sequence.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/models/sequence.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/pagination.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/pagination.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/pagination.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/renderers.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/renderers.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/renderers.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/renderers.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/routers.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/routers.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/routers.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/routers.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/serializers.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/serializers.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/serializers.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/serializers.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/aws.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/aws.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/aws.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/aws.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/base.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/base.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/base.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/base.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/it.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/it.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/it.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/it.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/local.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/local.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/settings/local.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/settings/local.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/factories.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/factories.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/factories.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/factories.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/test_base.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/test_base.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/test_base.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/test_base.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/test_models.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/test_models.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/test_models.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/test_models.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/test_viewsets.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/test_viewsets.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/tests/test_viewsets.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/tests/test_viewsets.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/urls/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/urls/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/urls/base.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/base.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/urls/base.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/base.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/urls/local.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/local.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/urls/local.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/urls/local.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/viewsets/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/viewsets/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/viewsets/sequence.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/sequence.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/viewsets/sequence.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/viewsets/sequence.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager/wsgi.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/wsgi.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager/wsgi.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager/wsgi.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequence.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequence.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequence.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequence.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/AWSEvent.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/AWSEvent.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/AWSEvent.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/AWSEvent.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/SequenceRunStateChange.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/SequenceRunStateChange.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/SequenceRunStateChange.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/SequenceRunStateChange.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/marshaller.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/marshaller.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/domain/sequencerunstatechange/marshaller.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/domain/sequencerunstatechange/marshaller.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/lambdas/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/lambdas/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/lambdas/bssh_event.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/bssh_event.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/lambdas/bssh_event.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/lambdas/bssh_event.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/services/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/services/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/services/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/services/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/services/sequence_srv.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/services/sequence_srv.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/services/sequence_srv.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/services/sequence_srv.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/__init__.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/__init__.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/__init__.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/__init__.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/case.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/case.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/case.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/case.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/test_bssh_event.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/test_bssh_event.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/test_bssh_event.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/test_bssh_event.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/test_sequence_domain.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/test_sequence_domain.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/test_sequence_domain.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/test_sequence_domain.py diff --git a/lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/test_sequence_srv.py b/lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/test_sequence_srv.py similarity index 100% rename from lib/workload/stateless/sequence_run_manager/sequence_run_manager_proc/tests/test_sequence_srv.py rename to lib/workload/stateless/stacks/sequence-run-manager/sequence_run_manager_proc/tests/test_sequence_srv.py diff --git a/lib/workload/stateless/statelessStackCollectionClass.ts b/lib/workload/stateless/statelessStackCollectionClass.ts new file mode 100644 index 000000000..f5ed3127b --- /dev/null +++ b/lib/workload/stateless/statelessStackCollectionClass.ts @@ -0,0 +1,75 @@ +import { Construct } from 'constructs'; +import { Stack, Environment, StackProps } from 'aws-cdk-lib'; + +import { FilemanagerProps, Filemanager } from './stacks/filemanager/deploy/lib/filemanager'; +import { + PostgresManagerStack, + PostgresManagerStackProps, +} from './stacks/postgres-manager/deploy/stack'; +import { + MetadataManagerStack, + MetadataManagerStackProps, +} from './stacks/metadata-manager/deploy/stack'; +import { + SequenceRunManagerStack, + SequenceRunManagerStackProps, +} from './stacks/sequence-run-manager/deploy/component'; + +export interface StatelessStackCollectionProps { + postgresManagerStackProps: PostgresManagerStackProps; + metadataManagerStackProps: MetadataManagerStackProps; + sequenceRunManagerStackProps: SequenceRunManagerStackProps; + fileManagerStackProps: FilemanagerProps; +} + +export class StatelessStackCollection { + // You could add more stack here and initiate it at the constructor. See example below for reference + readonly postgresManagerStack: Stack; + readonly fileManagerStack: Stack; + readonly metadataManagerStack: Stack; + readonly sequenceRunManagerStack: Stack; + + constructor( + scope: Construct, + env: Environment, + statefulConfiguration: StatelessStackCollectionProps + ) { + this.postgresManagerStack = new PostgresManagerStack(scope, 'PostgresManagerStack', { + ...this.createTemplateProps(env, 'PostgresManagerStack'), + ...statefulConfiguration.postgresManagerStackProps, + }); + + this.fileManagerStack = new Filemanager(scope, 'FileManagerStack', { + ...this.createTemplateProps(env, 'FileManagerStack'), + ...statefulConfiguration.fileManagerStackProps, + }); + + this.metadataManagerStack = new MetadataManagerStack(scope, 'MetadataManagerStack', { + ...this.createTemplateProps(env, 'MetadataManagerStack'), + ...statefulConfiguration.metadataManagerStackProps, + }); + + this.sequenceRunManagerStack = new SequenceRunManagerStack(scope, 'SequenceRunManagerStack', { + ...this.createTemplateProps(env, 'SequenceRunManagerStack'), + ...statefulConfiguration.sequenceRunManagerStackProps, + }); + } + + /** + * This output the StackProps that each stack should have on deployment + * + * @param env The environment which each stack should deploy to + * @param serviceName The service name + * @returns StackProps that will be included as template + */ + private createTemplateProps(env: Environment, serviceName: string): StackProps { + return { + env: env, + tags: { + 'umccr-org:Product': 'OrcaBus', + 'umccr-org:Creator': 'CDK', + 'umccr-org:Service': serviceName, + }, + }; + } +} diff --git a/package.json b/package.json index b81716401..9fc94caef 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "lint-fix": "eslint --fix .", "prettier": "prettier --check .", "prettier-fix": "prettier --write .", - "cdk-stateless": "cdk --app 'yarn run -B ts-node --prefer-ts-exts bin/stateless-pipeline.ts'", + "cdk-stateless": "cdk --app 'yarn run -B ts-node --prefer-ts-exts bin/statelessPipeline.ts'", "cdk-stateful": "cdk --app 'yarn run -B ts-node --prefer-ts-exts bin/statefulPipeline.ts'" }, "dependencies": { diff --git a/test/stateless/stateless-deployment.test.ts b/test/stateless/deployment.test.ts similarity index 50% rename from test/stateless/stateless-deployment.test.ts rename to test/stateless/deployment.test.ts index 62882e047..f3f21c14b 100644 --- a/test/stateless/stateless-deployment.test.ts +++ b/test/stateless/deployment.test.ts @@ -2,8 +2,8 @@ import { App, Aspects, Stack } from 'aws-cdk-lib'; import { Annotations, Match } from 'aws-cdk-lib/assertions'; import { SynthesisMessage } from 'aws-cdk-lib/cx-api'; import { AwsSolutionsChecks, NagSuppressions } from 'cdk-nag'; -import { OrcaBusStatelessStack } from '../../lib/workload/orcabus-stateless-stack'; import { getEnvironmentConfig } from '../../config/constants'; +import { StatelessStackCollection } from '../../lib/workload/stateless/statelessStackCollectionClass'; function synthesisMessageToString(sm: SynthesisMessage): string { return `${sm.entry.data} [${sm.id}]`; @@ -14,53 +14,38 @@ const config = getEnvironmentConfig('prod')!; describe('cdk-nag-stateless-stack', () => { const app: App = new App({}); - const stack: OrcaBusStatelessStack = new OrcaBusStatelessStack(app, 'TestStack', { - env: { - account: '12345678', + + const stackCollection = new StatelessStackCollection( + app, + { + account: '123456789', region: 'ap-southeast-2', }, - ...config.stackProps.orcaBusStatelessConfig, - }); - - // stateless stack cdk-nag test - Aspects.of(stack).add(new AwsSolutionsChecks()); - applyNagSuppression(stack.node.id, stack); - - test(`OrcaBusStatelessStack: cdk-nag AwsSolutions Pack errors`, () => { - const errors = Annotations.fromStack(stack) - .findError('*', Match.stringLikeRegexp('AwsSolutions-.*')) - .map(synthesisMessageToString); - expect(errors).toHaveLength(0); - }); - - test(`OrcaBusStatelessStack: cdk-nag AwsSolutions Pack warnings`, () => { - const warnings = Annotations.fromStack(stack) - .findWarning('*', Match.stringLikeRegexp('AwsSolutions-.*')) - .map(synthesisMessageToString); - expect(warnings).toHaveLength(0); - }); - - // microservice cdk-nag test - for (const ms_stack of stack.microserviceStackArray) { - const stackId = ms_stack.node.id; - - Aspects.of(ms_stack).add(new AwsSolutionsChecks()); - - applyNagSuppression(stackId, ms_stack); - - test(`${stackId}: cdk-nag AwsSolutions Pack errors`, () => { - const errors = Annotations.fromStack(ms_stack) - .findError('*', Match.stringLikeRegexp('AwsSolutions-.*')) - .map(synthesisMessageToString); - expect(errors).toHaveLength(0); - }); + config.stackProps.statelessConfig + ); - test(`${stackId}: cdk-nag AwsSolutions Pack warnings`, () => { - const warnings = Annotations.fromStack(ms_stack) - .findWarning('*', Match.stringLikeRegexp('AwsSolutions-.*')) - .map(synthesisMessageToString); - expect(warnings).toHaveLength(0); - }); + for (const key in stackCollection) { + if (Object.prototype.hasOwnProperty.call(stackCollection, key)) { + const stack = stackCollection[key as keyof StatelessStackCollection]; + const stackId = stack.node.id; + + Aspects.of(stack).add(new AwsSolutionsChecks()); + applyNagSuppression(stackId, stack); + + test(`${stackId}: cdk-nag AwsSolutions Pack errors`, () => { + const errors = Annotations.fromStack(stack) + .findError('*', Match.stringLikeRegexp('AwsSolutions-.*')) + .map(synthesisMessageToString); + expect(errors).toHaveLength(0); + }); + + test(`${stackId}: cdk-nag AwsSolutions Pack warnings`, () => { + const warnings = Annotations.fromStack(stack) + .findWarning('*', Match.stringLikeRegexp('AwsSolutions-.*')) + .map(synthesisMessageToString); + expect(warnings).toHaveLength(0); + }); + } } }); @@ -113,22 +98,7 @@ function applyNagSuppression(stackId: string, stack: Stack) { // for each stack specific switch (stackId) { - case 'PostgresManager': - // suppress by resource - NagSuppressions.addResourceSuppressionsByPath( - stack, - `/TestStack/PostgresManager/CreateUserPassPostgresLambda/ServiceRole/DefaultPolicy/Resource`, - [ - { - id: 'AwsSolutions-IAM5', - reason: - "'*' is required for secretsmanager:GetRandomPassword and new SM ARN will contain random character", - }, - ] - ); - break; - - case 'Filemanager': + case 'FileManagerStack': NagSuppressions.addResourceSuppressions( stack, [ @@ -142,7 +112,7 @@ function applyNagSuppression(stackId: string, stack: Stack) { ); NagSuppressions.addResourceSuppressionsByPath( stack, - `/TestStack/Filemanager/MigrateProviderFunction/Provider/framework-onEvent/ServiceRole/DefaultPolicy/Resource`, + `/FileManagerStack/MigrateProviderFunction/Provider/framework-onEvent/ServiceRole/DefaultPolicy/Resource`, [ { id: 'AwsSolutions-IAM5', diff --git a/test/stateless/stateless-pipeline.test.ts b/test/stateless/pipeline.test.ts similarity index 88% rename from test/stateless/stateless-pipeline.test.ts rename to test/stateless/pipeline.test.ts index e499e609e..cabb8690d 100644 --- a/test/stateless/stateless-pipeline.test.ts +++ b/test/stateless/pipeline.test.ts @@ -2,13 +2,13 @@ import { App, Aspects, Stack } from 'aws-cdk-lib'; import { Annotations, Match } from 'aws-cdk-lib/assertions'; import { SynthesisMessage } from 'aws-cdk-lib/cx-api'; import { AwsSolutionsChecks, NagSuppressions } from 'cdk-nag'; -import { StatelessPipelineStack } from '../../lib/pipeline/orcabus-stateless-pipeline-stack'; +import { StatelessPipelineStack } from '../../lib/pipeline/statelessPipelineStack'; // we are mocking the deployment stack here, as we have a dedicated cdk-nag test for deployment stack // see the ./stateless-deployment.test.ts -jest.mock('../../lib/workload/orcabus-stateless-stack', () => { +jest.mock('../../lib/workload/stateless/statelessStackCollectionClass', () => { return { - OrcaBusStatelessStack: jest.fn().mockImplementation((value) => { + StatelessStackCollection: jest.fn().mockImplementation((value) => { return new Stack(value, 'mockStack', {}); }), };