Developer guide
Setting up Secure AI Foundations Dev Environment
-
Clone this repo.
-
Install NPM/Node
-
NPM Install CDK
-
Authenticate to the Secure AI Foundations NPM Repo
-
From the root of the repo, run npm install:
npm install -
After making code changes, run a build/test from the root of the repo:
npm run build && npm run testTask orchestration uses nx (invoked through these npm scripts).
npm run buildandnpm run testbuild and test only the affected packages; usenpm run build:allandnpm run test:allto run against every package without the nx cache. Alternatively, you can runnpm run build && npm run testin each individual package you have modified.
Version Requirements
Secure AI Foundations has specific version requirements for development:
-
Node.js: Version 22.x or higher
-
NPM: Version 10.x or higher
-
Docker: Required for building Lambda layers and certain modules (e.g., GAIA)
Testing
Testing Overview
The testing approach for Secure AI Foundations changes varies depending on the type of package being tested (App, Stack, or Construct). Before testing, verify 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 verify that the CFN resources produced by a Secure AI Foundations 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
Secure AI Foundations 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 Secure AI Foundations 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 npm 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 Secure AI Foundations App
cdk synth --require-approval never -c org="" -c env="" -c domain="" -c module_configs="" -c tag_configs="" -c module_name="" --all