Skip to content

Commit 6662493

Browse files
authored
Added ProviderName to cluster (#79)
1 parent d541570 commit 6662493

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed

API.md

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ export {
8585
AdvancedRegionConfig,
8686
CfnCluster,
8787
CfnClusterPropsEncryptionAtRestProvider,
88+
AdvancedRegionConfigProviderName,
8889
} from "./l1-resources/clusters";
8990

9091
export {

src/l1-resources/clusters/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -594,6 +594,11 @@ export interface AdvancedRegionConfig {
594594
*/
595595
readonly regionName?: string;
596596

597+
/**
598+
* @schema advancedRegionConfig#ProviderName
599+
*/
600+
readonly providerName?: AdvancedRegionConfigProviderName;
601+
597602
/**
598603
* @schema advancedRegionConfig#AnalyticsSpecs
599604
*/
@@ -629,6 +634,7 @@ export function toJson_AdvancedRegionConfig(
629634
AnalyticsAutoScaling: toJson_AdvancedAutoScaling(obj.analyticsAutoScaling),
630635
AutoScaling: toJson_AdvancedAutoScaling(obj.autoScaling),
631636
RegionName: obj.regionName,
637+
ProviderName: obj.providerName,
632638
AnalyticsSpecs: toJson_Specs(obj.analyticsSpecs),
633639
ElectableSpecs: toJson_Specs(obj.electableSpecs),
634640
Priority: obj.priority,
@@ -730,6 +736,18 @@ export function toJson_AdvancedAutoScaling(
730736
}
731737
/* eslint-enable max-len, quote-props */
732738

739+
/**
740+
* @schema AdvancedRegionConfigProviderName
741+
*/
742+
export enum AdvancedRegionConfigProviderName {
743+
/** AWS */
744+
AWS = "AWS",
745+
/** GCP */
746+
GCP = "GCP",
747+
/** AZURE */
748+
AZURE = "AZURE",
749+
}
750+
733751
/**
734752
* @schema specs
735753
*/
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// Copyright 2023 MongoDB Inc
2+
//
3+
// Licensed under the Apache License, Version 2.0 (the "License");
4+
// you may not use this file except in compliance with the License.
5+
// You may obtain a copy of the License at
6+
//
7+
// http://www.apache.org/licenses/LICENSE-2.0
8+
//
9+
// Unless required by applicable law or agreed to in writing, software
10+
// distributed under the License is distributed on an "AS IS" BASIS,
11+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
// See the License for the specific language governing permissions and
13+
// limitations under the License.
14+
15+
import { App, Stack } from "aws-cdk-lib";
16+
import { Template } from "aws-cdk-lib/assertions";
17+
import { CfnCluster } from "../../../src/l1-resources/clusters";
18+
19+
const RESOURCE_NAME = "MongoDB::Atlas::Cluster";
20+
const PROJECT_ID = "testProjectId";
21+
const CLUSTER_NAME = "test_host_name";
22+
const PROFILE = "default";
23+
24+
test("Cluster construct should contain default properties", () => {
25+
const mockApp = new App();
26+
const stack = new Stack(mockApp);
27+
28+
new CfnCluster(stack, "cluster-testing-stack", {
29+
projectId: PROJECT_ID,
30+
name: CLUSTER_NAME,
31+
mongoDbMajorVersion: "6.0",
32+
clusterType: "REPLICASET",
33+
backupEnabled: true,
34+
profile: PROFILE,
35+
replicationSpecs: [
36+
{
37+
numShards: 1,
38+
advancedRegionConfigs: [
39+
{
40+
autoScaling: {
41+
diskGb: {
42+
enabled: true,
43+
},
44+
compute: {
45+
enabled: true,
46+
scaleDownEnabled: false,
47+
maxInstanceSize: "M40",
48+
},
49+
},
50+
electableSpecs: {
51+
ebsVolumeType: "PROVISIONED",
52+
instanceSize: "M30",
53+
nodeCount: 3,
54+
diskIops: "2000",
55+
},
56+
priority: 7,
57+
regionName: "EU_WEST_1",
58+
},
59+
],
60+
},
61+
],
62+
});
63+
64+
const template = Template.fromStack(stack);
65+
66+
template.hasResourceProperties(RESOURCE_NAME, {
67+
ProjectId: PROJECT_ID,
68+
Name: CLUSTER_NAME,
69+
MongoDBMajorVersion: "6.0",
70+
ClusterType: "REPLICASET",
71+
BackupEnabled: true,
72+
Profile: PROFILE,
73+
ReplicationSpecs: [
74+
{
75+
NumShards: 1,
76+
AdvancedRegionConfigs: [
77+
{
78+
AutoScaling: {
79+
DiskGB: {
80+
Enabled: true,
81+
},
82+
Compute: {
83+
Enabled: true,
84+
ScaleDownEnabled: false,
85+
MaxInstanceSize: "M40",
86+
},
87+
},
88+
ElectableSpecs: {
89+
EbsVolumeType: "PROVISIONED",
90+
InstanceSize: "M30",
91+
NodeCount: 3,
92+
DiskIOPS: "2000",
93+
},
94+
Priority: 7,
95+
RegionName: "EU_WEST_1",
96+
},
97+
],
98+
},
99+
],
100+
});
101+
});

0 commit comments

Comments
 (0)