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
75 changes: 75 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,8 @@
"author": {
"name": "Amazon Web Services",
"url": "https://aws.amazon.com"
},
"dependencies": {
"@aws-cdk/aws-sqs": "^0.32.0"
made2591 marked this conversation as resolved.
Show resolved Hide resolved
}
}
1 change: 1 addition & 0 deletions packages/@aws-cdk/aws-events-targets/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './codepipeline';
export * from './sns';
export * from './sqs';
export * from './codebuild';
export * from './lambda';
export * from './ecs-task-properties';
Expand Down
47 changes: 47 additions & 0 deletions packages/@aws-cdk/aws-events-targets/lib/sqs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import events = require('@aws-cdk/aws-events');
import iam = require('@aws-cdk/aws-iam');
import sqs = require('@aws-cdk/aws-sqs');

/**
* Customize the SQS Queue Event Target
*/
export interface SqsQueueProps {
/**
* The message to send to the queue
*
* @default the entire CloudWatch event
*/
readonly message?: events.RuleTargetInput;
made2591 marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Use an SQS Queue as a target for AWS CloudWatch event rules.
*
* @example
*
* // publish to an SQS queue every time code is committed
* // to a CodeCommit repository
* repository.onCommit(new targets.SqsQueue(queue));
*
*/
export class SqsQueue implements events.IRuleTarget {
constructor(public readonly queue: sqs.IQueue, private readonly props: SqsQueueProps = {}) {
}

/**
* Returns a RuleTarget that can be used to trigger this SQS queue as a
* result from a CloudWatch event.
*
* @see https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/resource-based-policies-cwe.html#sqs-permissions
*/
public bind(_rule: events.IRule): events.RuleTargetProperties {
// deduplicated automatically
this.queue.grantSendMessages(new iam.ServicePrincipal('events.amazonaws.com'));
made2591 marked this conversation as resolved.
Show resolved Hide resolved

return {
id: this.queue.node.id,
arn: this.queue.queueArn,
input: this.props.message,
};
}
}
213 changes: 107 additions & 106 deletions packages/@aws-cdk/aws-events-targets/package.json
Original file line number Diff line number Diff line change
@@ -1,110 +1,111 @@
{
"name": "@aws-cdk/aws-events-targets",
made2591 marked this conversation as resolved.
Show resolved Hide resolved
"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"
"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"
}
}
},
"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"
},
"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"
],
"coverageThreshold": {
"global": {
"branches": 30,
"statements": 80
}
"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"
}
},
"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"
}
}
}
Loading