tags: bmocdk

Refers:

CDK initializaion:


kaau@OCLT71159526 ~$ cd ${HOME}/myproj

kaau@OCLT71159526 ~/myproj$ git clone https://github.com/BMO-Prod/TREO_APM_CDK_SIM_92315.git
Cloning into 'TREO_APM_CDK_SIM_92315'...
remote: Enumerating objects: 350, done.
remote: Counting objects: 100% (350/350), done.
remote: Compressing objects: 100% (239/239), done.
remote: Total 350 (delta 93), reused 270 (delta 54), pack-reused 0 (from 0)
Receiving objects: 100% (350/350), 873.53 KiB | 2.25 MiB/s, done.
Resolving deltas: 100% (93/93), done.

kaau@OCLT71159526 ~/myproj$ ls -l
drwxr-xr-x 1 kaau 1049089 0 Jul 18 15:14 TREO_APM_CDK_SIM_92315

kaau@OCLT71159526 ~/myproj$ cd TREO_APM_CDK_SIM_92315
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315$ ls -la
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:14 .
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:14 ..
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:15 .git
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:14 .github                                                          ---GitHub Actions workflow files
-rw-r--r-- 1 kaau 1049089  148 Jul 18 15:14 .gitignore
-rw-r--r-- 1 kaau 1049089  119 Jul 18 15:14 build.sh                                                         ---GitHub Actions: build and deploy CDK stacks
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:14 docs
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:14 infra                                                            ---CDK infrastructure deployment code 
-rw-r--r-- 1 kaau 1049089 2215 Jul 18 15:14 readme.md
drwxr-xr-x 1 kaau 1049089    0 Jul 18 15:14 service                                                          ---lambda functions code 

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315$ ls -l .github/workflows
-rw-r--r-- 1 kaau 1049089  611 Jul 18 15:14 codescanning.default.workflow.yml
-rw-r--r-- 1 kaau 1049089 1276 Jul 18 15:14 compliant-cfn-diff-deploy.yml
-rw-r--r-- 1 kaau 1049089 2525 Jul 18 15:14 compliant-cfn-release.yml
-rw-r--r-- 1 kaau 1049089  732 Jul 18 15:14 compliant-cli-command.yml
-rw-r--r-- 1 kaau 1049089 1132 Jul 18 15:14 compliant-diff-deploy.yml
-rw-r--r-- 1 kaau 1049089 1142 Jul 18 15:14 compliant-diff-deploy-alpha.yml
-rw-r--r-- 1 kaau 1049089  290 Jul 18 15:14 compliant-modules-feedback.yml
-rw-r--r-- 1 kaau 1049089 2051 Jul 18 15:14 compliant-release.yml
-rw-r--r-- 1 kaau 1049089 2185 Jul 18 15:14 compliant-release-alpha.yml

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315$ cat build.sh 
[[blue:pushd infra]]
[[blue:pnpm i --shamefully-hoist=true]]
[[blue:popd ]]
[[blue:]]
[[blue:pushd service/api-lambda]]
[[blue:pnpm i --shamefully-hoist=true]]
[[blue:npx tsc]]
[[blue:popd]]
  

Working with the infra/ codes:


kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315$ cd infra
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ ls -l
drwxr-xr-x 1 kaau 1049089   0 Jul 18 15:14 bin                                                               ---#1 CDK entry point
-rw-r--r-- 1 kaau 1049089 830 Jul 18 15:14 cdk.json                                                          ---CDK config: how to run and what settings to use 
drwxr-xr-x 1 kaau 1049089   0 Jul 18 15:14 config
-rw-r--r-- 1 kaau 1049089  29 Jul 18 15:14 controller.json                                                   ---CDK stack config
-rw-r--r-- 1 kaau 1049089  72 Jul 18 15:14 jest.config.js
drwxr-xr-x 1 kaau 1049089   0 Jul 18 15:14 lib                                                               ---#2. CDK stack code
-rw-r--r-- 1 kaau 1049089 800 Jul 18 15:14 package.json                                                      ---CDK dependencies and scripts
drwxr-xr-x 1 kaau 1049089   0 Jul 18 15:14 test
-rw-r--r-- 1 kaau 1049089 710 Jul 18 15:14 tsconfig.json                                                     ---TypeScript config

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cat package.json 
[[blue:{]]
[[blue:  "name": "infra",]]
[[blue:  "version": "0.1.0",]]
[[blue:  "bin": {]]
[[blue:    "infra": "bin/infra.js"]]
[[blue:  },]]
[[blue:  "scripts": {]]
[[blue:    "build": "tsc",]]
[[blue:    "watch": "tsc -w",]]
[[blue:    "test": "jest",]]
[[blue:    "cdk": "cdk"]]
[[blue:  },]]
[[blue:  "devDependencies": {]]
[[blue:    "@types/jest": "^26.0.24",]]
[[blue:    "@types/node": "^10.17.27",]]
[[blue:    "jest": "^26.6.3",]]
[[blue:    "ts-jest": "^26.5.6",]]
[[blue:    "ts-node": "^10.9.2",]]
[[blue:    "typescript": "^5.9.2"]]
[[blue:  },]]
[[blue:  "dependencies": {]]
[[blue:    "@bmo-cdk/apigateway": "^9.0.0",]]                                                                         ---@bmo-cdk v9.0.0?
[[blue:    "@bmo-cdk/cloudwatch": "^9.0.0",]]
[[blue:    "@bmo-cdk/common": "^9.0.0",]]
[[blue:    "@bmo-cdk/dynamodb": "^9.0.0",]]
[[blue:    "@bmo-cdk/iam": "^9.0.0",]]
[[blue:    "@bmo-cdk/lambdafunction": "^9.0.0",]]
[[blue:    "@bmo-cdk/secretsmanager": "^9.0.0",]]
[[blue:    "@bmo-cdk/ssm-parameter": "^9.0.0",]]
[[blue:    "constructs": "^10.3.0",]]
[[blue:    "source-map-support": "^0.5.21"]]
[[blue:  }]]
[[blue:}]]

#
# adapts the latest @bmo-cdk v11.0.0 ():
# note: the latest @bmo-cdk v11.0.0 is available but it had not been official released on 18th July 2024
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ grep "@bmo-cdk" package.json 
[[blue:    "@bmo-cdk/apigateway": "^9.0.0",]]                                                                         ---can mix @bmo-cdk v9.0.0 with @bmo-cdk v11.0.0? [[red:NO!]]
[[blue:    "@bmo-cdk/cloudwatch": "^9.0.0",]]
[[blue:    "@bmo-cdk/common": "^9.0.0",]]
[[blue:    "@bmo-cdk/dynamodb": "^9.0.0",]]
[[blue:    "@bmo-cdk/iam": "^9.0.0",]]
[[blue:    "@bmo-cdk/lambdafunction": "^9.0.0",]]
[[blue:    "@bmo-cdk/secretsmanager": "^9.0.0",]]
[[blue:    "@bmo-cdk/ssm-parameter": "^9.0.0",]]

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ sed --in-place 's/\(@bmo-cdk\/[a-z-]*": "\^\)9\.0\.0/\110.0.0/g' package.json

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ grep "@bmo-cdk" package.json 
    [[blue:"@bmo-cdk/apigateway": "^10.0.0",]]
    [[blue:"@bmo-cdk/cloudwatch": "^10.0.0",]]
    [[blue:"@bmo-cdk/common": "^10.0.0",]]
    [[blue:"@bmo-cdk/dynamodb": "^10.0.0",]]
    [[blue:"@bmo-cdk/iam": "^10.0.0",]]
    [[blue:"@bmo-cdk/lambdafunction": "^10.0.0",]]
    [[blue:"@bmo-cdk/secretsmanager": "^10.0.0",]]
    [[blue:"@bmo-cdk/ssm-parameter": "^10.0.0",]]

