This folder contains examples of using MongoDB Atlas AWS CDK constructs that will help you get started and quickly build your own applications.
You must configure API keys to authenticate with your MongoDB Atlas organization.
To activate a public extension, create an execution role and pass the ARN of the role as an input. Use this template to create a new CloudFormation stack to create the execution role.
You must then activate the Public extension from your AWS console. You have to do this in each AWS Account and in each AWS Region. Use this link to register extensions on CloudFormation.
Consult the AWS CDK | Getting Started guide for full details. In general, you will need to:
- Install & configure awscli
- Configure AWS credentials
- Set your default region
- Configure your programming environment.
- Examples in this folder assume Typescript
- Install the AWS CDK
npm install -g aws-cdk
- Bootstrap your AWS account to enable CDK deployments
cdk bootstrap aws://ACCOUNT-NUMBER/REGION
A profile should be created in the AWS Secrets Manager, containing the MongoDB Atlas Programmatic API Key.
Use this template to create a new CloudFormation stack for the default profile that all resources will attempt to use unless a different override is specified.
Once your prerequisites are configured, use the examples in this folder as a starting template for a resource to quickly create a new AWS cdk application.
For example, the cluster example creates a project & cluster in your MongoDB Atlas organization, using a Typescript application. The example requires the following to be configured:
- A new CDK application, in a folder named
cdk-testing
cdk init app --language typescript
- MongoDB Atlas AWS CDK library for project & cluster constructs
npm install awscdk-resources-mongodbatlas
- Replace the generated
lib/cdk-testing-stack.ts
file with the cluster example content - Your application to be built successfully
npm run build
- You can deploy and monitor the progress using the cdk tooling, with parameters configured through the CDK runtime context
cdk deploy --context orgId=<ORG_ID>