Skip to content

Commit 60c5124

Browse files
oarbusiAgustinBettatimaastha
authored
feat: Adds Stream Instance L1 CDK construct (#233)
Co-authored-by: Agustin Bettati <[email protected]> Co-authored-by: maastha <[email protected]>
1 parent caf57eb commit 60c5124

File tree

9 files changed

+2655
-796
lines changed

9 files changed

+2655
-796
lines changed

API.md

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

examples/l1-resources/search-deployment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class CdkTestingStack extends cdk.Stack {
3535
throw "No context value specified for projectId. Please specify via the cdk context."
3636
}
3737
const clusterName = this.node.tryGetContext('clusterName');
38-
if (!projectId){
38+
if (!clusterName){
3939
throw "No context value specified for clusterName. Please specify via the cdk context."
4040
}
4141

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { CfnStreamInstance, StreamsDataProcessRegionCloudProvider } from 'awscdk-resources-mongodbatlas'
4+
import { env } from 'node:process';
5+
6+
interface AtlasStackProps {
7+
readonly projectId: string;
8+
readonly profile: string;
9+
readonly instanceName: string;
10+
readonly region: string;
11+
readonly tier: string;
12+
}
13+
14+
const app = new cdk.App();
15+
16+
17+
export class CdkTestStack extends cdk.Stack {
18+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
19+
super(scope, id, props);
20+
21+
const atlasProps = this.getContextProps();
22+
const streamInstance = new CfnStreamInstance(this, "stream-instance-testing-stack", {
23+
profile: atlasProps.profile,
24+
instanceName: atlasProps.instanceName,
25+
projectId: atlasProps.projectId,
26+
dataProcessRegion: {
27+
cloudProvider: StreamsDataProcessRegionCloudProvider.AWS,
28+
region: atlasProps.region,
29+
},
30+
streamConfig: {
31+
tier: atlasProps.tier,
32+
},
33+
});
34+
}
35+
36+
getContextProps(): AtlasStackProps {
37+
const profile = this.node.tryGetContext('profile') ?? 'default';
38+
const projectId = this.node.tryGetContext('projectId');
39+
const instanceName = this.node.tryGetContext('instanceName');
40+
const region = this.node.tryGetContext('region');
41+
const tier = this.node.tryGetContext('tier');
42+
if (!projectId) {
43+
throw "No context value specified for projectId. Please specify via the cdk context."
44+
}
45+
if (!instanceName) {
46+
throw "No context value specified for instanceName. Please specify via the cdk context."
47+
}
48+
if (!region) {
49+
throw "No context value specified for region. Please specify via the cdk context."
50+
}
51+
if (!tier) {
52+
throw "No context value specified for tier. Please specify via the cdk context."
53+
}
54+
55+
return {
56+
projectId,
57+
profile,
58+
instanceName,
59+
region,
60+
tier
61+
}
62+
}
63+
64+
}

src/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ L1 constructs are called Cfn (short for CloudFormation) resources. These resourc
4141
| search-deployment | The resource lets you create, edit and delete dedicated search nodes in a cluster. | [README.md](l1-resources/search-deployment/README.md) |
4242
| search-index | Returns, adds, edits, and removes Atlas Search indexes. Also returns and updates user-defined analyzers. | [README.md](l1-resources/search-index/README.md) |
4343
| serverless-instance | Returns, adds, edits, and removes serverless instances. | [README.md](l1-resources/serverless-instance/README.md) |
44+
| stream-instance | Returns, adds, edits, and removes stream instances instances. | [README.md](l1-resources/stream-instance/README.md) |
4445
| teams | Adds one team to the specified project. All members of the team share the same project access. To use this resource, the requesting API Key must have the Project User Admin role. This resource doesn't require the API Key to have an Access List. | [README.md](l1-resources/teams/README.md) |
4546
| third-party-integration | Returns, adds, edits, and removes third-party service integration configurations. MongoDB Cloud sends alerts to each third-party service that you configure. | [README.md](l1-resources/third-party-integration/README.md) |
4647
| trigger | View and manage your application's [triggers](https://www.mongodb.com/docs/atlas/app-services/triggers/overview/). | [README.md](l1-resources/trigger/README.md) |

src/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,20 @@ export {
341341
AwsPrivateEndpointConfig,
342342
} from "./l1-resources/serverless-private-endpoint";
343343

344+
export {
345+
CfnStreamInstance,
346+
StreamsDataProcessRegionCloudProvider,
347+
CfnStreamInstanceProps,
348+
StreamsDataProcessRegion,
349+
StreamConfig,
350+
StreamsConnection,
351+
StreamsConnectionType,
352+
StreamsKafkaAuthentication,
353+
StreamsKafkaSecurity,
354+
DbRoleToExecute,
355+
DbRoleToExecuteType,
356+
} from "./l1-resources/stream-instance";
357+
344358
export {
345359
CfnTeams,
346360
CfnTeamsProps,

src/l1-resources/search-deployment/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ The official [MongoDB Atlas](https://www.mongodb.com/) AWS CDK resource for Node
99

1010
## Description
1111

12-
Retrieves or creates projects in any given Atlas organization.
12+
Returns, adds, edits, and removes search deployments.
1313

1414
## MongoDB Atlas API Docs
1515

16-
For more information about the API refer to: [API Endpoints](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Projects)
16+
For more information about the API refer to: [API Endpoints](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Atlas-Search)
1717

1818
## Usage
1919

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# stream-instance
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::StreamInstance`.
6+
[L1 construct]: https://docs.aws.amazon.com/cdk/latest/guide/constructs.html
7+
[AWS CloudFormation Registry]: https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html
8+
9+
> **NOTE**:
10+
> - **Atlas Streams functionality is currently in [Public Preview](https://www.mongodb.com/blog/post/atlas-stream-processing-now-in-public-preview).**
11+
> - Please review [Limitations](https://www.mongodb.com/docs/atlas/atlas-sp/limitations/#std-label-atlas-sp-limitations) of Atlas Streams Processing during this preview period.
12+
> - Please refer [our example section](https://github.com/mongodb/mongodbatlas-cloudformation-resources/blob/master/examples/atlas-streams/README.md) for further details.
13+
14+
## Description
15+
16+
Returns, adds, edits, and removes stream instances.
17+
18+
## MongoDB Atlas API Docs
19+
20+
For more information about the API refer to: [API Endpoints](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams)
21+
22+
## Usage
23+
24+
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:
25+
26+
```sh
27+
aws cloudformation activate-type \
28+
--type-name MongoDB::Atlas::StreamInstance \
29+
--publisher-id bb989456c78c398a858fef18f2ca1bfc1fbba082 \
30+
--type RESOURCE \
31+
--execution-role-arn ROLE-ARN
32+
```
33+
34+
Alternatively:
35+
36+
```sh
37+
aws cloudformation activate-type \
38+
--public-type-arn arn:aws:cloudformation:us-east-1::type/resource/bb989456c78c398a858fef18f2ca1bfc1fbba082/MongoDB-Atlas-StreamInstance \
39+
--execution-role-arn ROLE-ARN
40+
```
41+
42+
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).
43+
44+
## Example: [stream-instance.ts](../../../examples/l1-resources/stream-instance.ts)
45+
```ts
46+
import { CfnStreamInstance } from 'awscdk-resources-mongodbatlas';
47+
48+
const streamInstance = new CfnStreamInstance(this, "stream-instance-testing-stack", {
49+
profile: atlasProps.profile,
50+
instanceName: atlasProps.projectId,
51+
projectId: atlasProps.projectId,
52+
dataProcessRegion: {
53+
cloudProvider: StreamsDataProcessRegionCloudProvider.AWS,
54+
region: "VIRGINIA_USA",
55+
},
56+
streamConfig: {
57+
tier: "SP30",
58+
},
59+
});
60+
```
61+
62+
## Feedback
63+
64+
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::StreamInstance`.
65+
66+
* 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-stream-instance+v1.0.0).
67+
* Issues related to `MongoDB::Atlas::StreamInstance` should be reported to the [publisher](https://github.com/mongodb/mongodbatlas-cloudformation-resources/issues).
68+
* Feature requests should be [reported here](https://feedback.mongodb.com/forums/924145-atlas?category_id=392596)
69+
70+
[cdklabs/cdk-cloudformation]: https://github.com/cdklabs/cdk-cloudformation
71+
72+
## License
73+
74+
Distributed under the Apache-2.0 License.

0 commit comments

Comments
 (0)