#
# pnpm install with the updated package.json:
# Refer: https://bmo.atlassian.net/wiki/spaces/AUTOMATE/pages/624625403/Installing+bmo-cdk-modules+with+pnpm+instead+of+npm
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ ls -ld node_modules
[[red:ls: cannot access 'node_modules': No such file or directory]]

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ pnpm install
[[yellow:[WARN]]] [[red:13 deprecated subdependencies]] found: abab@2.0.6, domexception@2.0.1, glob@7.2.3, inflight@1.0.6, resolve-url@0.2.1,
rimraf@3.0.2, sane@4.1.0, source-map-resolve@0.5.3, source-map-url@0.4.1, urix@0.1.0, uuid@8.3.2, w3c-hr-time@1.0.2, whatwg-encoding@1.0.5
Packages: [[green:+488]]
[[green:+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++]]
Progress: resolved [[blue:489]], reused [[blue:475]], downloaded [[blue:13]], added 488, done
[[yellow:[WARN]]] Issues with peer dependencies found. Run "pnpm peers check" to list them.
[[blue:dependencies:]]
[[green:+]] @bmo-cdk/apigateway 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/cloudwatch 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/common 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/dynamodb 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/iam 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/lambdafunction 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/secretsmanager 10.2.0 (11.0.0 is available)
[[green:+]] @bmo-cdk/ssm-parameter 10.2.0 (11.0.0 is available)
[[green:+]] constructs 10.6.0
[[green:+]] source-map-support 0.5.21
[[blue:devDependencies:]]
[[green:+]] @types/jest 26.0.24 (30.0.0 is available)
[[green:+]] @types/node 10.17.60 (26.1.1 is available)
[[green:+]] jest 26.6.3 (30.4.2 is available)
[[green:+]] ts-jest 26.5.6 (29.4.11 is available)
[[green:+]] ts-node 10.9.2
[[green:+]] typescript 5.9.3 (7.0.2 is available)
Done in 28.1s using pnpm v11.9.0

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ ls -ld node_modules
drwxr-xr-x 1 kaau 1049089 0 Jul 18 15:44 node_modules
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ du -sh node_modules
267M    node_modules

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ ls -l bin
-rw-r--r-- 1 kaau 1049089 2201 Jul 18 15:14 infra.ts
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ ls -l lib
-rw-r--r-- 1 kaau 1049089 6428 Jul 18 15:14 api_stack.ts
-rw-r--r-- 1 kaau 1049089 1452 Jul 18 15:14 dynamodb_stack.ts
-rw-r--r-- 1 kaau 1049089 4042 Jul 18 15:14 iam_stack.ts
-rw-r--r-- 1 kaau 1049089 2041 Jul 18 15:14 lambda_stack.ts
-rw-r--r-- 1 kaau 1049089 1884 Jul 18 15:14 swagger-api.ts
 

cdk operations:


kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list
C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:859
    [[red:return new TSError(diagnosticText, diagnosticCodes, diagnostics);]]
           [[red:^]]
[[red:TSError: ⨯ Unable to compile TypeScript:]]
[[red:bin/infra.ts:2:22 - error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations.]]
[[2 import * as cdk from 'aws-cdk-lib';]]
                       ~~~~~~~~~~~~~
bin/infra.ts:49:31 - error TS2339: Property 'addDependency' does not exist on type 'DynamoDBStack'.
49     iamStack && dynamodbStack.addDependency(iamStack)
                                 ~~~~~~~~~~~~~
bin/infra.ts:58:33 - error TS2339: Property 'addDependency' does not exist on type 'APIGatewayStack'.
58     iamStack && apiGatewayStack.addDependency(iamStack)
bin/infra.ts:65:13 - error TS2353: Object literal may only specify known properties, and 'env' does not exist in type 'LambdaStackProps'.
65             env
               ~~~
bin/infra.ts:68:29 - error TS2339: Property 'addDependency' does not exist on type 'LambdaStack'.
68     iamStack && lambdaStack.addDependency(iamStack)
                               ~~~~~~~~~~~~~
    at createTSError (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:859:12)
    at reportTSError (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:863:19)
    at getOutput (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1077:36)
    at Object.compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1433:41)
    at Module.m._compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1617:30)
    at node:internal/modules/cjs/loader:1706:10
    at Object.require.extensions.<computed> [as .ts] (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14) {
  diagnosticCodes: [ 2307, 2339, 2339, 2353, 2339 ]
}
✨  Synthesis time: 15.83s
npx ts-node --prefer-ts-exts bin/infra.ts: Subprocess exited with error 1

