You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Prerequisites for manual testing of a CDK construct:
Ensure AWS CLI is installed and configured correctly for your AWS account.
Configure an Atlas profile secret in your AWS account with your API keys. Refer README for more information on how to do this.
Install AWS CDK CLI.
Ensure required resources are activated in your AWS CloudFormation:
aws cloudformation activate-type \
--type-name <resource-type-name> \
--publisher-id bb989456c78c398a858fef18f2ca1bfc1fbba082 \
--type RESOURCE \
--execution-role-arn <role-arn>
For example, in order to activate MongoDB::Atlas::AlertConfiguration, run:
aws cloudformation activate-type \
--type-name
MongoDB::Atlas::AlertConfiguration \
--publisher-id bb989456c78c398a858fef18f2ca1bfc1fbba082 \
--type RESOURCE \
--execution-role-arn <role-arn>
Running unit tests:
Ensure unit tests for each resource (located in /test/[resource-folder]/index.test.ts) are updated and successful.
Run unit tests with npx projen test inside the resource folder
# if you created an L1 resource
cd test/l1-resources/[resource-folder]
# if you created an L2 resource
cd test/l2-resources/[resource-folder]
# if you created an L3 resource
cd test/l3-resources/[resource-folder]
npx projen test
Testing the resource in a CFN stack:
Build the construct by running npx projen build.
Navigate inside /dist/js and copy the.tgz file. You will use this in the next steps.
Create a CDK test app: We will be using a CDK app to test our construct by using the app to create, update and delete AWS CloudFormation stacks.
Create the CDK app by running the following in a terminal: (refer AWS walkthrough for details):
mkdir hello-cdk
cd hello-cdk
cdk init app --language typescript
# build the app:
npm run build
Copy the .tgz file from step #2 inside the node_modules folder in your CDK test app.
Import your CDK construct in a testing project.
Use the construct in your app with appropriate parameters.
[Optional, not applicable for L2/L3 constructs] If you need help getting test parameters to use with the constructs you can use ./cfn-resources/cfn-testing-helper.sh. Refer “Getting test parameters” for creating a stack here for details.