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

feat(@aws-cdk/aws-events-triggers): introducing sqs target support in event rule #2683

Merged
merged 10 commits into from
Jun 4, 2019
Prev Previous commit
Next Next commit
fix typo in package.json files. fix permission issue in test https://…
  • Loading branch information
made2591 committed May 30, 2019
commit 30b04ab38af0622cf39e0abed2035b8e433b238b
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,5 @@
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com"
},
"dependencies": {
"@aws-cdk/aws-sqs": "^0.32.0"
}
}
213 changes: 106 additions & 107 deletions packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
@@ -1,111 +1,110 @@
{
"name": "@aws-cdk/aws-events-targets",
"version": "0.32.0",
"description": "Event targets for AWS CloudWatch Events",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"jsii": {
"outdir": "dist",
"targets": {
"java": {
"package": "software.amazon.awscdk.services.events.targets",
"maven": {
"groupId": "software.amazon.awscdk",
"artifactId": "events-targets"
}
},
"dotnet": {
"namespace": "Amazon.CDK.AWS.Events.Targets",
"packageId": "Amazon.CDK.AWS.Events.Targets",
"signAssembly": true,
"assemblyOriginatorKeyFile": "../../key.snk"
},
"python": {
"distName": "aws-cdk.aws-events-targets",
"module": "aws_cdk.aws_events_targets"
}
"name": "@aws-cdk/aws-events-targets",
"version": "0.32.0",
"description": "Event targets for AWS CloudWatch Events",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"jsii": {
"outdir": "dist",
"targets": {
"java": {
"package": "software.amazon.awscdk.services.events.targets",
"maven": {
"groupId": "software.amazon.awscdk",
"artifactId": "events-targets"
}
},
"repository": {
"type": "git",
"url": "https://github.com/awslabs/aws-cdk.git",
"directory": "packages/@aws-cdk/aws-events-targets"
},
"scripts": {
"build": "cdk-build",
"watch": "cdk-watch",
"lint": "cdk-lint",
"test": "cdk-test",
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test"
},
"jest": {
"moduleFileExtensions": [
"js"
],
"coverageThreshold": {
"global": {
"branches": 30,
"statements": 80
}
}
},
"keywords": [
"aws",
"cdk",
"cloudlib",
"aws-cloudlib",
"aws-clib",
"cloudwatch",
"events"
},
"dotnet": {
"namespace": "Amazon.CDK.AWS.Events.Targets",
"packageId": "Amazon.CDK.AWS.Events.Targets",
"signAssembly": true,
"assemblyOriginatorKeyFile": "../../key.snk"
},
"python": {
"distName": "aws-cdk.aws-events-targets",
"module": "aws_cdk.aws_events_targets"
}
}
},
"repository": {
"type": "git",
"url": "https://github.com/awslabs/aws-cdk.git",
"directory": "packages/@aws-cdk/aws-events-targets"
},
"scripts": {
"build": "cdk-build",
"watch": "cdk-watch",
"lint": "cdk-lint",
"test": "cdk-test",
"integ": "cdk-integ",
"pkglint": "pkglint -f",
"package": "cdk-package",
"awslint": "cdk-awslint",
"cfn2ts": "cfn2ts",
"build+test+package": "npm run build+test && npm run package",
"build+test": "npm run build && npm test"
},
"jest": {
"moduleFileExtensions": [
"js"
],
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com",
"organization": true
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "^0.32.0",
"@aws-cdk/aws-codecommit": "^0.32.0",
"cdk-build-tools": "^0.32.0",
"cdk-integ-tools": "^0.32.0",
"jest": "^24.7.1",
"pkglint": "^0.32.0"
},
"dependencies": {
"@aws-cdk/aws-codebuild": "^0.32.0",
"@aws-cdk/aws-codepipeline": "^0.32.0",
"@aws-cdk/aws-ec2": "^0.32.0",
"@aws-cdk/aws-ecs": "^0.32.0",
"@aws-cdk/aws-events": "^0.32.0",
"@aws-cdk/aws-iam": "^0.32.0",
"@aws-cdk/aws-lambda": "^0.32.0",
"@aws-cdk/aws-sns": "^0.32.0",
"@aws-cdk/aws-sqs": "^0.32.0",
"@aws-cdk/aws-stepfunctions": "^0.32.0",
"@aws-cdk/cdk": "^0.32.0"
},
"homepage": "https://github.com/awslabs/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-codebuild": "^0.32.0",
"@aws-cdk/aws-codepipeline": "^0.32.0",
"@aws-cdk/aws-ec2": "^0.32.0",
"@aws-cdk/aws-ecs": "^0.32.0",
"@aws-cdk/aws-events": "^0.32.0",
"@aws-cdk/aws-iam": "^0.32.0",
"@aws-cdk/aws-lambda": "^0.32.0",
"@aws-cdk/aws-sns": "^0.32.0",
"@aws-cdk/aws-sqs": "^0.32.0",
"@aws-cdk/aws-stepfunctions": "^0.32.0",
"@aws-cdk/cdk": "^0.32.0"
},
"engines": {
"node": ">= 8.10.0"
"coverageThreshold": {
"global": {
"branches": 30,
"statements": 80
}
}
}
},
"keywords": [
"aws",
"cdk",
"cloudlib",
"aws-cloudlib",
"aws-clib",
"cloudwatch",
"events"
],
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com",
"organization": true
},
"license": "Apache-2.0",
"devDependencies": {
"@aws-cdk/assert": "^0.32.0",
"@aws-cdk/aws-codecommit": "^0.32.0",
"@aws-cdk/aws-sqs": "^0.32.0",
"cdk-build-tools": "^0.32.0",
"cdk-integ-tools": "^0.32.0",
"jest": "^24.7.1",
"pkglint": "^0.32.0"
},
"dependencies": {
"@aws-cdk/aws-codebuild": "^0.32.0",
"@aws-cdk/aws-codepipeline": "^0.32.0",
"@aws-cdk/aws-ec2": "^0.32.0",
"@aws-cdk/aws-ecs": "^0.32.0",
"@aws-cdk/aws-events": "^0.32.0",
"@aws-cdk/aws-iam": "^0.32.0",
"@aws-cdk/aws-lambda": "^0.32.0",
"@aws-cdk/aws-sns": "^0.32.0",
"@aws-cdk/aws-stepfunctions": "^0.32.0",
"@aws-cdk/cdk": "^0.32.0"
},
"homepage": "https://github.com/awslabs/aws-cdk",
"peerDependencies": {
"@aws-cdk/aws-codebuild": "^0.32.0",
"@aws-cdk/aws-codepipeline": "^0.32.0",
"@aws-cdk/aws-ec2": "^0.32.0",
"@aws-cdk/aws-ecs": "^0.32.0",
"@aws-cdk/aws-events": "^0.32.0",
"@aws-cdk/aws-iam": "^0.32.0",
"@aws-cdk/aws-lambda": "^0.32.0",
"@aws-cdk/aws-sns": "^0.32.0",
"@aws-cdk/aws-stepfunctions": "^0.32.0",
"@aws-cdk/cdk": "^0.32.0"
},
"engines": {
"node": ">= 8.10.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,41 +26,6 @@
"Properties": {
"PolicyDocument": {
"Statement": [
{
"Action": [
"sqs:SendMessage",
"sqs:SendMessageBatch",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl"
],
"Condition": {
"ArnEquals": {
"aws:SourceArn": {
"Ref": "EveryMinute2BBCEA8F"
}
}
},
"Effect": "Allow",
"Principal": {
"Service": {
"Fn::Join": [
"",
[
"events.",
{
"Ref": "AWS::URLSuffix"
}
]
]
}
},
"Resource": {
"Fn::GetAtt": [
"MyQueueE6CA6235",
"Arn"
]
}
},
{
"Action": [
"sqs:SendMessage",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import events = require('@aws-cdk/aws-events');
import iam = require('@aws-cdk/aws-iam');
import { PolicyStatementEffect } from '@aws-cdk/aws-iam';
import sqs = require('@aws-cdk/aws-sqs');
import cdk = require('@aws-cdk/cdk');
import targets = require('../../lib');

// ---------------------------------
// Define a rule that triggers an event every 1min.
// Connect the event with a queue. This means that the queue should have
// Define a rule that triggers an SNS topic every 1min.
// Connect the topic with a queue. This means that the queue should have
// a message sent to it every minute.

const app = new cdk.App();
Expand All @@ -19,21 +17,6 @@ const event = new events.Rule(stack, 'EveryMinute', {
});

const queue = new sqs.Queue(stack, 'MyQueue');
const policy = new iam.PolicyStatement(PolicyStatementEffect.Allow);
policy.addActions(
"sqs:SendMessage",
"sqs:SendMessageBatch",
"sqs:GetQueueAttributes",
"sqs:GetQueueUrl"
);
policy.addResource(queue.queueArn);
policy.addCondition("ArnEquals", {
"aws:SourceArn": {
Ref: "EveryMinute2BBCEA8F"
}
});
policy.addPrincipal(new iam.ServicePrincipal("events"));
queue.addToResourcePolicy(policy);
event.addTarget(new targets.SqsQueue(queue);
event.addTarget(new targets.SqsQueue(queue));

app.run();