#
# resolve error:
#   bin/infra.ts:2:22-error TS2307: Cannot find module 'aws-cdk-lib' or its corresponding type declarations.
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ pnpm add aws-cdk-lib --save-dev
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[green:✓]] Lockfile passes supply-chain policies (verified 12m ago)
[[yellow:[WARN]]] [[red:13 deprecated subdependencies]] found: abab@2.0.6, domexception@2.0.1, glob@7.2.3, inflight@1.0.6, resolve-url@0.2.1, rimraf@3.0.2, sane@4.1.0, 
source-map-resolve@0.5.3, source-map-url@0.4.1, urix@0.1.0, uuid@8.3.2, w3c-hr-time@1.0.2, whatwg-encoding@1.0.5
Packages: [[green:+10]] [[red:-10]]
[[green:++++++++++]][[red:----------]]
Downloading aws-cdk-lib@2.261.0: [[blue:31.20 MB/31.20 MB]], done
Progress: resolved [[blue:489]], reused [[blue:487]], downloaded [[blue:1]], added [[blue:10]], done
[[yellow:[WARN]]] Issues with peer dependencies found. Run "pnpm peers check" to list them.
[[blue:devDependencies:]]
[[green:+]] aws-cdk-lib 2.261.0
Done in 22.3s using pnpm v11.9.0

#
# try again:
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list
C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:859
    [[red:return new TSError(diagnosticText, diagnosticCodes, diagnostics);]]
           [[red:^]]
[[red:TSError: ⨯ Unable to compile TypeScript:]]
[[red:lib/lambda_stack.ts:41:95 - error TS2339: Property 'lambdaSecurityGroupId' does not exist on type 'NoPurposeCodeVpcSsmParameter'.]]
[[red:41       securityGroupIds: GetSSMValue(this, [helper.ssmParamemterName.network.sharedWorkloadVpc.lambdaSecurityGroupId]),]]
                                                                                                 [[red:~~~~~~~~~~~~~~~~~~~~~]]
    at createTSError (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:859:12)
    at reportTSError (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:863:19)
    at getOutput (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1077:36)
    at Object.compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1433:41)
    at Module.m._compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1617:30)
    at node:internal/modules/cjs/loader:1706:10
    at Object.require.extensions.<computed> [as .ts] (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14) {
  diagnosticCodes: [ 2339 ]
}
✨  Synthesis time: 15.6s
npx ts-node --prefer-ts-exts bin/infra.ts: Subprocess exited with error 1

#
# resolve error:
#   TSError: ⨯ Unable to compile TypeScript:
#   lib/lambda_stack.ts:41:95-error TS2339: Property 'lambdaSecurityGroupId' does not exist on type 'NoPurposeCodeVpcSsmParameter'.
#
#   declare the lambdaSecurityGroupId in helper.ssmParamemterName.network.sharedWorkloadVpc as any
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ sed -n "41p" lib/lambda_stack.ts 
      [[blue:securityGroupIds: GetSSMValue(this, [helper.ssmParamemterName.network.sharedWorkloadVpc.lambdaSecurityGroupId]),]]

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ vi lib/lambda_stack.ts 
::
::

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ sed -n "41p" lib/lambda_stack.ts 
      [[blue:securityGroupIds: GetSSMValue(this, [(helper.ssmParamemterName.network.sharedWorkloadVpc as any).lambdaSecurityGroupId]),]]

#
# try again:
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list
C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+common@10.2.0_aws-_558700f685f40860d18f63592583e9af\node_modules\@bmo-cdk\common\lib\BMOCommonConstruct.ts:606
                    [[red:throw new Error('[ERROR]: ' + key + ' tag cannot be undefined or empty');]]
                          [[red:^]]
