Skip to content

Commit 167fb46

Browse files
feat: CDK L1 resource added Datalakes pipelines and atlas gov support (#127)
Co-authored-by: Adelmar92 <[email protected]> Co-authored-by: Adelmar92 <[email protected]>
1 parent 5cd9c68 commit 167fb46

File tree

12 files changed

+890
-22
lines changed

12 files changed

+890
-22
lines changed

API.md

Lines changed: 26 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
// This example creates a project and a cluster in Atlas using the L1 resources.
2+
import * as cdk from 'aws-cdk-lib';
3+
import { Construct } from 'constructs';
4+
import { CfnDataLakePipeline} from 'awscdk-resources-mongodbatlas';
5+
6+
interface AtlasStackProps {
7+
readonly projId: string;
8+
readonly profile: string;
9+
readonly name: string;
10+
readonly clusterName: string;
11+
readonly collectionName: string;
12+
readonly dbName: string;
13+
}
14+
15+
export class CdkTestingStack extends cdk.Stack {
16+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
17+
super(scope, id, props);
18+
19+
const atlasProps = this.getContextProps();
20+
const sink = {"partitionFields" :[{
21+
"fieldName": "testpartition2",
22+
"order": 0
23+
}]};
24+
25+
const source = {
26+
"clusterName": atlasProps.clusterName,
27+
"collectionName": atlasProps.collectionName,
28+
"databaseName": atlasProps.dbName
29+
};
30+
const transform = [
31+
{
32+
"field" :"testtransformFeild",
33+
"type": "EXCLUDE"
34+
}
35+
];
36+
37+
const datalakePipeline = new CfnDataLakePipeline(this, 'datalakePipeline', {
38+
projectId: atlasProps.projId,
39+
profile: atlasProps.profile,
40+
name: atlasProps.name,
41+
sink:sink,
42+
source: source,
43+
transformations: transform
44+
});
45+
46+
}
47+
48+
getContextProps(): AtlasStackProps {
49+
const projId = this.node.tryGetContext('projId');
50+
if (!projId){
51+
throw "No context value specified for projId. Please specify via the cdk context."
52+
}
53+
const name = this.node.tryGetContext('name');
54+
const clusterName = this.node.tryGetContext('clusterName');
55+
const profile = this.node.tryGetContext('profile') ?? 'default';
56+
const dbName = this.node.tryGetContext('dbName');
57+
const collectionName = this.node.tryGetContext('collectionName');
58+
59+
60+
return {
61+
projId,
62+
profile,
63+
name,
64+
dbName,
65+
collectionName,
66+
clusterName
67+
}
68+
}
69+
}

examples/l1-resources/project.ts

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ interface AtlasStackProps {
77
readonly orgId: string;
88
readonly profile: string;
99
readonly projName: string;
10+
readonly regionUsageRestrictions: string;
1011
}
1112

