Contributing to the Framework
This is a TypeScript project managed by the projen tool. To contribute to the framework sub project, you need to have the following prerequisites:
Prerequisites
- Node.js v20
- Yarn
- Docker running locally
Setup
-
Clone the repository:
git clone https://github.com/awslabs/data-solutions-framework-on-aws.git
-
Navigate to the repository directory:
cd data-solutions-framework-on-aws
-
Install the project dependencies:
yarn install
-
Build the project using projen:
npx projen build
Now you're ready to start contributing to the framework sub project!
Making Changes
-
Create a new branch for your changes:
git checkout -b feat/my-feature-branch
-
Make your changes to the code in the framework directory.
-
Build the project again to ensure everything compiles correctly:
npx projen build
Testing changes
- Validate the changes in an AWS account
- Use the following code in a file (Ex:
mytest.e2e.test.ts
) in theframework/test/e2e
folder and update corresponding values.
- Use the following code in a file (Ex:
This file used to iteratively test the construct during development should not be committed to the repository. Only standard e2e tests should be committed.
/**
* Testing my changes
*
* @group mytests
*/
import * as cdk from 'aws-cdk-lib';
import { TestStack } from './test-stack';
jest.setTimeout(10000000);
// GIVEN
const app = new cdk.App();
const stack = new Stack(app, 'E2eStack');
const testStack = new TestStack('E2eTestStack', app, stack);
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true);
// LOGIC TO TEST
new cdk.CfnOutput(stack, 'MyOutput', {
value: <OUTPUT_VALUE_TO_TEST>,
});
let deployResult: Record<string, string>;
beforeAll(async() => {
// WHEN
deployResult = await testStack.deploy();
}, 10000000);
it('mytest', async () => {
// THEN
expect(deployResult.MyOutput).toContain('<VALUE_TO_TEST>');
});
- Deploy the stack
cd framework
npx jest --group=mytests
-
Iterate and re-deploy the stack
-
Create/update unit tests. They are required to validate the constructs at the Cloudformation level. Unit tests check the CFN template is matching what is expected. Follow the example of the
DataLakeStorage
here -
Create/update cdk-nag tests. They are required to validate the CDK code follows AWS Well Architected rules. Follow the example of the
DataLakeStorage
here. Add exceptions to CDK-nag when:- Errors or warnings are raised on constructs that are not in the scope of the test. For example when encapsulating another construct which is already tested via its own CDK-nag tests.
- CDK native resources (provided by CDK itself) are raising errors but it cannot be configured. For example, the CDK custom resource provider has limited configuration and it's not possible to customize the custom resource provider framework itself.
- There is no workaround to follow best practices. For example, IAM permissions contains wildcards and can't be scoped down because the resource ID is unknown.
-
Create/update e2e tests. They are required to test the deployment of the construct in an AWS account. Follow the example of the
DataLakeStorage
here -
Commit your changes:
git add .
git commit -m "My awesome changes" -
Push your changes to the remote repository:
git push origin my-feature-branch
-
Open a pull request on GitHub for your changes to be reviewed and merged.