[[red:Error: [ERROR]: Environment tag cannot be undefined or empty]]
    at new BMOTaggingConstruct (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+common@10.2.0_aws-_558700f685f40860d18f63592583e9af\node_modules\@bmo-cdk\common\lib\BMOCommonConstruct.ts:606:27)
    at new BMOIAMConstruct (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+iam@10.2.0_@bmo-cd_ff47539a887f9629baba96df4b23b26c\node_modules\@bmo-cdk\iam\lib\BMOIAMConstruct.ts:442:9)
    at new IamStack (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\lib\iam_stack.ts:13:9)
    at Object.<anonymous> (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\bin\infra.ts:32:16)
    at Module._compile (node:internal/modules/cjs/loader:1554:14)
    at Module.m._compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1618:23)
    at node:internal/modules/cjs/loader:1706:10
    at Object.require.extensions.<computed> [as .ts] (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
✨  Synthesis time: 15.22s
npx ts-node --prefer-ts-exts bin/infra.ts: Subprocess exited with error 1

#
# resolve error:
#  Error: [ERROR]: Environment tag cannot be undefined or empty
#
#  refers: https://bmo.atlassian.net/wiki/spaces/IE/pages/360461499/Mandatory+tag+values
#  due to the missing environment tag in the CDK helper configuration
#  update the createBmoCdkHelper in config/index.ts to provide a non-empty value for environment tag
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ sed --silent "9,17p" config/index.ts 
[[blue:export const createBmoCdkHelper = configurationHelperFactory({]]
[[blue:    appCatId: '92315', // App Cat ID ]]
[[blue:    projectName: 'TREO', // Alphanumeric only, the project name (e.g., CENG)]]
[[blue:    serviceName: 'APMCDKSIM', // Alphanumeric and hyphens only]]
[[blue:    serviceDescription: '[Please enter your service description]', // Any text]]
[[blue:    purposeCode: PurposeCode.NONE, // Purpose code of the multi account. Use PurposeCode.NONE for old account.]]
[[blue:    costCenter: '[Please enter your cost center]', // Cost Center]]
[[blue:    supportTeam: 'RUN_ENG_CLOUD_PLATFORM_SUPPORT', // Support team]]
[[blue:})]]

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ vi config/index.ts 
::
::

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ sed --silent "9,18p" config/index.ts 
[[blue:export const createBmoCdkHelper = configurationHelperFactory({]]
[[blue:    appCatId: '92315', // App Cat ID ]]
[[blue:    projectName: 'TREO', // Alphanumeric only, the project name (e.g., CENG)]]
[[blue:    serviceName: 'APMCDKSIM', // Alphanumeric and hyphens only]]
[[blue:    serviceDescription: '[Please enter your service description]', // Any text]]
[[blue:    purposeCode: PurposeCode.NONE, // Purpose code of the multi account. Use PurposeCode.NONE for old account.]]
[[blue:    costCenter: '[Please enter your cost center]', // Cost Center]]
[[blue:    supportTeam: 'RUN_ENG_CLOUD_PLATFORM_SUPPORT', // Support team]]
[[blue:    environment: 'Sandbox']]                                                                                   ---this!
[[blue:})]]

#
# try again:
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list
C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+common@10.1.
0_aws-_d4479d8257a9240775a092b6ec0139e9\node_modules\@bmo-cdk\common\lib\BMOCommonConstruct.ts:593
                    throw new Error('[ERROR]: ' + key + ' tag cannot be undefined or empty');
                          ^
[[red:Error: [ERROR]: Stage tag cannot be undefined or empty]]
    at new BMOTaggingConstruct (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+common@10.1.0_aws-_d4479d8257a9240775a092b6ec0139e9\node_modules\@bmo-cdk\common\lib\BMOCommonConstruct.ts:593:27)
    at new BMOIAMConstruct (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+iam@10.1.
    0_@bmo-cd_ad78dbc40b931337d36a593a7688c47e\node_modules\@bmo-cdk\iam\lib\BMOIAMConstruct.ts:442:9)
    at new IamStack (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\lib\iam_stack.ts:13:9)
    at Object.<anonymous> (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\bin\infra.ts:32:16)
    at Module._compile (node:internal/modules/cjs/loader:1554:14)
    at Module.m._compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.
    3\node_modules\ts-node\src\index.ts:1618:23)
    at node:internal/modules/cjs/loader:1706:10
    at Object.require.extensions.<computed> [as .ts] (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types
    +node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
npx ts-node --prefer-ts-exts bin/infra.ts: Subprocess exited with error 1

#
# resolve error:
#  Error: [ERROR]: Stage tag cannot be undefined or empty
#
#  due to the missing "Stage" in environment
#  we provide the Stage via --context
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list --context Stage=sandbox
Building with @bmo-cdk/iam module version: 10.2.0
C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\lib\dynamodb_stack.ts:39
      [[red:kmsMasterKeyId: GetSSMValue(this, helper.ssmParamemterName.kmsKey.dynamoKeyId),]]
                                 [[red:^]]
[[red:«StackAccountRegionNotSpecified» Cannot retrieve value from context provider ssm since account/region are not specified at the stack level.]]
[[red:Configure "env" with an account and region when you define your stack.See https://docs.aws.amazon.com/cdk/latest/guide/environments.html for more details.]]
    ...GetSSMValue in .pnpm...
    at new DynamoDBStack (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\lib\dynamodb_stack.ts:39:34)
    at <anonymous> (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\bin\infra.ts:42:21)
    ...node internals, .pnpm, .pnpm...
Relates to construct:
    <.> (aws-cdk-lib.App)
     └─ APMCDKSIM-sandbox-dynamodb-stack (aws-cdk-lib.Stack)
✨  Synthesis time: 15.33s
npx ts-node --prefer-ts-exts bin/infra.ts: Subprocess exited with error 1

#
# resolve error:
#   Configure "env" with an account and region when you define your stack.
#
#  we provide the accountID and region via --context
#   
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list --context Stage=sandbox --context accountID=520049198415 --context region=us-east-1
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+lambdafunction@10._e4de315374aa1eedd60a6b8c01c7d541\node_modules\@bmo-cdk\lambdafunction\lib\BMOLambdaConstruct.ts:491
                [[red:throw new Error(]]
                      [[red:^]]
[[red:Error: [ERROR] Dynatrace Layer ARN context variables are empty. Please create an INC and assign to BLD_ENG_CLOUD_AUTOMATION team.]]
    at Function.setupDynatrace (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+lambdafunction@10._e4de315374aa1eedd60a6b8c01c7d541\node_modules\@bmo-cdk\lambdafunction\lib\BMOLambdaConstruct.ts:491:23)
    at new BMOLambdaConstruct (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\@bmo-cdk+lambdafunction@10._e4de315374aa1eedd60a6b8c01c7d541\node_modules\@bmo-cdk\lambdafunction\lib\BMOLambdaConstruct.ts:1022:57)
    at new LambdaStack (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\lib\lambda_stack.ts:19:5)
    at Object.<anonymous> (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\bin\infra.ts:60:19)
    at Module._compile (node:internal/modules/cjs/loader:1554:14)
    at Module.m._compile (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1618:23)
    at node:internal/modules/cjs/loader:1706:10
    at Object.require.extensions.<computed> [as .ts] (C:\Users\kaau\myproj\TREO_APM_CDK_SIM_92315\infra\node_modules\.pnpm\ts-node@10.9.2_@types+node@10.17.60_typescript@5.9.3\node_modules\ts-node\src\index.ts:1621:12)
    at Module.load (node:internal/modules/cjs/loader:1289:32)
    at Function._load (node:internal/modules/cjs/loader:1108:12)
✨  Synthesis time: 15.96s

#
# resolve error:
#   Error: [ERROR] Dynatrace Layer ARN context variables are empty. Please create an INC and assign to BLD_ENG_CLOUD_AUTOMATION team.
#
#  due to Dynatrace monitoring is not available in local development, hence, we can disable Dynatrace monitoring in the lambda stack for local development
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ grep dynatrace lib/lambda_stack.ts 
      [[blue:dynatraceConfig: true,]]

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ vi lib/lambda_stack.ts 
::
::

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ grep dynatrace lib/lambda_stack.ts 
      [[blue:dynatraceConfig: false,]]

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk list -c Stage=sandbox -c accountID=520049198415 -c region=us-east-1
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
Runtime set to nodejs20.x
Building with @bmo-cdk/lambdafunction module version: 10.2.0
Issue with Logging Configuration
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
Runtime set to nodejs20.x
Building with @bmo-cdk/lambdafunction module version: 10.2.0
Issue with Logging Configuration
Building with @bmo-cdk/cloudwatch module version: 10.2.0
✨  Synthesis time: 41.34s
APMCDKSIM-sandbox-iam-stack
APMCDKSIM-sandbox-dynamodb-stack
APMCDKSIM-sandbox-api-stack
APMCDKSIM-sandbox-lambda-stack                                                                               ---viola!

#
# proceed to cdk synth:
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk synth --context Stage=sandbox --context accountID=520049198415 --context region=us-east-1
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
Runtime set to nodejs20.x
Building with @bmo-cdk/lambdafunction module version: 10.2.0
Issue with Logging Configuration
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
Runtime set to nodejs20.x
Building with @bmo-cdk/lambdafunction module version: 10.2.0
Issue with Logging Configuration
Building with @bmo-cdk/cloudwatch module version: 10.2.0
[[red:ERROR Need to perform AWS calls for account 520049198415, but no credentials have been configured (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-dynamodb-stack]]
[[red:   Rule error-annotation]]
[[red:ERROR Need to perform AWS calls for account 520049198415, but no credentials have been configured (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-api-stack]]
[[red:   Rule error-annotation]]
[[red:ERROR Need to perform AWS calls for account 520049198415, but no credentials have been configured (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-lambda-stack]]
[[red:   Rule error-annotation]]
[[red:ERROR parameterName must be provided in props for SSMContextProviderPlugin (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-lambda-stack]]
[[red:   Rule error-annotation]]
[[yellow:WARNING]] [[red:No cross-stack-reference strength configured, defaulting to "strong". We recommend you set feature flag "@aws-cdk/core:defaultCrossStackReferences" to "both",]]
[[red:then deploy everywhere, then set it to "weak". Alternatively, set it to "strong" explicitly to lock in the current producer-protecting behavior.]]
[[red:(See: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/README.md#reference-strength) (Construct Annotations)]]
   [[red:APMCDKSIM-sandbox-lambda-stack]]
   Acknowledge with 'Construct-Annotations::@aws-cdk/core:crossStackReferencesDefaultStrong'
[[red:Synthesis finished with errors]]

#
# try export AWS credentials and try again:
#
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ export AWS_ACCESS_KEY_ID="ASIAXSFKZAVH5SYPHZUH"
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ export AWS_SECRET_ACCESS_KEY="9k5ZmfPccWvD4C7YLyGub8WfgJIRHGicyoBqwdT4"
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ export AWS_SESSION_TOKEN="IQoJb3JpZ2luX2VjEMj.....0VrSPNgrVTMgq4sdFQ=="
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ export AWS_REGION=us-east-1
kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ export | grep AWS_
declare -x AWS_ACCESS_KEY_ID="ASIAXSFKZAVH5SYPHZUH"
declare -x AWS_REGION="us-east-1"
declare -x AWS_SECRET_ACCESS_KEY="9k5ZmfPccWvD4C7YLyGub8WfgJIRHGicyoBqwdT4"
declare -x AWS_SESSION_TOKEN="IQoJb3JpZ2luX2VjEMj....0VrSPNgrVTMgq4sdFQ=="

kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cdk synth --context Stage=sandbox --context accountID=520049198415 --context region=us-east-1
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
Runtime set to nodejs20.x
Building with @bmo-cdk/lambdafunction module version: 10.2.0
Issue with Logging Configuration
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/iam module version: 10.2.0
Building with @bmo-cdk/dynamodb module version: 10.2.0
You are not using the centralized load balancer in shared services account, please correct this by using the right endpoint
Building with@bmo-cdk/apigateway module version: 10.2.0
Building with @bmo-cdk/cloudwatch module version: 10.2.0
Building with @bmo-cdk/apigateway module version: 10.2.0
Runtime set to nodejs20.x
Building with @bmo-cdk/lambdafunction module version: 10.2.0
Issue with Logging Configuration
Building with @bmo-cdk/cloudwatch module version: 10.2.0
[[red:ERROR Need to perform AWS calls for account 520049198415, but no credentials have been configured (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-dynamodb-stack]]
[[red:   Rule error-annotation]]
[[red:ERROR Need to perform AWS calls for account 520049198415, but no credentials have been configured (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-api-stack]]
[[red:   Rule error-annotation]]
[[red:ERROR Need to perform AWS calls for account 520049198415, but no credentials have been configured (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-lambda-stack]]
[[red:   Rule error-annotation]]
[[red:ERROR parameterName must be provided in props for SSMContextProviderPlugin (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-lambda-stack]]
[[red:   Rule error-annotation]]
[[yellow:WARNING]] [[red:No cross-stack-reference strength configured, defaulting to "strong". We recommend you set feature flag "@aws-cdk/core:defaultCrossStackReferences" to "both", ]]
[[red:then deploy everywhere, then set it to "weak". Alternatively, set it to "strong" explicitly to lock in the current producer-protecting behavior. ]]
[[red:(See: https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/README.md#reference-strength) (Construct Annotations)]]
[[red:   APMCDKSIM-sandbox-lambda-stack]]
[[red:   Acknowledge with 'Construct-Annotations::@aws-cdk/core:crossStackReferencesDefaultStrong']]
[[red:Synthesis finished with errors]]                                                                               ---due to the CDK unable to perform AWS calls to retrieve parameter values
 

Clean up:


kaau@OCLT71159526 ~/myproj/TREO_APM_CDK_SIM_92315/infra$ cd ${HOME}/myproj
kaau@OCLT71159526 ~/myproj$ rm -rf TREO_APM_CDK_SIM_92315