1213
export class CdkTestingStack extends cdk.Stack {
@@ -18,7 +19,28 @@ export class CdkTestingStack extends cdk.Stack {
1819
const projectRes = new CfnProject(this, 'ProjectResource', {
1920
name: atlasProps.projName,
2021
orgId: atlasProps.orgId,
21-
profile: atlasProps.profile
22+
profile: atlasProps.profile,
23+
regionUsageRestrictions: atlasProps.regionUsageRestrictions,
24+
projectSettings: {
25+
isCollectDatabaseSpecificsStatisticsEnabled: false,
26+
isDataExplorerEnabled: false,
27+
isPerformanceAdvisorEnabled: false,
28+
isRealtimePerformancePanelEnabled: false,
29+
isSchemaAdvisorEnabled: true,
30+
isExtendedStorageSizesEnabled: true
31+
},
32+
projectApiKeys: [
33+
{
34+
key: "64f75b66e205b21647ae1e58",
35+
roleNames: ["GROUP_CLUSTER_MANAGER"]
36+
}
37+
],
38+
projectTeams: [
39+
{
40+
teamId: "647a04045878135ce0e8bfff",
41+
roleNames: ["GROUP_OWNER"]
42+
}
43+
]
2244
});
2345

2446
}
@@ -30,11 +52,12 @@ export class CdkTestingStack extends cdk.Stack {
3052
}
3153
const projName = this.node.tryGetContext('projName') ?? 'test-proj';
3254
const profile = this.node.tryGetContext('profile') ?? 'default';
33-
55+
const regionUsageRestrictions= this.node.tryGetContext('regionUsageRestrictions') ?? "NONE";
3456
return {
3557
projName,
3658
orgId,
37-
profile
59+
profile,
60+
regionUsageRestrictions
3861
}
3962
}
4063
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# cluster
2+
3+
The official [MongoDB Atlas](https://www.mongodb.com/) AWS CDK resource for Node.js.
4+
5+
> AWS CDK [L1 construct] and data structures for the [AWS CloudFormation Registry] type `MongoDB::Atlas::Cluster` v1.0.0.
6+
7+
[L1 construct]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html
8+
[AWS CloudFormation Registry]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html
9+
10+
## Description
11+
12+
Atlas Data Lake takes snapshots of your Atlas cluster, so you can easily analyze data over time. As data is ingested, Atlas Data Lake reformats, creates partition indexes, and partitions data, creating an isolated workload ready to support large and complex queries without impacting your production application.
13+
14+
## MongoDB Atlas API Docs
15+
16+
For more information about the API refer to: [API Endpoints](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Data-Lake-Pipelines/operation/createPipeline)
17+
18+
## Usage
19+
20+
In order to use this library, you will need to activate this AWS CloudFormation Registry type in your account. You can do this via the AWS Management Console or using the [AWS CLI](https://aws.amazon.com/cli/) using the following command:
21+
22+
```sh
23+
aws cloudformation activate-type \
24+
--type-name MongoDB::Atlas::DataLakePipeline \
25+
--publisher-id bb989456c78c398a858fef18f2ca1bfc1fbba082 \
26+
--type RESOURCE \
27+
--execution-role-arn ROLE-ARN
28+
```
29+
30+
Alternatively:
31+
32+
```sh
33+
aws cloudformation activate-type \
34+
--public-type-arn arn:aws:cloudformation:us-east-1::type/resource/bb989456c78c398a858fef18f2ca1bfc1fbba082/MongoDB-Atlas-Cluster \
35+
--execution-role-arn ROLE-ARN
36+
```
37+
38+
You can find more information about activating this type in the [AWS CloudFormation documentation](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry-public.html).
39+
40+
41+
## Example: [cluster.ts](../../../examples/l1-resources/dataLakePipeline.ts)
42+
```ts
43+
import { CfnDataLakePipeline } from 'awscdk-resources-mongodbatlas';
44+
45+
const clusterRes = new CfnDataLakePipeline(this, 'ClusterResource', {
46+
name: atlasProps.clusterName,
47+
projectId: projectRes.attrId,
48+
profile: atlasProps.profile,
49+
clusterType: atlasProps.clusterType,
50+
backupEnabled: true,
51+
pitEnabled: false,
52+
replicationSpecs: [{
53+
numShards: 1,
54+
advancedRegionConfigs: [{
55+
autoScaling: {
56+
diskGb: {
57+
enabled: true,
58+
},
59+
compute: {
60+
enabled: false,
61+
scaleDownEnabled: false,
62+
},
63+
},
64+
analyticsSpecs: {
65+
ebsVolumeType: "STANDARD",
66+
instanceSize: atlasProps.instanceSize,
67+
nodeCount: 3,
68+
},
69+
electableSpecs: {
70+
ebsVolumeType: "STANDARD",
71+
instanceSize: atlasProps.instanceSize,
72+
nodeCount: 3,
73+
},
74+
readOnlySpecs: {
75+
ebsVolumeType: "STANDARD",
76+
instanceSize: atlasProps.instanceSize,
77+
nodeCount: 3,
78+
},
79+
priority: 7,
80+
regionName: atlasProps.region,
81+
}]
82+
}]
83+
});
84+
85+
```
86+
87+
## Feedback
88+
89+
This library is auto-generated and published to all supported programming languages by the [cdklabs/cdk-cloudformation] project based on the API schema published for `MongoDB::Atlas::Cluster`.
90+
91+
* Issues related to this generated library should be [reported here](https://github.com/cdklabs/cdk-cloudformation/issues/new?title=Issue+with+%40cdk-cloudformation%2Fmongodb-atlas-cluster+v1.0.0).
92+
* Issues related to `MongoDB::Atlas::Cluster` should be reported to the [publisher](https://github.com/mongodb/mongodbatlas-cloudformation-resources/issues).
93+
* Feature requests should be [reported here](https://feedback.mongodb.com/forums/924145-atlas?category_id=392596)
94+
95+
[cdklabs/cdk-cloudformation]: https://github.com/cdklabs/cdk-cloudformation
96+
97+
## License
98+
99+
Distributed under the Apache-2.0 License.

0 commit comments

Comments
 (0)