Skip to content

Commit 9fb0de7

Browse files
authored
feat: Adds project tags (#268)
1 parent 62ec858 commit 9fb0de7

File tree

4 files changed

+57
-27
lines changed

4 files changed

+57
-27
lines changed

API.md

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

examples/l1-resources/project.ts

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ interface AtlasStackProps {
88
readonly profile: string;
99
readonly projName: string;
1010
readonly regionUsageRestrictions: string;
11+
readonly tags: Map<string, string>;
12+
readonly apiKey: string
13+
readonly teamId: string;
1114
}
1215

1316
export class CdkTestingStack extends cdk.Stack {
@@ -31,17 +34,18 @@ export class CdkTestingStack extends cdk.Stack {
3134
},
3235
projectApiKeys: [
3336
{
34-
key: "64f75b66e205b21647ae1e58",
37+
key: atlasProps.apiKey,
3538
roleNames: ["GROUP_CLUSTER_MANAGER"]
3639
}
3740
],
3841
projectTeams: [
3942
{
40-
teamId: "647a04045878135ce0e8bfff",
43+
teamId: atlasProps.teamId,
4144
roleNames: ["GROUP_OWNER"]
4245
}
43-
]
44-
});
46+
],
47+
tags: atlasProps.tags,
48+
});
4549

4650
}
4751

@@ -53,11 +57,23 @@ export class CdkTestingStack extends cdk.Stack {
5357
const projName = this.node.tryGetContext('projName') ?? 'test-proj';
5458
const profile = this.node.tryGetContext('profile') ?? 'default';
5559
const regionUsageRestrictions= this.node.tryGetContext('regionUsageRestrictions') ?? "NONE";
60+
const tags = this.node.tryGetContext('tags') ?? {Owner: 'AWS-CDK-EXAMPLE'};
61+
const apiKey = this.node.tryGetContext('apiKey');
62+
if (!apiKey){
63+
throw "No context value specified for apiKey. Please specify via the cdk context."
64+
}
65+
const teamId = this.node.tryGetContext('teamId');
66+
if (!teamId){
67+
throw "No context value specified for teamId. Please specify via the cdk context."
68+
}
5669
return {
5770
projName,
5871
orgId,
5972
profile,
60-
regionUsageRestrictions
73+
regionUsageRestrictions,
74+
tags,
75+
apiKey,
76+
teamId,
6177
}
6278
}
6379
}

src/l1-resources/project/index.ts

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,6 @@ export interface CfnProjectProps {
2929
*/
3030
readonly withDefaultAlertsSettings?: boolean;
3131

32-
/**
33-
* The number of Atlas clusters deployed in the project.
34-
*
35-
* @schema CfnProjectProps#ClusterCount
36-
*/
37-
readonly clusterCount?: number;
38-
3932
/**
4033
* @schema CfnProjectProps#ProjectSettings
4134
*/
@@ -68,6 +61,11 @@ export interface CfnProjectProps {
6861
* @schema CfnProjectProps#RegionUsageRestrictions
6962
*/
7063
readonly regionUsageRestrictions?: string;
64+
65+
/**
66+
* @schema CfnProjectProps#Tags
67+
*/
68+
readonly tags?: any;
7169
}
7270

7371
/**
@@ -84,12 +82,12 @@ export function toJson_CfnProjectProps(
8482
Name: obj.name,
8583
OrgId: obj.orgId,
8684
WithDefaultAlertsSettings: obj.withDefaultAlertsSettings,
87-
ClusterCount: obj.clusterCount,
8885
ProjectSettings: toJson_ProjectSettings(obj.projectSettings),
8986
Profile: obj.profile,
9087
ProjectTeams: obj.projectTeams?.map((y) => toJson_ProjectTeam(y)),
9188
ProjectApiKeys: obj.projectApiKeys?.map((y) => toJson_ProjectApiKey(y)),
9289
RegionUsageRestrictions: obj.regionUsageRestrictions,
90+
Tags: obj.tags,
9391
};
9492
// filter undefined values
9593
return Object.entries(result).reduce(
@@ -284,6 +282,10 @@ export class CfnProject extends cdk.CfnResource {
284282
* Attribute `MongoDB::Atlas::Project.ProjectOwnerId`
285283
*/
286284
public readonly attrProjectOwnerId: string;
285+
/**
286+
* Attribute `MongoDB::Atlas::Project.ClusterCount`
287+
*/
288+
public readonly attrClusterCount: number;
287289

288290
/**
289291
* Create a new `MongoDB::Atlas::Project`.
@@ -303,5 +305,6 @@ export class CfnProject extends cdk.CfnResource {
303305
this.attrId = cdk.Token.asString(this.getAtt("Id"));
304306
this.attrCreated = cdk.Token.asString(this.getAtt("Created"));
305307
this.attrProjectOwnerId = cdk.Token.asString(this.getAtt("ProjectOwnerId"));
308+
this.attrClusterCount = cdk.Token.asNumber(this.getAtt("ClusterCount"));
306309
}
307310
}

0 commit comments

Comments
 (0)