Skip to content

Commit 41386f7

Browse files
authored
feat: federated database instance private link query limit (#118)
1 parent 6662f51 commit 41386f7

File tree

18 files changed

+5912
-1440
lines changed

18 files changed

+5912
-1440
lines changed

API.md

Lines changed: 4471 additions & 1439 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { CfnFederatedSettingsOrgRoleMapping } from 'awscdk-resources-mongodbatlas';
4+
5+
interface AtlasStackProps {
6+
readonly tenantName: string;
7+
readonly projectId: string;
8+
readonly profile: string;
9+
readonly roleId: string;
10+
readonly testS3Bucket: string;
11+
}
12+
13+
const UNDEFINED = "UNDEFINED";
14+
15+
export class CDKFederatedDatabaseInstanceExample 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 federatedDatabaseInstance = new CfnFederatedSettingsOrgRoleMapping(this, 'FederatedDatabaseInstance', {
21+
tenantName: atlasProps.tenantName,
22+
projectId: atlasProps.projectId,
23+
profile: atlasProps.profile,
24+
cloudProviderConfig: {
25+
roleId: atlasProps.roleId,
26+
testS3Bucket: atlasProps.testS3Bucket,
27+
},
28+
dataProcessRegion: {
29+
region: "VIRGINIA_USA",
30+
},
31+
storage: {
32+
databases: [
33+
{
34+
maxWildcardCollections: "50",
35+
name: "cfn-df-dbs",
36+
},
37+
],
38+
},
39+
});
40+
41+
new cdk.CfnOutput(this, "externalID", {
42+
value: (federatedDatabaseInstance.attrExternalId ?? UNDEFINED).toString(),
43+
exportName: "externalId",
44+
});
45+
46+
new cdk.CfnOutput(this, "HostName", {
47+
value: (
48+
cdk.Fn.select(0, federatedDatabaseInstance.attrHostNames) ?? UNDEFINED
49+
).toString(),
50+
exportName: "HostName",
51+
});
52+
}
53+
54+
getContextProps(): AtlasStackProps {
55+
const projectId = this.node.tryGetContext('projId');
56+
if (!projectId){
57+
throw "No context value specified for projId. Please specify via the cdk context."
58+
}
59+
60+
const tenantName = this.node.tryGetContext('tenantName');
61+
const profile = this.node.tryGetContext('profile') ?? 'default';
62+
const roleId = this.node.tryGetContext('roleId');
63+
const testS3Bucket = this.node.tryGetContext('testS3Bucket');
64+
65+
return {
66+
tenantName,
67+
projectId,
68+
profile,
69+
roleId,
70+
testS3Bucket
71+
}
72+
}
73+
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { CfnFederatedQueryLimit, CfnFederatedQueryLimitPropsLimitName} from 'awscdk-resources-mongodbatlas';
4+
5+
interface AtlasStackProps {
6+
readonly projectId: string;
7+
readonly profile: string;
8+
readonly role: string;
9+
readonly tenantName: string;
10+
readonly limitName: string;
11+
readonly value: string;
12+
}
13+
14+
export class CdkTestingStack extends cdk.Stack {
15+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
16+
super(scope, id, props);
17+
18+
const atlasProps = this.getContextProps();
19+
new CfnFederatedQueryLimit(this, 'Federation', {
20+
profile: atlasProps.profile,
21+
projectId: atlasProps.projectId,
22+
tenantName: atlasProps.tenantName,
23+
limitName : atlasProps.limitName,
24+
value: atlasProps.value
25+
});
26+
}
27+
28+
getContextProps(): AtlasStackProps {
29+
const projectId = this.node.tryGetContext('projId');
30+
if (!projectId){
31+
throw "No context value specified for projId. Please specify via the cdk context."
32+
}
33+
34+
const profile = this.node.tryGetContext('profile') ?? 'default';
35+
const role = this.node.tryGetContext('role');
36+
const tenantName = this.node.tryGetContext('tenantName');
37+
const limitName= this.node.tryGetContext('limitName') ?? CfnFederatedQueryLimitPropsLimitName.BYTES_PROCESSED_QUERY;
38+
const value= this.node.tryGetContext("value") ?? "2000000000"
39+
return {
40+
projectId,
41+
profile,
42+
role,
43+
tenantName,
44+
limitName,
45+
value
46+
}
47+
}
48+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { CfnPrivatelinkEndpointServiceDataFederationOnlineArchive } from 'awscdk-resources-mongodbatlas';
4+
5+
interface AtlasStackProps {
6+
readonly projId: string;
7+
readonly endpointId: string;
8+
readonly profile: string;
9+
}
10+
11+
export class CDKFederatedDatabaseInstanceExample extends cdk.Stack {
12+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
13+
super(scope, id, props);
14+
15+
const atlasProps = this.getContextProps();
16+
const federatedDatabaseInstance = new CfnPrivatelinkEndpointServiceDataFederationOnlineArchive(this, 'FederatedDatabaseInstance', {
17+
projectId: atlasProps.projId,
18+
endpointId: atlasProps.endpointId,
19+
type: "DATA_LAKE",
20+
comment: "online-archive-private-link-endpoint",
21+
profile: atlasProps.profile,
22+
});
23+
}
24+
25+
getContextProps(): AtlasStackProps {
26+
const projId = this.node.tryGetContext('projId');
27+
if (!projId){
28+
throw "No context value specified for projId. Please specify via the cdk context."
29+
}
30+
31+
const endpointId = this.node.tryGetContext('endpointId');
32+
const profile = this.node.tryGetContext('profile') ?? 'default';
33+
34+
return {
35+
projId,
36+
endpointId,
37+
profile
38+
}
39+
}
40+
}

src/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,32 @@ export {
3434

3535
export { CfnAuditing, CfnAuditingProps } from "./l1-resources/auditing";
3636

37+
export {
38+
CfnFederatedQueryLimit,
39+
CfnFederatedQueryLimitProps,
40+
CfnFederatedQueryLimitPropsLimitName,
41+
} from "./l1-resources/federated-query-limit";
42+
43+
export {
44+
CfnFederatedDatabaseInstance,
45+
CfnFederatedDatabaseInstanceProps,
46+
CloudProviderConfig,
47+
DataProcessRegion,
48+
Storage,
49+
Database,
50+
Store,
51+
Collection,
52+
DataSource,
53+
ReadPreference,
54+
TagSet,
55+
View,
56+
} from "./l1-resources/federated-database-instance";
57+
58+
export {
59+
CfnPrivatelinkEndpointServiceDataFederationOnlineArchive,
60+
CfnPrivatelinkEndpointServiceDataFederationOnlineArchiveProps,
61+
} from "./l1-resources/privatelink-endpoint-service-data-federation-online-archive";
62+
3763
export {
3864
CfnCloudBackUpRestoreJobs,
3965
CfnCloudBackUpRestoreJobsProps,

0 commit comments

Comments
 (0)