Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(sns): move subscribers to aws-sns-subscribers #2804

Merged
merged 6 commits into from
Jun 11, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import autoscaling = require('@aws-cdk/aws-autoscaling');
import lambda = require('@aws-cdk/aws-lambda');
import sns = require('@aws-cdk/aws-sns');
import subs = require('@aws-cdk/aws-sns-subscriptions');
import { Construct } from '@aws-cdk/cdk';
import { TopicHook } from './topic-hook';

Expand All @@ -15,7 +16,7 @@ export class FunctionHook implements autoscaling.ILifecycleHookTarget {

public bind(scope: Construct, lifecycleHook: autoscaling.ILifecycleHook): autoscaling.LifecycleHookTargetConfig {
const topic = new sns.Topic(scope, 'Topic');
topic.subscribeLambda(this.fn);
topic.addSubscription(new subs.LambdaSubscription(this.fn));
return new TopicHook(topic).bind(scope, lifecycleHook);
}
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-autoscaling-hooktargets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
"@aws-cdk/aws-iam": "^0.33.0",
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/aws-sqs": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
Expand All @@ -90,6 +91,7 @@
"@aws-cdk/aws-iam": "^0.33.0",
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/aws-sqs": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import codepipeline = require('@aws-cdk/aws-codepipeline');
import sns = require('@aws-cdk/aws-sns');
import subs = require('@aws-cdk/aws-sns-subscriptions');
import cdk = require('@aws-cdk/cdk');

/**
Expand Down Expand Up @@ -62,7 +63,7 @@ export class ManualApprovalAction extends codepipeline.Action {
if (this._notificationTopic) {
this._notificationTopic.grantPublish(info.role);
for (const notifyEmail of this.props.notifyEmails || []) {
this._notificationTopic.subscribeEmail(`Subscription-${notifyEmail}`, notifyEmail);
this._notificationTopic.addSubscription(new subs.EmailSubscription(notifyEmail));
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-codepipeline-actions/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-s3": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
"homepage": "https://github.com/awslabs/aws-cdk",
Expand All @@ -103,6 +104,7 @@
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-s3": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
"engines": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@
"PipelineApproveManualApprovalTopicResourceF5A35B20": {
"Type": "AWS::SNS::Topic"
},
"PipelineApproveManualApprovalTopicResourceSubscriptionadamruka85gmailcom76398FFA": {
"PipelineApproveManualApprovalTopicResourceadamruka85gmailcom202874CD": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Protocol": "email",
Expand All @@ -203,4 +203,4 @@
}
}
}
}
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@
"@aws-cdk/aws-iam": "^0.33.0",
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/aws-stepfunctions": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
Expand All @@ -103,6 +104,7 @@
"@aws-cdk/aws-iam": "^0.33.0",
"@aws-cdk/aws-lambda": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/aws-sqs": "^0.33.0",
"@aws-cdk/aws-stepfunctions": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import codebuild = require('@aws-cdk/aws-codebuild');
import codecommit = require('@aws-cdk/aws-codecommit');
import events = require('@aws-cdk/aws-events');
import sns = require('@aws-cdk/aws-sns');
import subs = require('@aws-cdk/aws-sns-subscriptions');
import sqs = require('@aws-cdk/aws-sqs');
import cdk = require('@aws-cdk/cdk');
import targets = require('../../lib');
Expand All @@ -19,7 +20,7 @@ const project = new codebuild.Project(stack, 'MyProject', {
const queue = new sqs.Queue(stack, 'MyQueue');

const topic = new sns.Topic(stack, 'MyTopic');
topic.subscribeQueue(queue);
topic.addSubscription(new subs.SqsSubscription(queue));

// this will send an email with the JSON event for every state change of this
// build project.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import events = require('@aws-cdk/aws-events');
import sns = require('@aws-cdk/aws-sns');
import subs = require('@aws-cdk/aws-sns-subscriptions');
import sqs = require('@aws-cdk/aws-sqs');
import cdk = require('@aws-cdk/cdk');
import targets = require('../../lib');
Expand All @@ -19,7 +20,7 @@ const event = new events.Rule(stack, 'EveryMinute', {
});

const queue = new sqs.Queue(stack, 'MyQueue');
topic.subscribeQueue(queue);
topic.addSubscription(new subs.SqsSubscription(queue));

event.addTarget(new targets.SnsTopic(topic));

Expand Down
5 changes: 3 additions & 2 deletions packages/@aws-cdk/aws-lambda-event-sources/lib/sns.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import lambda = require('@aws-cdk/aws-lambda');
import sns = require('@aws-cdk/aws-sns');
import subs = require('@aws-cdk/aws-sns-subscriptions');

/**
* Use an Amazon SNS topic as an event source for AWS Lambda.
Expand All @@ -9,6 +10,6 @@ export class SnsEventSource implements lambda.IEventSource {
}

public bind(target: lambda.IFunction) {
this.topic.subscribeLambda(target);
this.topic.addSubscription(new subs.LambdaSubscription(target));
}
}
}
2 changes: 2 additions & 0 deletions packages/@aws-cdk/aws-lambda-event-sources/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@aws-cdk/aws-s3": "^0.33.0",
"@aws-cdk/aws-s3-notifications": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/aws-sqs": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
Expand All @@ -85,6 +86,7 @@
"@aws-cdk/aws-s3": "^0.33.0",
"@aws-cdk/aws-s3-notifications": "^0.33.0",
"@aws-cdk/aws-sns": "^0.33.0",
"@aws-cdk/aws-sns-subscriptions": "^0.33.0",
"@aws-cdk/aws-sqs": "^0.33.0",
"@aws-cdk/cdk": "^0.33.0"
},
Expand Down
16 changes: 16 additions & 0 deletions packages/@aws-cdk/aws-sns-subscriptions/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
*.js
tsconfig.json
tslint.json
*.js.map
*.d.ts
*.generated.ts
dist
lib/generated/resources.ts
.jsii

.LAST_BUILD
.nyc_output
coverage
.nycrc
.LAST_PACKAGE
*.snk
18 changes: 18 additions & 0 deletions packages/@aws-cdk/aws-sns-subscriptions/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Don't include original .ts files when doing `npm pack`
*.ts
!*.d.ts
coverage
.nyc_output
*.tgz

dist
.LAST_PACKAGE
.LAST_BUILD
!*.js

# Include .jsii
!.jsii

*.snk

*.tsbuildinfo
Loading