Developer guide
Setting up MDAA Dev Environment
-
Clone this repo.
-
Install NPM/Node
-
NPM Install CDK, Lerna
-
Authenticate to the MDAA NPM Repo
-
From the root of the repo, run npm install:
npm install -
After making code changes, run a build/test using lerna:
lerna run build && lerna run testAlternatively, you can run
npm run build && npm run testin each individual package you have modified.
Version Requirements
MDAA has specific version requirements for development:
-
Node.js: Version 22.x or higher
-
NPM: Version 10.x or higher
-
AWS CDK: Version 2.220.0 (as of v1.3.0)
-
CDK Nag: Version 2.37.55 (as of v1.3.0)
-
Docker: Required for building Lambda layers and certain modules (e.g., GAIA)
Testing
Testing Overview
The testing approach for MDAA changes varies depending on the type of package being tested (App, Stack, or Construct). Before testing, ensure that the entire MDAA repo is cloned, bootstrapped, and built.
Testing Constructs and Stacks
Constructs and Stacks should be tested via unit testing using the CDK Assertions framework. This framework can be used to ensure that the CFN resources produced by a MDAA construct or stack are defined as expected in the resulting CFN template. Specific attention should be paid in these unit tests to any resource property which has compliance implications.
Example Construct/Stack Unit Tests
import { MdaaTestApp } from "@aws-mdaa/testing"; import { Stack } from "aws-cdk-lib"; import { MdaaKmsKey } from '@aws-mdaa/kms-constructs'; import { Match, Template } from "aws-cdk-lib/assertions"; import { NagSuppressions } from "cdk-nag"; import { MdaaBucket, MdaaBucketProps } from "../lib"; describe( 'MDAA Construct Compliance Tests', () => { const constructTestApp = new MdaaTestApp() const constructTestStack = new Stack( constructTestApp, "test-stack" ) const testKey = MdaaKmsKey.fromMdaaKeyArn( constructTestStack, "test-key", "arn:test-partition:kms:test-region:test-account:key/test-key" ) const testContstructProps: MdaaBucketProps = { naming: constructTestApp.naming, bucketName: "test-bucket", encryptionKey: testKey } const testConstruct = new MdaaBucket( constructTestStack, "test-construct", testContstructProps ) NagSuppressions.addResourceSuppressions( testConstruct, [ { id: 'NIST.800.53.R5-S3BucketReplicationEnabled', reason: 'MDAA Data Lake does not use bucket replication.' }, { id: 'HIPAA.Security-S3BucketReplicationEnabled', reason: 'MDAA Data Lake does not use bucket replication.' } ], true ); constructTestApp.checkCdkNagCompliance( constructTestStack ) const template = Template.fromStack( constructTestStack ); test( 'BucketName', () => { template.hasResourceProperties( "AWS::S3::Bucket", { "BucketName": constructTestApp.naming.resourceName( "test-bucket" ) } ) } ) test( 'DefaultEncryption', () => { template.hasResourceProperties( "AWS::S3::Bucket", { "BucketEncryption": { "ServerSideEncryptionConfiguration": [ { "BucketKeyEnabled": true, "ServerSideEncryptionByDefault": { "SSEAlgorithm": "aws:kms", "KMSMasterKeyID": testKey.keyArn } } ] } } ) } ) } )
Testing Apps
MDAA Apps can be developed and tested like any other CDK app. This typically involves a cdk list/synth/diff/deploy from within the App source directory, while also providing the necessary context values which would otherwise be provided by the MDAA framework. Executing the cdk command will result in the application source code being built. However, any changes made in underlying dependencies (such as stacks and constructs) would require either a lerna run build at the root of the MDAA repo, or npm run build in the package folder for each of the modified dependencies.
Example CDK Command Invoking a MDAA App
cdk synth --require-approval never -c org="" -c env="" -c domain="" -c module_configs="" -c tag_configs="" -c module_name="" --all