-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Marie
committed
Sep 4, 2020
1 parent
c6d746e
commit d9861bf
Showing
3 changed files
with
6 additions
and
34 deletions.
There are no files selected for viewing
21 changes: 1 addition & 20 deletions
21
packages/aws-cdk/lib/init-templates/lib/typescript/lib/index.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,13 @@ | ||
import * as sns from '@aws-cdk/aws-sns'; | ||
import * as subs from '@aws-cdk/aws-sns-subscriptions'; | ||
import * as sqs from '@aws-cdk/aws-sqs'; | ||
import * as cdk from '@aws-cdk/core'; | ||
|
||
export interface %name.PascalCased%Props { | ||
/** | ||
* The visibility timeout to be configured on the SQS Queue, in seconds. | ||
* | ||
* @default Duration.seconds(300) | ||
*/ | ||
visibilityTimeout?: cdk.Duration; | ||
|
||
} | ||
|
||
export class %name.PascalCased% extends cdk.Construct { | ||
/** @returns the ARN of the SQS queue */ | ||
public readonly queueArn: string; | ||
|
||
constructor(scope: cdk.Construct, id: string, props: %name.PascalCased%Props = {}) { | ||
super(scope, id); | ||
|
||
const queue = new sqs.Queue(this, '%name.PascalCased%Queue', { | ||
visibilityTimeout: props.visibilityTimeout || cdk.Duration.seconds(300) | ||
}); | ||
|
||
const topic = new sns.Topic(this, '%name.PascalCased%Topic'); | ||
|
||
topic.addSubscription(new subs.SqsSubscription(queue)); | ||
|
||
this.queueArn = queue.queueArn; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 5 additions & 11 deletions
16
packages/aws-cdk/lib/init-templates/lib/typescript/test/%name%.test.template.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,15 @@ | ||
import { expect as expectCDK, haveResource } from '@aws-cdk/assert'; | ||
import { expect as expectCDK, countResources } from '@aws-cdk/assert'; | ||
import * as cdk from '@aws-cdk/core'; | ||
import * as %name.PascalCased% from '../lib/index'; | ||
|
||
test('SQS Queue Created', () => { | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, "TestStack"); | ||
// WHEN | ||
new %name.PascalCased%.%name.PascalCased%(stack, 'MyTestConstruct'); | ||
// THEN | ||
expectCDK(stack).to(haveResource("AWS::SQS::Queue")); | ||
}); | ||
|
||
/* | ||
* Example test | ||
*/ | ||
test('SNS Topic Created', () => { | ||
const app = new cdk.App(); | ||
const stack = new cdk.Stack(app, "TestStack"); | ||
// WHEN | ||
new %name.PascalCased%.%name.PascalCased%(stack, 'MyTestConstruct'); | ||
// THEN | ||
expectCDK(stack).to(haveResource("AWS::SNS::Topic")); | ||
expectCDK(stack).to(countResources("AWS::SNS::Topic",0)); | ||
}); |