@digitraffic/common 2024.1.10-1 → 2024.1.23-1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/aws/infra/api/{handler-factory.d.ts → handler-factory.d.mts} +2 -2
- package/dist/aws/infra/api/{handler-factory.js → handler-factory.mjs} +5 -10
- package/dist/aws/infra/api/{integration.d.ts → integration.d.mts} +1 -1
- package/dist/aws/infra/api/{integration.js → integration.mjs} +10 -14
- package/dist/aws/infra/api/{response.d.ts → response.d.mts} +2 -3
- package/dist/aws/infra/api/{response.js → response.mjs} +26 -31
- package/dist/aws/infra/api/{responses.d.ts → responses.d.mts} +2 -3
- package/dist/aws/infra/api/responses.mjs +78 -0
- package/dist/aws/infra/api/{static-integration.d.ts → static-integration.d.mts} +1 -1
- package/dist/aws/infra/api/{static-integration.js → static-integration.mjs} +8 -12
- package/dist/aws/infra/canaries/{canary-alarm.d.ts → canary-alarm.d.mts} +1 -1
- package/dist/aws/infra/canaries/canary-alarm.mjs +20 -0
- package/dist/aws/infra/canaries/canary-keys.mjs +4 -0
- package/dist/aws/infra/canaries/canary-parameters.mjs +2 -0
- package/dist/aws/infra/canaries/{canary-role.js → canary-role.mjs} +9 -13
- package/dist/aws/infra/canaries/{canary.d.ts → canary.d.mts} +2 -2
- package/dist/aws/infra/canaries/canary.mjs +26 -0
- package/dist/aws/infra/canaries/{database-canary.d.ts → database-canary.d.mts} +3 -3
- package/dist/aws/infra/canaries/{database-canary.js → database-canary.mjs} +9 -13
- package/dist/aws/infra/canaries/{database-checker.d.ts → database-checker.d.mts} +1 -1
- package/dist/aws/infra/canaries/{database-checker.js → database-checker.mjs} +12 -18
- package/dist/aws/infra/canaries/{url-canary.d.ts → url-canary.d.mts} +4 -4
- package/dist/aws/infra/canaries/{url-canary.js → url-canary.mjs} +9 -13
- package/dist/aws/infra/canaries/{url-checker.d.ts → url-checker.d.mts} +2 -2
- package/dist/aws/infra/canaries/{url-checker.js → url-checker.mjs} +35 -42
- package/dist/aws/infra/{documentation.js → documentation.mjs} +9 -17
- package/dist/aws/infra/{import-util.js → import-util.mjs} +11 -19
- package/dist/aws/infra/scheduler.mjs +27 -0
- package/dist/aws/infra/{security-rule.js → security-rule.mjs} +5 -9
- package/dist/aws/infra/{sqs-integration.d.ts → sqs-integration.d.mts} +1 -2
- package/dist/aws/infra/{sqs-integration.js → sqs-integration.mjs} +12 -16
- package/dist/aws/infra/{sqs-queue.d.ts → sqs-queue.d.mts} +1 -1
- package/dist/aws/infra/{sqs-queue.js → sqs-queue.mjs} +33 -41
- package/dist/aws/infra/stack/{lambda-configs.d.ts → lambda-configs.d.mts} +2 -2
- package/dist/aws/infra/stack/{lambda-configs.js → lambda-configs.mjs} +15 -21
- package/dist/aws/infra/stack/{monitoredfunction.d.ts → monitoredfunction.d.mts} +3 -3
- package/dist/aws/infra/stack/{monitoredfunction.js → monitoredfunction.mjs} +20 -28
- package/dist/aws/infra/stack/{parameters.d.ts → parameters.d.mts} +1 -1
- package/dist/aws/infra/stack/{parameters.js → parameters.mjs} +6 -11
- package/dist/aws/infra/stack/{rest_apis.d.ts → rest_apis.d.mts} +3 -3
- package/dist/aws/infra/stack/{rest_apis.js → rest_apis.mjs} +42 -55
- package/dist/aws/infra/stack/{stack-checking-aspect.d.ts → stack-checking-aspect.d.mts} +1 -1
- package/dist/aws/infra/stack/{stack-checking-aspect.js → stack-checking-aspect.mjs} +25 -32
- package/dist/aws/infra/stack/{stack.d.ts → stack.d.mts} +3 -4
- package/dist/aws/infra/stack/stack.mjs +63 -0
- package/dist/aws/infra/stack/{subscription.d.ts → subscription.d.mts} +2 -2
- package/dist/aws/infra/stack/{subscription.js → subscription.mjs} +6 -11
- package/dist/aws/infra/stacks/{db-dns-stack.d.ts → db-dns-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/db-dns-stack.mjs +60 -0
- package/dist/aws/infra/stacks/{db-proxy-stack.d.ts → db-proxy-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/db-proxy-stack.mjs +73 -0
- package/dist/aws/infra/stacks/{db-stack.d.ts → db-stack.d.mts} +3 -4
- package/dist/aws/infra/stacks/{db-stack.js → db-stack.mjs} +31 -35
- package/dist/aws/infra/stacks/intra-stack-configuration.mjs +2 -0
- package/dist/aws/infra/stacks/{network-stack.d.ts → network-stack.d.mts} +2 -2
- package/dist/aws/infra/stacks/network-stack.mjs +40 -0
- package/dist/aws/infra/{usage-plans.js → usage-plans.mjs} +3 -8
- package/dist/aws/runtime/apikey.mjs +9 -0
- package/dist/aws/runtime/{digitraffic-integration-response.d.ts → digitraffic-integration-response.d.mts} +1 -1
- package/dist/aws/runtime/digitraffic-integration-response.mjs +24 -0
- package/dist/aws/runtime/{dt-logger-default.d.ts → dt-logger-default.d.mts} +2 -2
- package/dist/aws/runtime/dt-logger-default.mjs +6 -0
- package/dist/aws/runtime/{dt-logger.d.ts → dt-logger.d.mts} +1 -1
- package/dist/aws/runtime/{dt-logger.js → dt-logger.mjs} +4 -11
- package/dist/aws/runtime/{environment.js → environment.mjs} +4 -8
- package/dist/aws/runtime/{messaging.js → messaging.mjs} +2 -6
- package/dist/aws/runtime/{s3.js → s3.mjs} +4 -8
- package/dist/aws/runtime/secrets/{dbsecret.d.ts → dbsecret.d.mts} +1 -1
- package/dist/aws/runtime/secrets/{dbsecret.js → dbsecret.mjs} +6 -10
- package/dist/aws/runtime/secrets/proxy-holder.mjs +24 -0
- package/dist/aws/runtime/secrets/rds-holder.mjs +24 -0
- package/dist/aws/runtime/secrets/{secret-holder.d.ts → secret-holder.d.mts} +1 -1
- package/dist/aws/runtime/secrets/{secret-holder.js → secret-holder.mjs} +14 -19
- package/dist/aws/runtime/secrets/{secret.js → secret.mjs} +8 -12
- package/dist/aws/types/errors.mjs +12 -0
- package/dist/aws/types/{lambda-response.js → lambda-response.mjs} +4 -11
- package/dist/aws/types/{mediatypes.js → mediatypes.mjs} +3 -6
- package/dist/aws/types/model-with-reference.mjs +2 -0
- package/dist/aws/types/proxytypes.mjs +2 -0
- package/dist/aws/types/tags.mjs +4 -0
- package/dist/database/{cached.d.ts → cached.d.mts} +1 -1
- package/dist/database/{cached.js → cached.mjs} +10 -15
- package/dist/database/{database.d.ts → database.d.mts} +1 -1
- package/dist/database/{database.js → database.mjs} +17 -24
- package/dist/database/{last-updated.d.ts → last-updated.d.mts} +1 -1
- package/dist/database/{last-updated.js → last-updated.mjs} +9 -18
- package/dist/database/models.mjs +2 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.mjs +2 -0
- package/dist/marine/{id_utils.js → id_utils.mjs} +4 -10
- package/dist/marine/rtz.mjs +2 -0
- package/dist/test/{asserter.js → asserter.mjs} +2 -6
- package/dist/test/{db-testutils.d.ts → db-testutils.d.mts} +1 -1
- package/dist/test/db-testutils.mjs +29 -0
- package/dist/test/{httpserver.js → httpserver.mjs} +11 -15
- package/dist/test/secrets-manager.mjs +34 -0
- package/dist/test/testutils.mjs +33 -0
- package/dist/types/async-timeout-error.mjs +6 -0
- package/dist/types/aws-env.mjs +2 -0
- package/dist/types/either.mjs +2 -0
- package/dist/types/http-error.mjs +7 -0
- package/dist/types/input-error.mjs +3 -0
- package/dist/types/language.mjs +7 -0
- package/dist/types/{nullable.d.ts → nullable.d.mts} +1 -1
- package/dist/types/nullable.mjs +2 -0
- package/dist/types/{traffictype.js → traffictype.mjs} +3 -6
- package/dist/types/urn.mjs +2 -0
- package/dist/types/util-types.mjs +2 -0
- package/dist/types/validator.mjs +9 -0
- package/dist/utils/{api-model.d.ts → api-model.d.mts} +1 -1
- package/dist/utils/{api-model.js → api-model.mjs} +18 -28
- package/dist/utils/{base64.d.ts → base64.d.mts} +1 -1
- package/dist/utils/base64.mjs +16 -0
- package/dist/utils/date-utils.mjs +44 -0
- package/dist/utils/geojson-types.mjs +13 -0
- package/dist/utils/{geometry.js → geometry.mjs} +16 -49
- package/dist/utils/{logging.d.ts → logging.d.mts} +1 -1
- package/dist/utils/{logging.js → logging.mjs} +9 -14
- package/dist/utils/{retry.js → retry.mjs} +22 -27
- package/dist/utils/slack.mjs +23 -0
- package/dist/utils/{utils.d.ts → utils.d.mts} +2 -2
- package/dist/utils/{utils.js → utils.mjs} +15 -30
- package/package.json +99 -10
- package/src/aws/infra/api/{handler-factory.ts → handler-factory.mts} +3 -3
- package/src/aws/infra/api/{integration.ts → integration.mts} +2 -2
- package/src/aws/infra/api/{response.ts → response.mts} +3 -3
- package/src/aws/infra/api/{responses.ts → responses.mts} +4 -4
- package/src/aws/infra/api/{static-integration.ts → static-integration.mts} +2 -2
- package/src/aws/infra/canaries/Synthetics.d.mts +21 -0
- package/src/aws/infra/canaries/{canary-alarm.ts → canary-alarm.mts} +1 -1
- package/src/aws/infra/canaries/{canary.ts → canary.mts} +3 -3
- package/src/aws/infra/canaries/{database-canary.ts → database-canary.mts} +3 -3
- package/src/aws/infra/canaries/{database-checker.ts → database-checker.mts} +7 -10
- package/src/aws/infra/canaries/{url-canary.ts → url-canary.mts} +6 -6
- package/src/aws/infra/canaries/{url-checker.ts → url-checker.mts} +9 -29
- package/src/aws/infra/{sqs-integration.ts → sqs-integration.mts} +1 -1
- package/src/aws/infra/{sqs-queue.ts → sqs-queue.mts} +3 -6
- package/src/aws/infra/stack/{lambda-configs.ts → lambda-configs.mts} +2 -2
- package/src/aws/infra/stack/{monitoredfunction.ts → monitoredfunction.mts} +4 -4
- package/src/aws/infra/stack/{parameters.ts → parameters.mts} +1 -1
- package/src/aws/infra/stack/{rest_apis.ts → rest_apis.mts} +6 -6
- package/src/aws/infra/stack/{stack-checking-aspect.ts → stack-checking-aspect.mts} +1 -1
- package/src/aws/infra/stack/{stack.ts → stack.mts} +4 -5
- package/src/aws/infra/stack/{subscription.ts → subscription.mts} +2 -2
- package/src/aws/infra/stacks/{db-dns-stack.ts → db-dns-stack.mts} +4 -4
- package/src/aws/infra/stacks/{db-proxy-stack.ts → db-proxy-stack.mts} +5 -5
- package/src/aws/infra/stacks/{db-stack.ts → db-stack.mts} +5 -5
- package/src/aws/infra/stacks/{network-stack.ts → network-stack.mts} +3 -3
- package/src/aws/runtime/{digitraffic-integration-response.ts → digitraffic-integration-response.mts} +2 -2
- package/src/aws/runtime/{dt-logger-default.ts → dt-logger-default.mts} +2 -2
- package/src/aws/runtime/secrets/{dbsecret.ts → dbsecret.mts} +1 -1
- package/src/aws/runtime/secrets/node-ttl.d.mts +12 -0
- package/src/aws/runtime/secrets/{proxy-holder.ts → proxy-holder.mts} +4 -4
- package/src/aws/runtime/secrets/{rds-holder.ts → rds-holder.mts} +4 -4
- package/src/aws/runtime/secrets/{secret-holder.ts → secret-holder.mts} +8 -9
- package/src/aws/runtime/secrets/{secret.ts → secret.mts} +2 -2
- package/src/database/{cached.ts → cached.mts} +4 -2
- package/src/database/{database.ts → database.mts} +6 -6
- package/src/database/{last-updated.ts → last-updated.mts} +1 -1
- package/src/index.mts +2 -0
- package/src/test/{db-testutils.ts → db-testutils.mts} +2 -2
- package/src/test/{secrets-manager.ts → secrets-manager.mts} +3 -3
- package/src/types/{nullable.ts → nullable.mts} +1 -1
- package/src/utils/{api-model.ts → api-model.mts} +1 -1
- package/src/utils/{geometry.ts → geometry.mts} +5 -3
- package/src/utils/{logging.ts → logging.mts} +2 -2
- package/src/utils/{retry.ts → retry.mts} +3 -3
- package/src/utils/{slack.ts → slack.mts} +2 -2
- package/src/utils/{utils.ts → utils.mts} +3 -3
- package/dist/aws/infra/api/responses.js +0 -84
- package/dist/aws/infra/canaries/canary-alarm.js +0 -24
- package/dist/aws/infra/canaries/canary-keys.js +0 -7
- package/dist/aws/infra/canaries/canary-parameters.js +0 -3
- package/dist/aws/infra/canaries/canary.js +0 -30
- package/dist/aws/infra/scheduler.js +0 -31
- package/dist/aws/infra/stack/stack.js +0 -67
- package/dist/aws/infra/stacks/db-dns-stack.js +0 -64
- package/dist/aws/infra/stacks/db-proxy-stack.js +0 -77
- package/dist/aws/infra/stacks/intra-stack-configuration.js +0 -3
- package/dist/aws/infra/stacks/network-stack.js +0 -44
- package/dist/aws/runtime/apikey.js +0 -13
- package/dist/aws/runtime/digitraffic-integration-response.js +0 -28
- package/dist/aws/runtime/dt-logger-default.js +0 -9
- package/dist/aws/runtime/secrets/proxy-holder.js +0 -28
- package/dist/aws/runtime/secrets/rds-holder.js +0 -28
- package/dist/aws/types/errors.js +0 -16
- package/dist/aws/types/model-with-reference.js +0 -3
- package/dist/aws/types/proxytypes.js +0 -3
- package/dist/aws/types/tags.js +0 -7
- package/dist/database/models.js +0 -3
- package/dist/marine/rtz.js +0 -3
- package/dist/test/db-testutils.js +0 -34
- package/dist/test/secrets-manager.js +0 -62
- package/dist/test/testutils.js +0 -44
- package/dist/types/async-timeout-error.js +0 -10
- package/dist/types/aws-env.js +0 -3
- package/dist/types/either.js +0 -3
- package/dist/types/http-error.js +0 -11
- package/dist/types/input-error.js +0 -7
- package/dist/types/language.js +0 -10
- package/dist/types/nullable.js +0 -3
- package/dist/types/urn.js +0 -3
- package/dist/types/util-types.js +0 -3
- package/dist/types/validator.js +0 -14
- package/dist/utils/base64.js +0 -21
- package/dist/utils/date-utils.js +0 -51
- package/dist/utils/geojson-types.js +0 -18
- package/dist/utils/slack.js +0 -30
- /package/dist/aws/infra/canaries/{canary-keys.d.ts → canary-keys.d.mts} +0 -0
- /package/dist/aws/infra/canaries/{canary-parameters.d.ts → canary-parameters.d.mts} +0 -0
- /package/dist/aws/infra/canaries/{canary-role.d.ts → canary-role.d.mts} +0 -0
- /package/dist/aws/infra/{documentation.d.ts → documentation.d.mts} +0 -0
- /package/dist/aws/infra/{import-util.d.ts → import-util.d.mts} +0 -0
- /package/dist/aws/infra/{scheduler.d.ts → scheduler.d.mts} +0 -0
- /package/dist/aws/infra/{security-rule.d.ts → security-rule.d.mts} +0 -0
- /package/dist/aws/infra/stacks/{intra-stack-configuration.d.ts → intra-stack-configuration.d.mts} +0 -0
- /package/dist/aws/infra/{usage-plans.d.ts → usage-plans.d.mts} +0 -0
- /package/dist/aws/runtime/{apikey.d.ts → apikey.d.mts} +0 -0
- /package/dist/aws/runtime/{environment.d.ts → environment.d.mts} +0 -0
- /package/dist/aws/runtime/{messaging.d.ts → messaging.d.mts} +0 -0
- /package/dist/aws/runtime/{s3.d.ts → s3.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{proxy-holder.d.ts → proxy-holder.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{rds-holder.d.ts → rds-holder.d.mts} +0 -0
- /package/dist/aws/runtime/secrets/{secret.d.ts → secret.d.mts} +0 -0
- /package/dist/aws/types/{errors.d.ts → errors.d.mts} +0 -0
- /package/dist/aws/types/{lambda-response.d.ts → lambda-response.d.mts} +0 -0
- /package/dist/aws/types/{mediatypes.d.ts → mediatypes.d.mts} +0 -0
- /package/dist/aws/types/{model-with-reference.d.ts → model-with-reference.d.mts} +0 -0
- /package/dist/aws/types/{proxytypes.d.ts → proxytypes.d.mts} +0 -0
- /package/dist/aws/types/{tags.d.ts → tags.d.mts} +0 -0
- /package/dist/database/{models.d.ts → models.d.mts} +0 -0
- /package/dist/marine/{id_utils.d.ts → id_utils.d.mts} +0 -0
- /package/dist/marine/{rtz.d.ts → rtz.d.mts} +0 -0
- /package/dist/test/{asserter.d.ts → asserter.d.mts} +0 -0
- /package/dist/test/{httpserver.d.ts → httpserver.d.mts} +0 -0
- /package/dist/test/{secrets-manager.d.ts → secrets-manager.d.mts} +0 -0
- /package/dist/test/{testutils.d.ts → testutils.d.mts} +0 -0
- /package/dist/types/{async-timeout-error.d.ts → async-timeout-error.d.mts} +0 -0
- /package/dist/types/{aws-env.d.ts → aws-env.d.mts} +0 -0
- /package/dist/types/{either.d.ts → either.d.mts} +0 -0
- /package/dist/types/{http-error.d.ts → http-error.d.mts} +0 -0
- /package/dist/types/{input-error.d.ts → input-error.d.mts} +0 -0
- /package/dist/types/{language.d.ts → language.d.mts} +0 -0
- /package/dist/types/{traffictype.d.ts → traffictype.d.mts} +0 -0
- /package/dist/types/{urn.d.ts → urn.d.mts} +0 -0
- /package/dist/types/{util-types.d.ts → util-types.d.mts} +0 -0
- /package/dist/types/{validator.d.ts → validator.d.mts} +0 -0
- /package/dist/utils/{date-utils.d.ts → date-utils.d.mts} +0 -0
- /package/dist/utils/{geojson-types.d.ts → geojson-types.d.mts} +0 -0
- /package/dist/utils/{geometry.d.ts → geometry.d.mts} +0 -0
- /package/dist/utils/{retry.d.ts → retry.d.mts} +0 -0
- /package/dist/utils/{slack.d.ts → slack.d.mts} +0 -0
- /package/src/@types/geojson-validation/{index.d.ts → index.d.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-keys.ts → canary-keys.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-parameters.ts → canary-parameters.mts} +0 -0
- /package/src/aws/infra/canaries/{canary-role.ts → canary-role.mts} +0 -0
- /package/src/aws/infra/{documentation.ts → documentation.mts} +0 -0
- /package/src/aws/infra/{import-util.ts → import-util.mts} +0 -0
- /package/src/aws/infra/{scheduler.ts → scheduler.mts} +0 -0
- /package/src/aws/infra/{security-rule.ts → security-rule.mts} +0 -0
- /package/src/aws/infra/stacks/{intra-stack-configuration.ts → intra-stack-configuration.mts} +0 -0
- /package/src/aws/infra/{usage-plans.ts → usage-plans.mts} +0 -0
- /package/src/aws/runtime/{apikey.ts → apikey.mts} +0 -0
- /package/src/aws/runtime/{dt-logger.ts → dt-logger.mts} +0 -0
- /package/src/aws/runtime/{environment.ts → environment.mts} +0 -0
- /package/src/aws/runtime/{messaging.ts → messaging.mts} +0 -0
- /package/src/aws/runtime/{s3.ts → s3.mts} +0 -0
- /package/src/aws/types/{errors.ts → errors.mts} +0 -0
- /package/src/aws/types/{lambda-response.ts → lambda-response.mts} +0 -0
- /package/src/aws/types/{mediatypes.ts → mediatypes.mts} +0 -0
- /package/src/aws/types/{model-with-reference.ts → model-with-reference.mts} +0 -0
- /package/src/aws/types/{proxytypes.ts → proxytypes.mts} +0 -0
- /package/src/aws/types/{tags.ts → tags.mts} +0 -0
- /package/src/database/{models.ts → models.mts} +0 -0
- /package/src/marine/{id_utils.ts → id_utils.mts} +0 -0
- /package/src/marine/{rtz.ts → rtz.mts} +0 -0
- /package/src/test/{asserter.ts → asserter.mts} +0 -0
- /package/src/test/{httpserver.ts → httpserver.mts} +0 -0
- /package/src/test/{testutils.ts → testutils.mts} +0 -0
- /package/src/types/{async-timeout-error.ts → async-timeout-error.mts} +0 -0
- /package/src/types/{aws-env.ts → aws-env.mts} +0 -0
- /package/src/types/{either.ts → either.mts} +0 -0
- /package/src/types/{http-error.ts → http-error.mts} +0 -0
- /package/src/types/{input-error.ts → input-error.mts} +0 -0
- /package/src/types/{language.ts → language.mts} +0 -0
- /package/src/types/{traffictype.ts → traffictype.mts} +0 -0
- /package/src/types/{urn.ts → urn.mts} +0 -0
- /package/src/types/{util-types.ts → util-types.mts} +0 -0
- /package/src/types/{validator.ts → validator.mts} +0 -0
- /package/src/utils/{base64.ts → base64.mts} +0 -0
- /package/src/utils/{date-utils.ts → date-utils.mts} +0 -0
- /package/src/utils/{geojson-types.ts → geojson-types.mts} +0 -0
@@ -1,5 +1,5 @@
|
|
1
1
|
import { IAspect } from "aws-cdk-lib";
|
2
|
-
import { DigitrafficStack } from "./stack";
|
2
|
+
import { DigitrafficStack } from "./stack.mjs";
|
3
3
|
import { IConstruct } from "constructs";
|
4
4
|
export declare class StackCheckingAspect implements IAspect {
|
5
5
|
private readonly stackShortName?;
|
@@ -1,20 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
};
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
const stack_1 = require("./stack");
|
11
|
-
const aws_apigateway_1 = require("aws-cdk-lib/aws-apigateway");
|
12
|
-
const aws_sqs_1 = require("aws-cdk-lib/aws-sqs");
|
13
|
-
const aws_logs_1 = require("aws-cdk-lib/aws-logs");
|
14
|
-
const change_case_1 = require("change-case");
|
15
|
-
const lodash_1 = __importDefault(require("lodash"));
|
1
|
+
import { Annotations, Stack } from "aws-cdk-lib";
|
2
|
+
import { CfnFunction, Runtime } from "aws-cdk-lib/aws-lambda";
|
3
|
+
import { CfnBucket } from "aws-cdk-lib/aws-s3";
|
4
|
+
import { DigitrafficStack, SOLUTION_KEY } from "./stack.mjs";
|
5
|
+
import { CfnMethod, CfnResource } from "aws-cdk-lib/aws-apigateway";
|
6
|
+
import { CfnQueue } from "aws-cdk-lib/aws-sqs";
|
7
|
+
import { LogRetention } from "aws-cdk-lib/aws-logs";
|
8
|
+
import { kebabCase } from "change-case";
|
9
|
+
import _ from "lodash";
|
16
10
|
const MAX_CONCURRENCY_LIMIT = 100;
|
17
|
-
const NODE_RUNTIMES = [
|
11
|
+
const NODE_RUNTIMES = [Runtime.NODEJS_20_X.name, Runtime.NODEJS_18_X.name];
|
18
12
|
var ResourceType;
|
19
13
|
(function (ResourceType) {
|
20
14
|
ResourceType["stackName"] = "STACK_NAME";
|
@@ -29,7 +23,7 @@ var ResourceType;
|
|
29
23
|
ResourceType["queueEncryption"] = "QUEUE_ENCRYPTION";
|
30
24
|
ResourceType["logGroupRetention"] = "LOG_GROUP_RETENTION";
|
31
25
|
})(ResourceType || (ResourceType = {}));
|
32
|
-
class StackCheckingAspect {
|
26
|
+
export class StackCheckingAspect {
|
33
27
|
constructor(stackShortName, whitelistedResources) {
|
34
28
|
this.stackShortName = stackShortName;
|
35
29
|
this.whitelistedResources = whitelistedResources;
|
@@ -59,14 +53,14 @@ class StackCheckingAspect {
|
|
59
53
|
// error && whitelisted -> warning
|
60
54
|
// warning && whitelisted -> nothing
|
61
55
|
if (isError && !isWhiteListed) {
|
62
|
-
|
56
|
+
Annotations.of(node).addError(annotationMessage);
|
63
57
|
}
|
64
58
|
else if ((!isError && !isWhiteListed) || (isError && isWhiteListed)) {
|
65
|
-
|
59
|
+
Annotations.of(node).addWarning(annotationMessage);
|
66
60
|
}
|
67
61
|
}
|
68
62
|
checkStack(node) {
|
69
|
-
if (node instanceof
|
63
|
+
if (node instanceof DigitrafficStack) {
|
70
64
|
if ((node.stackName.includes("Test") || node.stackName.includes("Tst")) &&
|
71
65
|
node.configuration.production) {
|
72
66
|
this.addAnnotation(node, ResourceType.stackName, "Production is set for Test-stack");
|
@@ -78,7 +72,7 @@ class StackCheckingAspect {
|
|
78
72
|
}
|
79
73
|
}
|
80
74
|
checkFunction(node) {
|
81
|
-
if (node instanceof
|
75
|
+
if (node instanceof CfnFunction) {
|
82
76
|
if (!node.reservedConcurrentExecutions) {
|
83
77
|
this.addAnnotation(node, ResourceType.reservedConcurrentConcurrency, "Function must have reservedConcurrentConcurrency");
|
84
78
|
}
|
@@ -102,14 +96,14 @@ class StackCheckingAspect {
|
|
102
96
|
}
|
103
97
|
}
|
104
98
|
checkTags(node) {
|
105
|
-
if (node instanceof
|
106
|
-
if (!node.tags.tagValues()[
|
99
|
+
if (node instanceof Stack) {
|
100
|
+
if (!node.tags.tagValues()[SOLUTION_KEY]) {
|
107
101
|
this.addAnnotation(node, ResourceType.tagSolution, "Solution tag is missing");
|
108
102
|
}
|
109
103
|
}
|
110
104
|
}
|
111
105
|
checkBucket(node) {
|
112
|
-
if (node instanceof
|
106
|
+
if (node instanceof CfnBucket) {
|
113
107
|
const c = node.publicAccessBlockConfiguration;
|
114
108
|
if (c &&
|
115
109
|
(!c.blockPublicAcls ||
|
@@ -128,18 +122,18 @@ class StackCheckingAspect {
|
|
128
122
|
if (path.includes("{")) {
|
129
123
|
return this.isValidPath(path.split("{")[0]);
|
130
124
|
}
|
131
|
-
return
|
125
|
+
return kebabCase(path) === path;
|
132
126
|
}
|
133
127
|
static isValidQueryString(name) {
|
134
|
-
return
|
128
|
+
return _.snakeCase(name) === name;
|
135
129
|
}
|
136
130
|
checkResourceCasing(node) {
|
137
|
-
if (node instanceof
|
131
|
+
if (node instanceof CfnResource) {
|
138
132
|
if (!StackCheckingAspect.isValidPath(node.pathPart)) {
|
139
133
|
this.addAnnotation(node, ResourceType.resourcePath, "Path part should be in kebab-case");
|
140
134
|
}
|
141
135
|
}
|
142
|
-
else if (node instanceof
|
136
|
+
else if (node instanceof CfnMethod) {
|
143
137
|
const integration = node.integration;
|
144
138
|
if (integration?.requestParameters) {
|
145
139
|
Object.keys(integration.requestParameters).forEach((key) => {
|
@@ -154,14 +148,14 @@ class StackCheckingAspect {
|
|
154
148
|
}
|
155
149
|
}
|
156
150
|
checkQueueEncryption(node) {
|
157
|
-
if (node instanceof
|
151
|
+
if (node instanceof CfnQueue) {
|
158
152
|
if (!node.kmsMasterKeyId) {
|
159
153
|
this.addAnnotation(node, ResourceType.queueEncryption, "Queue must have encryption enabled");
|
160
154
|
}
|
161
155
|
}
|
162
156
|
}
|
163
157
|
checkLogGroupRetention(node) {
|
164
|
-
if (node instanceof
|
158
|
+
if (node instanceof LogRetention) {
|
165
159
|
const child = node.node.defaultChild;
|
166
160
|
const retention = child._cfnProperties.RetentionInDays;
|
167
161
|
if (!retention) {
|
@@ -170,5 +164,4 @@ class StackCheckingAspect {
|
|
170
164
|
}
|
171
165
|
}
|
172
166
|
}
|
173
|
-
|
174
|
-
//# sourceMappingURL=stack-checking-aspect.js.map
|
167
|
+
//# sourceMappingURL=stack-checking-aspect.mjs.map
|
@@ -1,12 +1,11 @@
|
|
1
1
|
import { Stack, StackProps } from "aws-cdk-lib";
|
2
|
-
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
3
|
-
import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
|
2
|
+
import { type ISecurityGroup, IVpc } from "aws-cdk-lib/aws-ec2";
|
4
3
|
import { ITopic } from "aws-cdk-lib/aws-sns";
|
5
4
|
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
6
5
|
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
7
6
|
import { Construct } from "constructs";
|
8
|
-
import { TrafficType } from "../../../types/traffictype";
|
9
|
-
import { DBLambdaEnvironment } from "./lambda-configs";
|
7
|
+
import { TrafficType } from "../../../types/traffictype.mjs";
|
8
|
+
import { DBLambdaEnvironment } from "./lambda-configs.mjs";
|
10
9
|
export declare const SOLUTION_KEY = "Solution";
|
11
10
|
export declare const SSM_KEY_WARNING_TOPIC = "/digitraffic/monitoring/warning-topic";
|
12
11
|
export declare const SSM_KEY_ALARM_TOPIC = "/digitraffic/monitoring/alarm-topic";
|
@@ -0,0 +1,63 @@
|
|
1
|
+
import { Aspects, Stack } from "aws-cdk-lib";
|
2
|
+
import { SecurityGroup, Vpc } from "aws-cdk-lib/aws-ec2";
|
3
|
+
import { Topic } from "aws-cdk-lib/aws-sns";
|
4
|
+
import { StringParameter } from "aws-cdk-lib/aws-ssm";
|
5
|
+
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
6
|
+
import { StackCheckingAspect } from "./stack-checking-aspect.mjs";
|
7
|
+
const SSM_ROOT = "/digitraffic";
|
8
|
+
export const SOLUTION_KEY = "Solution";
|
9
|
+
const MONITORING_ROOT = "/monitoring";
|
10
|
+
export const SSM_KEY_WARNING_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/warning-topic`;
|
11
|
+
export const SSM_KEY_ALARM_TOPIC = `${SSM_ROOT}${MONITORING_ROOT}/alarm-topic`;
|
12
|
+
export class DigitrafficStack extends Stack {
|
13
|
+
constructor(scope, id, configuration) {
|
14
|
+
super(scope, id, configuration.stackProps);
|
15
|
+
this.configuration = configuration;
|
16
|
+
if (configuration.secretId) {
|
17
|
+
this.secret = Secret.fromSecretNameV2(this, "Secret", configuration.secretId);
|
18
|
+
}
|
19
|
+
// VPC reference construction requires vpcId and availability zones
|
20
|
+
// private subnets are used in Lambda configuration
|
21
|
+
if (configuration.vpcId) {
|
22
|
+
this.vpc = Vpc.fromVpcAttributes(this, "vpc", {
|
23
|
+
vpcId: configuration.vpcId,
|
24
|
+
privateSubnetIds: configuration.privateSubnetIds,
|
25
|
+
availabilityZones: configuration.availabilityZones ?? [],
|
26
|
+
});
|
27
|
+
}
|
28
|
+
// security group that allows Lambda database access
|
29
|
+
if (configuration.lambdaDbSgId) {
|
30
|
+
this.lambdaDbSg = SecurityGroup.fromSecurityGroupId(this, "LambdaDbSG", configuration.lambdaDbSgId);
|
31
|
+
}
|
32
|
+
this.alarmTopic = Topic.fromTopicArn(this, "AlarmTopic", StringParameter.fromStringParameterName(this, "AlarmTopicParam", SSM_KEY_ALARM_TOPIC).stringValue);
|
33
|
+
this.warningTopic = Topic.fromTopicArn(this, "WarningTopic", StringParameter.fromStringParameterName(this, "WarningTopicParam", SSM_KEY_WARNING_TOPIC).stringValue);
|
34
|
+
this.addAspects();
|
35
|
+
}
|
36
|
+
addAspects() {
|
37
|
+
Aspects.of(this).add(StackCheckingAspect.create(this));
|
38
|
+
}
|
39
|
+
createLambdaEnvironment() {
|
40
|
+
return this.createDefaultLambdaEnvironment(this.configuration.shortName);
|
41
|
+
}
|
42
|
+
createDefaultLambdaEnvironment(dbApplication) {
|
43
|
+
return this.configuration.secretId
|
44
|
+
? {
|
45
|
+
SECRET_ID: this.configuration.secretId,
|
46
|
+
DB_APPLICATION: dbApplication,
|
47
|
+
}
|
48
|
+
: {
|
49
|
+
DB_APPLICATION: dbApplication,
|
50
|
+
};
|
51
|
+
}
|
52
|
+
getSecret() {
|
53
|
+
if (this.secret === undefined) {
|
54
|
+
throw new Error("Secret is undefined");
|
55
|
+
}
|
56
|
+
return this.secret;
|
57
|
+
}
|
58
|
+
grantSecret(...lambdas) {
|
59
|
+
const secret = this.getSecret();
|
60
|
+
lambdas.forEach((l) => secret.grantRead(l));
|
61
|
+
}
|
62
|
+
}
|
63
|
+
//# sourceMappingURL=stack.mjs.map
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { CfnSubscriptionFilter } from "aws-cdk-lib/aws-logs";
|
2
2
|
import { Function as AWSFunction } from "aws-cdk-lib/aws-lambda";
|
3
|
-
import { DigitrafficStack } from "./stack";
|
3
|
+
import { DigitrafficStack } from "./stack.mjs";
|
4
4
|
import { Construct } from "constructs";
|
5
|
-
import { MonitoredFunction } from "./monitoredfunction";
|
5
|
+
import { MonitoredFunction } from "./monitoredfunction.mjs";
|
6
6
|
/**
|
7
7
|
* Creates a subscription filter that subscribes to a Lambda Log Group and delivers the logs to another destination.
|
8
8
|
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.DigitrafficLogSubscriptions = exports.createSubscription = void 0;
|
4
|
-
const aws_logs_1 = require("aws-cdk-lib/aws-logs");
|
1
|
+
import { CfnSubscriptionFilter } from "aws-cdk-lib/aws-logs";
|
5
2
|
/**
|
6
3
|
* Creates a subscription filter that subscribes to a Lambda Log Group and delivers the logs to another destination.
|
7
4
|
* https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-logs-subscriptionfilter.html
|
@@ -10,11 +7,11 @@ const aws_logs_1 = require("aws-cdk-lib/aws-logs");
|
|
10
7
|
* @param logDestinationArn Destination for streamed logs
|
11
8
|
* @param stack CloudFormation stack
|
12
9
|
*/
|
13
|
-
function createSubscription(lambda, lambdaName, logDestinationArn, stack) {
|
10
|
+
export function createSubscription(lambda, lambdaName, logDestinationArn, stack) {
|
14
11
|
if (logDestinationArn == undefined) {
|
15
12
|
return undefined;
|
16
13
|
}
|
17
|
-
const filter = new
|
14
|
+
const filter = new CfnSubscriptionFilter(stack, `${lambdaName}LogsSubscription`, {
|
18
15
|
logGroupName: `/aws/lambda/${lambdaName}`,
|
19
16
|
filterPattern: "",
|
20
17
|
destinationArn: logDestinationArn,
|
@@ -22,13 +19,12 @@ function createSubscription(lambda, lambdaName, logDestinationArn, stack) {
|
|
22
19
|
filter.node.addDependency(lambda);
|
23
20
|
return filter;
|
24
21
|
}
|
25
|
-
|
26
|
-
class DigitrafficLogSubscriptions {
|
22
|
+
export class DigitrafficLogSubscriptions {
|
27
23
|
constructor(stack, ...lambdas) {
|
28
24
|
const destinationArn = stack.configuration.logsDestinationArn;
|
29
25
|
if (destinationArn !== undefined) {
|
30
26
|
lambdas.forEach((lambda) => {
|
31
|
-
const filter = new
|
27
|
+
const filter = new CfnSubscriptionFilter(stack, `${lambda.givenName}LogsSubscription`, {
|
32
28
|
logGroupName: `/aws/lambda/${lambda.givenName}`,
|
33
29
|
filterPattern: "",
|
34
30
|
destinationArn,
|
@@ -38,5 +34,4 @@ class DigitrafficLogSubscriptions {
|
|
38
34
|
}
|
39
35
|
}
|
40
36
|
}
|
41
|
-
|
42
|
-
//# sourceMappingURL=subscription.js.map
|
37
|
+
//# sourceMappingURL=subscription.mjs.map
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { Stack } from "aws-cdk-lib";
|
2
|
-
import { Construct } from "constructs
|
3
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
2
|
+
import { type Construct } from "constructs";
|
3
|
+
import { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
4
4
|
/**
|
5
5
|
* Creates a dns local zone and creates records for cluster endpoints and proxy endpoints.
|
6
6
|
*
|
@@ -0,0 +1,60 @@
|
|
1
|
+
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib";
|
2
|
+
import { PrivateHostedZone, RecordSet, RecordTarget, RecordType, } from "aws-cdk-lib/aws-route53";
|
3
|
+
import { importVpc } from "../import-util.mjs";
|
4
|
+
import { getParameterValue } from "../stack/parameters.mjs";
|
5
|
+
const DEFAULT_RECORD_TTL = Duration.seconds(30);
|
6
|
+
/**
|
7
|
+
* Creates a dns local zone and creates records for cluster endpoints and proxy endpoints.
|
8
|
+
*
|
9
|
+
* Please note, that created PrivateHostedZone has RETAIN removalPolicy, so if you want to delete this stack,
|
10
|
+
* you must remove the zone by hand after.
|
11
|
+
*/
|
12
|
+
export class DbDnsStack extends Stack {
|
13
|
+
constructor(scope, id, isc) {
|
14
|
+
super(scope, id, {
|
15
|
+
env: isc.env,
|
16
|
+
});
|
17
|
+
this.createDnsRecords(isc);
|
18
|
+
}
|
19
|
+
createDnsRecords(isc) {
|
20
|
+
const vpc = importVpc(this, isc.environmentName);
|
21
|
+
const zone = new PrivateHostedZone(this, "DNSHostedZone", {
|
22
|
+
zoneName: isc.environmentName + ".local",
|
23
|
+
vpc,
|
24
|
+
});
|
25
|
+
zone.applyRemovalPolicy(RemovalPolicy.RETAIN);
|
26
|
+
const clusterReaderEndpoint = getParameterValue(this, "cluster.reader");
|
27
|
+
const clusterWriterEndpoint = getParameterValue(this, "cluster.writer");
|
28
|
+
const proxyReaderEndpoint = getParameterValue(this, "proxy.reader");
|
29
|
+
const proxyWriterEndpoint = getParameterValue(this, "proxy.writer");
|
30
|
+
new RecordSet(this, "ReaderRecord", {
|
31
|
+
recordType: RecordType.CNAME,
|
32
|
+
recordName: `db-ro.${isc.environmentName}.local`,
|
33
|
+
target: RecordTarget.fromValues(clusterReaderEndpoint),
|
34
|
+
ttl: DEFAULT_RECORD_TTL,
|
35
|
+
zone,
|
36
|
+
});
|
37
|
+
new RecordSet(this, "WriterRecord", {
|
38
|
+
recordType: RecordType.CNAME,
|
39
|
+
recordName: `db.${isc.environmentName}.local`,
|
40
|
+
target: RecordTarget.fromValues(clusterWriterEndpoint),
|
41
|
+
ttl: DEFAULT_RECORD_TTL,
|
42
|
+
zone,
|
43
|
+
});
|
44
|
+
new RecordSet(this, "ProxyReaderRecord", {
|
45
|
+
recordType: RecordType.CNAME,
|
46
|
+
recordName: `proxy-ro.${isc.environmentName}.local`,
|
47
|
+
target: RecordTarget.fromValues(proxyReaderEndpoint),
|
48
|
+
ttl: DEFAULT_RECORD_TTL,
|
49
|
+
zone,
|
50
|
+
});
|
51
|
+
new RecordSet(this, "ProxyWriterRecord", {
|
52
|
+
recordType: RecordType.CNAME,
|
53
|
+
recordName: `proxy.${isc.environmentName}.local`,
|
54
|
+
target: RecordTarget.fromValues(proxyWriterEndpoint),
|
55
|
+
ttl: DEFAULT_RECORD_TTL,
|
56
|
+
zone,
|
57
|
+
});
|
58
|
+
}
|
59
|
+
}
|
60
|
+
//# sourceMappingURL=db-dns-stack.mjs.map
|
@@ -1,9 +1,9 @@
|
|
1
1
|
import { CfnDBProxyEndpoint, DatabaseProxy } from "aws-cdk-lib/aws-rds";
|
2
2
|
import { ISecret } from "aws-cdk-lib/aws-secretsmanager";
|
3
3
|
import { IVpc } from "aws-cdk-lib/aws-ec2";
|
4
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
4
|
+
import { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
5
5
|
import { Stack } from "aws-cdk-lib/core";
|
6
|
-
import { Construct } from "constructs/lib/construct";
|
6
|
+
import { Construct } from "constructs/lib/construct.js";
|
7
7
|
export interface ProxyConfiguration {
|
8
8
|
readonly secretArn: string;
|
9
9
|
readonly name?: string;
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { CfnDBProxyEndpoint, DatabaseCluster, DatabaseClusterEngine, DatabaseProxy, ProxyTarget, } from "aws-cdk-lib/aws-rds";
|
2
|
+
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
3
|
+
import { SecurityGroup } from "aws-cdk-lib/aws-ec2";
|
4
|
+
import { DbStack } from "./db-stack.mjs";
|
5
|
+
import { exportValue, importVpc } from "../import-util.mjs";
|
6
|
+
import { createParameter } from "../stack/parameters.mjs";
|
7
|
+
import { Stack, Duration } from "aws-cdk-lib/core";
|
8
|
+
/**
|
9
|
+
* A stack that creates a Database proxy.
|
10
|
+
*/
|
11
|
+
export class DbProxyStack extends Stack {
|
12
|
+
constructor(scope, id, isc, configuration) {
|
13
|
+
super(scope, id, {
|
14
|
+
env: isc.env,
|
15
|
+
});
|
16
|
+
this.isc = isc;
|
17
|
+
if (configuration.clusterIdentifier === "") {
|
18
|
+
throw new Error("Empty cluster identifier!");
|
19
|
+
}
|
20
|
+
const vpc = importVpc(this, isc.environmentName);
|
21
|
+
const secret = Secret.fromSecretAttributes(this, "proxy-secret", {
|
22
|
+
secretCompleteArn: configuration.secretArn,
|
23
|
+
});
|
24
|
+
const proxy = this.createProxy(vpc, secret, configuration);
|
25
|
+
const readerEndpoint = this.createProxyEndpoints(vpc, proxy, configuration.securityGroupId);
|
26
|
+
createParameter(this, "proxy.reader", readerEndpoint.attrEndpoint);
|
27
|
+
createParameter(this, "proxy.writer", proxy.endpoint);
|
28
|
+
this.setOutputs(proxy);
|
29
|
+
}
|
30
|
+
setOutputs(proxy) {
|
31
|
+
// if only one instance, then there is no reader-endpoint
|
32
|
+
exportValue(this, this.isc.environmentName, DbProxyStack.PROXY_READER_EXPORT_NAME, proxy.endpoint);
|
33
|
+
exportValue(this, this.isc.environmentName, DbProxyStack.PROXY_WRITER_EXPORT_NAME, proxy.endpoint);
|
34
|
+
}
|
35
|
+
createProxy(vpc, secret, configuration) {
|
36
|
+
const proxyId = `${this.isc.environmentName}-proxy`;
|
37
|
+
const securityGroup = SecurityGroup.fromSecurityGroupId(this, "securitygroup", configuration.securityGroupId);
|
38
|
+
const cluster = DatabaseCluster.fromDatabaseClusterAttributes(this, "db-cluster", {
|
39
|
+
clusterIdentifier: configuration.clusterIdentifier,
|
40
|
+
engine: DatabaseClusterEngine.AURORA_POSTGRESQL,
|
41
|
+
port: DbStack.CLUSTER_PORT,
|
42
|
+
});
|
43
|
+
// CDK tries to allow connections between proxy and cluster
|
44
|
+
// this does not work on cluster references
|
45
|
+
cluster.connections.allowDefaultPortFrom = () => {
|
46
|
+
/* nothing */
|
47
|
+
};
|
48
|
+
return new DatabaseProxy(this, proxyId, {
|
49
|
+
dbProxyName: configuration.name ?? "AuroraProxy",
|
50
|
+
securityGroups: [securityGroup],
|
51
|
+
proxyTarget: ProxyTarget.fromCluster(cluster),
|
52
|
+
idleClientTimeout: Duration.seconds(1800),
|
53
|
+
maxConnectionsPercent: 50,
|
54
|
+
maxIdleConnectionsPercent: 25,
|
55
|
+
borrowTimeout: Duration.seconds(120),
|
56
|
+
requireTLS: false,
|
57
|
+
secrets: [secret],
|
58
|
+
vpc: vpc,
|
59
|
+
});
|
60
|
+
}
|
61
|
+
createProxyEndpoints(vpc, proxy, securityGroupId) {
|
62
|
+
return new CfnDBProxyEndpoint(this, "ReaderEndpoint", {
|
63
|
+
dbProxyEndpointName: "ReaderEndpoint",
|
64
|
+
dbProxyName: proxy.dbProxyName,
|
65
|
+
vpcSubnetIds: vpc.privateSubnets.map((sub) => sub.subnetId),
|
66
|
+
vpcSecurityGroupIds: [securityGroupId],
|
67
|
+
targetRole: "READ_ONLY",
|
68
|
+
});
|
69
|
+
}
|
70
|
+
}
|
71
|
+
DbProxyStack.PROXY_READER_EXPORT_NAME = "db-reader-endpoint";
|
72
|
+
DbProxyStack.PROXY_WRITER_EXPORT_NAME = "db-writer-endpoint";
|
73
|
+
//# sourceMappingURL=db-proxy-stack.mjs.map
|
@@ -1,8 +1,7 @@
|
|
1
|
-
import { InstanceType, IVpc } from "aws-cdk-lib/aws-ec2";
|
2
|
-
import { ISecurityGroup } from "aws-cdk-lib/aws-ec2/lib/security-group";
|
1
|
+
import { InstanceType, IVpc, type ISecurityGroup } from "aws-cdk-lib/aws-ec2";
|
3
2
|
import { AuroraPostgresEngineVersion, DatabaseCluster, DatabaseClusterProps, IParameterGroup } from "aws-cdk-lib/aws-rds";
|
4
|
-
import { Construct } from "constructs/lib/construct";
|
5
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
3
|
+
import { Construct } from "constructs/lib/construct.js";
|
4
|
+
import { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
6
5
|
import { Stack } from "aws-cdk-lib/core";
|
7
6
|
export interface DbConfiguration {
|
8
7
|
readonly cluster?: ClusterConfiguration;
|
@@ -1,12 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
const import_util_1 = require("../import-util");
|
8
|
-
const core_1 = require("aws-cdk-lib/core");
|
9
|
-
const parameters_1 = require("../stack/parameters");
|
1
|
+
import { SecurityGroup, SubnetType, } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import { CfnDBInstance, Credentials, DatabaseCluster, DatabaseClusterEngine, DatabaseClusterFromSnapshot, InstanceUpdateBehaviour, ParameterGroup, } from "aws-cdk-lib/aws-rds";
|
3
|
+
import { Secret } from "aws-cdk-lib/aws-secretsmanager";
|
4
|
+
import { exportValue, importVpc } from "../import-util.mjs";
|
5
|
+
import { Duration, RemovalPolicy, Stack } from "aws-cdk-lib/core";
|
6
|
+
import { createParameter } from "../stack/parameters.mjs";
|
10
7
|
/**
|
11
8
|
* Stack that creates DatabaseCluster.
|
12
9
|
*
|
@@ -16,7 +13,7 @@ const parameters_1 = require("../stack/parameters");
|
|
16
13
|
* You should deploy once with cluster and then without. This way you can create the cluster with this
|
17
14
|
* stack, but cluster is not part of the stack after that.
|
18
15
|
*/
|
19
|
-
class DbStack extends
|
16
|
+
export class DbStack extends Stack {
|
20
17
|
constructor(scope, id, isc, configuration) {
|
21
18
|
super(scope, id, {
|
22
19
|
env: isc.env,
|
@@ -30,23 +27,23 @@ class DbStack extends core_1.Stack {
|
|
30
27
|
// create cluster if this is wanted, should do it only once
|
31
28
|
if (configuration.cluster) {
|
32
29
|
const cluster = this.createAuroraCluster(isc, configuration, configuration.cluster, parameterGroups);
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
exportValue(this, isc.environmentName, DbStack.CLUSTER_IDENTIFIER_EXPORT_NAME, cluster.clusterIdentifier);
|
31
|
+
exportValue(this, isc.environmentName, DbStack.CLUSTER_WRITE_ENDPOINT_EXPORT_NAME, cluster.clusterEndpoint.hostname);
|
32
|
+
exportValue(this, isc.environmentName, DbStack.CLUSTER_READ_ENDPOINT_EXPORT_NAME, cluster.clusterReadEndpoint.hostname);
|
33
|
+
createParameter(this, "cluster.reader", cluster.clusterReadEndpoint.hostname);
|
34
|
+
createParameter(this, "cluster.writer", cluster.clusterEndpoint.hostname);
|
35
|
+
createParameter(this, "cluster.identifier", cluster.clusterIdentifier);
|
39
36
|
this.clusterIdentifier = cluster.clusterIdentifier;
|
40
37
|
}
|
41
38
|
if (configuration.clusterImport) {
|
42
|
-
|
43
|
-
|
39
|
+
createParameter(this, "cluster.reader", configuration.clusterImport.clusterReadEndpoint);
|
40
|
+
createParameter(this, "cluster.writer", configuration.clusterImport.clusterWriteEndpoint);
|
44
41
|
}
|
45
42
|
}
|
46
43
|
createParameterGroups(customVersions, workmem) {
|
47
44
|
return customVersions.map((version) => {
|
48
|
-
const pg = new
|
49
|
-
engine:
|
45
|
+
const pg = new ParameterGroup(this, `parameter-group-${version.auroraPostgresMajorVersion}`, {
|
46
|
+
engine: DatabaseClusterEngine.auroraPostgres({
|
50
47
|
version,
|
51
48
|
}),
|
52
49
|
parameters: {
|
@@ -62,22 +59,22 @@ class DbStack extends core_1.Stack {
|
|
62
59
|
});
|
63
60
|
}
|
64
61
|
createClusterParameters(secretArn, clusterConfiguration, instanceName, vpc, securityGroup, parameterGroup) {
|
65
|
-
const secret =
|
62
|
+
const secret = Secret.fromSecretCompleteArn(this, "DBSecret", secretArn);
|
66
63
|
return {
|
67
|
-
engine:
|
64
|
+
engine: DatabaseClusterEngine.auroraPostgres({
|
68
65
|
version: clusterConfiguration.dbVersion,
|
69
66
|
}),
|
70
67
|
instances: clusterConfiguration.instances,
|
71
|
-
instanceUpdateBehaviour:
|
68
|
+
instanceUpdateBehaviour: InstanceUpdateBehaviour.ROLLING,
|
72
69
|
instanceIdentifierBase: instanceName + "-",
|
73
70
|
cloudwatchLogsExports: ["postgresql"],
|
74
71
|
backup: {
|
75
|
-
retention:
|
72
|
+
retention: Duration.days(35),
|
76
73
|
preferredWindow: "01:00-02:00",
|
77
74
|
},
|
78
75
|
preferredMaintenanceWindow: "mon:03:00-mon:04:00",
|
79
76
|
deletionProtection: true,
|
80
|
-
removalPolicy:
|
77
|
+
removalPolicy: RemovalPolicy.RETAIN,
|
81
78
|
port: DbStack.CLUSTER_PORT,
|
82
79
|
instanceProps: {
|
83
80
|
autoMinorVersionUpgrade: true,
|
@@ -86,35 +83,35 @@ class DbStack extends core_1.Stack {
|
|
86
83
|
vpc,
|
87
84
|
securityGroups: [securityGroup],
|
88
85
|
vpcSubnets: {
|
89
|
-
subnetType:
|
86
|
+
subnetType: SubnetType.PRIVATE_WITH_EGRESS,
|
90
87
|
},
|
91
88
|
instanceType: clusterConfiguration.dbInstanceType,
|
92
89
|
parameterGroup,
|
93
90
|
},
|
94
|
-
credentials:
|
91
|
+
credentials: Credentials.fromPassword(secret.secretValueFromJson("db.superuser").unsafeUnwrap(), secret.secretValueFromJson("db.superuser.password")),
|
95
92
|
parameterGroup,
|
96
93
|
// storageEncrypted: clusterConfiguration.storageEncrypted ?? true,
|
97
|
-
monitoringInterval:
|
94
|
+
monitoringInterval: Duration.seconds(30),
|
98
95
|
};
|
99
96
|
}
|
100
97
|
createAuroraCluster(isc, configuration, clusterConfiguration, parameterGroups) {
|
101
98
|
const instanceName = isc.environmentName + "-db";
|
102
|
-
const securityGroup =
|
99
|
+
const securityGroup = SecurityGroup.fromSecurityGroupId(this, "securitygroup", clusterConfiguration.securityGroupId);
|
103
100
|
const vpc = configuration.vpc
|
104
101
|
? configuration.vpc
|
105
|
-
:
|
102
|
+
: importVpc(this, isc.environmentName);
|
106
103
|
const parameters = this.createClusterParameters(configuration.secretArn, clusterConfiguration, instanceName, vpc, securityGroup, parameterGroups[0]);
|
107
104
|
// create cluster from the snapshot or from the scratch
|
108
105
|
const cluster = clusterConfiguration.snapshotIdentifier
|
109
|
-
? new
|
106
|
+
? new DatabaseClusterFromSnapshot(this, instanceName, {
|
110
107
|
...parameters,
|
111
108
|
...{
|
112
109
|
snapshotIdentifier: clusterConfiguration.snapshotIdentifier,
|
113
110
|
},
|
114
111
|
})
|
115
|
-
: new
|
112
|
+
: new DatabaseCluster(this, instanceName, parameters);
|
116
113
|
// this workaround should prevent stack failing on version upgrade
|
117
|
-
const cfnInstances = cluster.node.children.filter((child) => child instanceof
|
114
|
+
const cfnInstances = cluster.node.children.filter((child) => child instanceof CfnDBInstance);
|
118
115
|
if (cfnInstances.length === 0) {
|
119
116
|
throw new Error("Couldn't pull CfnDBInstances from the L1 constructs!");
|
120
117
|
}
|
@@ -122,9 +119,8 @@ class DbStack extends core_1.Stack {
|
|
122
119
|
return cluster;
|
123
120
|
}
|
124
121
|
}
|
125
|
-
exports.DbStack = DbStack;
|
126
122
|
DbStack.CLUSTER_PORT = 5432;
|
127
123
|
DbStack.CLUSTER_IDENTIFIER_EXPORT_NAME = "db-cluster";
|
128
124
|
DbStack.CLUSTER_READ_ENDPOINT_EXPORT_NAME = "db-cluster-reader-endpoint";
|
129
125
|
DbStack.CLUSTER_WRITE_ENDPOINT_EXPORT_NAME = "db-cluster-writer-endpoint";
|
130
|
-
//# sourceMappingURL=db-stack.
|
126
|
+
//# sourceMappingURL=db-stack.mjs.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { IVpc, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
-
import { InfraStackConfiguration } from "./intra-stack-configuration";
|
2
|
+
import { InfraStackConfiguration } from "./intra-stack-configuration.mjs";
|
3
3
|
import { Stack } from "aws-cdk-lib/core";
|
4
|
-
import { Construct } from "constructs/lib/construct";
|
4
|
+
import { Construct } from "constructs/lib/construct.js";
|
5
5
|
export interface NetworkConfiguration {
|
6
6
|
readonly vpcName: string;
|
7
7
|
readonly cidr: string;
|
@@ -0,0 +1,40 @@
|
|
1
|
+
import { IpAddresses, SubnetType, Vpc } from "aws-cdk-lib/aws-ec2";
|
2
|
+
import { exportValue } from "../import-util.mjs";
|
3
|
+
import { Stack } from "aws-cdk-lib/core";
|
4
|
+
export class NetworkStack extends Stack {
|
5
|
+
constructor(scope, id, isc, configuration) {
|
6
|
+
super(scope, id, {
|
7
|
+
env: isc.env,
|
8
|
+
});
|
9
|
+
this.vpc = this.createVpc(configuration);
|
10
|
+
exportValue(this, isc.environmentName, "VPCID", this.vpc.vpcId);
|
11
|
+
exportValue(this, isc.environmentName, "digitrafficpublicASubnet", this.vpc.publicSubnets[0].subnetId);
|
12
|
+
exportValue(this, isc.environmentName, "digitrafficpublicBSubnet", this.vpc.publicSubnets[1].subnetId);
|
13
|
+
exportValue(this, isc.environmentName, "digitrafficprivateASubnet", this.vpc.privateSubnets[0].subnetId);
|
14
|
+
exportValue(this, isc.environmentName, "digitrafficprivateBSubnet", this.vpc.privateSubnets[1].subnetId);
|
15
|
+
}
|
16
|
+
createVpc(configuration) {
|
17
|
+
return new Vpc(this, "DigitrafficVPC", {
|
18
|
+
vpcName: configuration.vpcName,
|
19
|
+
availabilityZones: Stack.of(this)
|
20
|
+
.availabilityZones.sort()
|
21
|
+
.slice(0, 2), // take two first azs
|
22
|
+
enableDnsHostnames: true,
|
23
|
+
enableDnsSupport: true,
|
24
|
+
ipAddresses: IpAddresses.cidr(configuration.cidr),
|
25
|
+
subnetConfiguration: [
|
26
|
+
{
|
27
|
+
name: "public",
|
28
|
+
cidrMask: 24,
|
29
|
+
subnetType: SubnetType.PUBLIC,
|
30
|
+
},
|
31
|
+
{
|
32
|
+
name: "private",
|
33
|
+
cidrMask: 24,
|
34
|
+
subnetType: SubnetType.PRIVATE_WITH_EGRESS,
|
35
|
+
},
|
36
|
+
],
|
37
|
+
});
|
38
|
+
}
|
39
|
+
}
|
40
|
+
//# sourceMappingURL=network-stack.mjs.map
|