Skip to content

Commit 564246e

Browse files
authored
fix: Fixes trigger attributes name and type that are required but were as optional (#226)
1 parent 2b54e3b commit 564246e

File tree

5 files changed

+40
-33
lines changed

5 files changed

+40
-33
lines changed

API.md

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

examples/l1-resources/trigger.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This example creates a database user in Atlas using the L1 resources.
22
import * as cdk from 'aws-cdk-lib';
33
import { Construct } from 'constructs';
4-
import { CfnTrigger, DatabaseConfigOperationTypes } from 'awscdk-resources-mongodbatlas';
4+
import { CfnTrigger, DatabaseConfigOperationTypes } from 'awscdk-resources-mongodbatlas';
55

66
interface AtlasStackProps {
77
readonly projId: string;
@@ -23,6 +23,7 @@ export class CdkTestingStack extends cdk.Stack {
2323
const trigger = new CfnTrigger(this, 'ThirdPartyIntegration', {
2424
projectId: atlasProps.projId,
2525
profile: atlasProps.profile,
26+
name: "mytrigger",
2627
type: "DATABASE",
2728
appId: atlasProps.appId,
2829
databaseTrigger: {
@@ -45,7 +46,7 @@ export class CdkTestingStack extends cdk.Stack {
4546

4647
getContextProps(): AtlasStackProps {
4748
const projId = this.node.tryGetContext('projId');
48-
if (!projId){
49+
if (!projId) {
4950
throw "No context value specified for projId. Please specify via the cdk context."
5051
}
5152
const appId = this.node.tryGetContext('appId');
@@ -55,14 +56,14 @@ export class CdkTestingStack extends cdk.Stack {
5556
const serviceId = this.node.tryGetContext('serviceId');
5657
const functionId = this.node.tryGetContext('functionId');
5758
const functionName = this.node.tryGetContext('functionName');
58-
59+
5960
return {
6061
projId,
6162
profile,
6263
appId,
6364
dbName,
6465
collection,
65-
serviceId,
66+
serviceId,
6667
functionId,
6768
functionName
6869
}

src/l1-resources/trigger/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,14 @@ export interface CfnTriggerProps {
3535
*
3636
* @schema CfnTriggerProps#Name
3737
*/
38-
readonly name?: string;
38+
readonly name: string;
3939

4040
/**
4141
* The trigger's type.
4242
*
4343
* @schema CfnTriggerProps#Type
4444
*/
45-
readonly type?: string;
45+
readonly type: string;
4646

4747
/**
4848
* If `true`, the trigger is disabled and does not listen for events or execute.

test/l1-resources/trigger/index.test.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import { CfnTrigger } from "../../../src/l1-resources/trigger";
1919
const RESOURCE_NAME = "MongoDB::Atlas::Trigger";
2020
const PROJECT_ID = "testProjectId";
2121
const APPID = "appId";
22+
const NAME = "name";
23+
const TYPE = "type";
2224

2325
test("Trigger construct should contain default properties", () => {
2426
const mockApp = new App();
@@ -27,12 +29,16 @@ test("Trigger construct should contain default properties", () => {
2729
new CfnTrigger(stack, "testing-stack", {
2830
projectId: PROJECT_ID,
2931
appId: APPID,
32+
name: NAME,
33+
type: TYPE,
3034
});
3135

3236
const template = Template.fromStack(stack);
3337

3438
template.hasResourceProperties(RESOURCE_NAME, {
3539
ProjectId: PROJECT_ID,
3640
AppId: APPID,
41+
Name: NAME,
42+
Type: TYPE,
3743
});
3844
});

0 commit comments

Comments
 (0)