Skip to content

Commit 6cdac98

Browse files
authored
feat: Adds Stream Connection L1 CDK construct (#234)
1 parent 60c5124 commit 6cdac98

File tree

8 files changed

+1399
-4
lines changed

8 files changed

+1399
-4
lines changed

API.md

Lines changed: 831 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
import * as cdk from 'aws-cdk-lib';
2+
import { Construct } from 'constructs';
3+
import { CfnStreamConnection, CfnStreamConnectionPropsType } 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 connectionName: string;
11+
readonly type: CfnStreamConnectionPropsType;
12+
readonly clusterName: string;
13+
}
14+
15+
const app = new cdk.App();
16+
17+
18+
export class CdkTestStack extends cdk.Stack {
19+
constructor(scope: Construct, id: string, props?: cdk.StackProps) {
20+
super(scope, id, props);
21+
22+
const atlasProps = this.getContextProps();
23+
const streamConnection = new CfnStreamConnection(this, "stream-connection-testing-stack", {
24+
profile: atlasProps.profile,
25+
instanceName: atlasProps.instanceName,
26+
projectId: atlasProps.projectId,
27+
connectionName: atlasProps.connectionName,
28+
type: CfnStreamConnectionPropsType.CLUSTER,
29+
clusterName: atlasProps.clusterName
30+
});
31+
}
32+
33+
34+
getContextProps(): AtlasStackProps {
35+
const profile = this.node.tryGetContext('profile') ?? 'default';
36+
const projectId = this.node.tryGetContext('projectId');
37+
const instanceName = this.node.tryGetContext('instanceName');
38+
const connectionName = this.node.tryGetContext('connectionName');
39+
const type = this.node.tryGetContext('type');
40+
if (!projectId) {
41+
throw "No context value specified for projectId. Please specify via the cdk context."
42+
}
43+
if (!instanceName) {
44+
throw "No context value specified for instanceName. Please specify via the cdk context."
45+
}
46+
if (!connectionName) {
47+
throw "No context value specified for connectionName. Please specify via the cdk context."
48+
}
49+
if (!type) {
50+
throw "No context value specified for type. Please specify via the cdk context."
51+
}
52+
53+
return {
54+
projectId,
55+
profile,
56+
instanceName,
57+
connectionName,
58+
type
59+
}
60+
}
61+
62+
}

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-connection | Returns, adds, edits, and removes stream connections instances. | [README.md](l1-resources/stream-connection/README.md) |
4445
| stream-instance | Returns, adds, edits, and removes stream instances instances. | [README.md](l1-resources/stream-instance/README.md) |
4546
| 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) |
4647
| 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) |

src/index.ts

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

344+
export {
345+
CfnStreamConnection,
346+
CfnStreamConnectionProps,
347+
CfnStreamConnectionPropsType,
348+
DbRoleToExecute,
349+
DbRoleToExecuteType,
350+
StreamsKafkaAuthentication,
351+
StreamsKafkaSecurity,
352+
} from "./l1-resources/stream-connection";
353+
344354
export {
345355
CfnStreamInstance,
346356
StreamsDataProcessRegionCloudProvider,
@@ -349,10 +359,6 @@ export {
349359
StreamConfig,
350360
StreamsConnection,
351361
StreamsConnectionType,
352-
StreamsKafkaAuthentication,
353-
StreamsKafkaSecurity,
354-
DbRoleToExecute,
355-
DbRoleToExecuteType,
356362
} from "./l1-resources/stream-instance";
357363

358364
export {
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# stream-connection
2+
3+
The official [MongoDB Atlas](https://www.mongodb.com/) AWS CDK resource for Node.js.
4+
5+
> AWS CDK [L1 construct](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html) and data structures for the [AWS CloudFormation Registry](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/registry.html) type `MongoDB::Atlas::StreamConnection`.
6+
7+
> **NOTE**:
8+
> - **Atlas Streams functionality is currently in [Public Preview](https://www.mongodb.com/blog/post/atlas-stream-processing-now-in-public-preview).**
9+
> - 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.
10+
> - Please refer [our example section](https://github.com/mongodb/mongodbatlas-cloudformation-resources/blob/master/examples/atlas-streams/README.md) for further details.
11+
12+
## Description
13+
14+
Returns, adds, edits, and removes stream connections.
15+
16+
## MongoDB Atlas API Docs
17+
18+
For more information about the API refer to: [API Endpoints](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Streams)
19+
20+
## Usage
21+
22+
> [Using Atlas Streams with Cloudformation](https://github.com/mongodb/mongodbatlas-cloudformation-resources/blob/master/examples/atlas-streams/README.md)
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::StreamConnection \
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-StreamConnection \
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-connection.ts](../../../examples/l1-resources/stream-connection.ts)
45+
```ts
46+
import { CfnStreamInstance } from 'awscdk-resources-mongodbatlas';
47+
48+
const streamConnection = new CfnStreamConnection(this, "stream-connection-testing-stack", {
49+
profile: atlasProps.profile,
50+
instanceName: atlasProps.instanceName,
51+
projectId: atlasProps.projectId,
52+
connectionName: atlasProps.connectionName,
53+
type: CfnStreamConnectionPropsType.CLUSTER,
54+
clusterName: atlasProps.clusterName
55+
});
56+
```
57+
58+
## Feedback
59+
60+
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::StreamConnection`.
61+
62+
* 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-connection+v1.0.0).
63+
* Issues related to `MongoDB::Atlas::StreamConnection` should be reported to the [publisher](https://github.com/mongodb/mongodbatlas-cloudformation-resources/issues).
64+
* Feature requests should be [reported here](https://feedback.mongodb.com/forums/924145-atlas?category_id=392596)
65+
66+
[cdklabs/cdk-cloudformation]: https://github.com/cdklabs/cdk-cloudformation
67+
68+
## License
69+
70+
Distributed under the Apache-2.0 License.

0 commit comments

Comments
 (0)