Skip to content

Commit cf1d5c0

Browse files
feat: INTMDB-1040 L3 atlas basic serverles (#121)
Co-authored-by: TSowbaranika <[email protected]>
1 parent 41386f7 commit cf1d5c0

File tree

8 files changed

+704
-0
lines changed

8 files changed

+704
-0
lines changed

API.md

Lines changed: 215 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// This CDK L3 example creates a MongoDB Atlas project, cluster, databaseUser, and projectIpAccessList
2+
import * as cdk from 'aws-cdk-lib';
3+
import { Construct } from 'constructs';
4+
import { AtlasServerlessBasic, ServerlessInstanceProviderSettingsProviderName } from 'awscdk-resources-mongodbatlas';
5+
6+
interface AtlasStackProps {
7+
readonly orgId: string;
8+
readonly profile: string;
9+
readonly region: string;
10+
readonly ip: string;
11+
readonly continuousBackupEnabled: string;
12+
readonly terminationProtectionEnabled: 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 atlasBasic = new AtlasServerlessBasic(this, 'AtlasServerlessBasic', {
21+
serverlessProps: {
22+
projectId: atlasProps.orgId,
23+
profile: atlasProps.profile,
24+
continuousBackupEnabled: atlasProps.continuousBackupEnabled,
25+
providerSettings: {
26+
providerName: ServerlessInstanceProviderSettingsProviderName.SERVERLESS
27+
},
28+
terminationProtectionEnabled: atlasProps.terminationProtectionEnabled
29+
},
30+
projectProps: {
31+
orgId: atlasProps.orgId,
32+
},
33+
34+
ipAccessListProps: {
35+
accessList:[
36+
{ ipAddress: atlasProps.ip, comment: 'My first IP address' }
37+
]
38+
},
39+
profile: atlasProps.profile,
40+
});
41+
42+
}
43+
44+
getContextProps(): AtlasStackProps {
45+
const orgId = this.node.tryGetContext('orgId');
46+
if (!orgId){
47+
throw "No context value specified for orgId. Please specify via the cdk context."
48+
}
49+
const profile = this.node.tryGetContext('profile') ?? 'default';
50+
const terminationProtectionEnabled = this.node.tryGetContext('terminationProtectionEnabled');
51+
const continuousBackupEnabled = this.node.tryGetContext('continuousBackupEnabled');
52+
const region = this.node.tryGetContext('region') ?? "US_EAST_1";
53+
const ip = this.node.tryGetContext('ip');
54+
if (!ip){
55+
throw "No context value specified for ip. Please specify via the cdk context."
56+
}
57+
58+
return {
59+
orgId,
60+
terminationProtectionEnabled,
61+
continuousBackupEnabled,
62+
profile,
63+
region,
64+
ip
65+
}
66+
}
67+
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,7 @@ export * from "./l2-resources/third-party-integration";
322322

323323
// L3 Constructors
324324
export * from "./l3-resources/atlas-basic";
325+
export * from "./l3-resources/atlas-serverless-basic";
325326
export * from "./l3-resources/atlas-basic-private-endpoint";
326327
export * from "./l3-resources/encryption-at-rest-express";
327328

0 commit comments

Comments
 (0)