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

fix(@aws-cdk/aws-events-targets): event-rules cannot have targets with the same construct id #2744

Merged
merged 23 commits into from
Jun 17, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ce33b40
fix(@aws-cdk/aws-events-targets): event-rules cannot have targets wit…
made2591 Jun 4, 2019
58a6cbc
fix uniqueId dimension to 64 chars
made2591 Jun 6, 2019
b824cd4
Merge branch 'master' into fix/aws-events-node-unique-id
made2591 Jun 6, 2019
5fd1465
fix integ.instance.lit.expected.json (got from Travis): local build d…
made2591 Jun 6, 2019
f4783eb
Merge remote-tracking branch 'upstream/master' into fix/aws-events-no…
made2591 Jun 7, 2019
c378546
move uniqueId cut inside aws-events/lib/rule.ts. change in uniqueId i…
made2591 Jun 7, 2019
bdc8c3c
fix integration tests after uniqueId migration.
made2591 Jun 7, 2019
f099eb0
change uniqueId for ecs-task target rule. fix integration tests
made2591 Jun 7, 2019
be8c70a
Merge remote-tracking branch 'upstream/master'
Jun 7, 2019
02cf01b
Merge branch 'master' into fix/aws-events-node-unique-id
Jun 7, 2019
0f4a4c0
fix integration test in aws-codepipeline-actions/test/
made2591 Jun 10, 2019
e4a8447
Merge remote-tracking branch 'upstream/master' into fix/aws-events-no…
made2591 Jun 10, 2019
7dd818b
fix tests in packages/@aws-cdk/aws-ecs-patterns/test/
made2591 Jun 10, 2019
532c02e
fix test in packages/@aws-cdk/aws-codepipeline-actions/test/integ.lam…
made2591 Jun 10, 2019
c27e874
fix codepipeline actions tests. wip
made2591 Jun 11, 2019
fbfe7d3
Merge remote-tracking branch 'upstream/master' into fix/aws-events-no…
Jun 11, 2019
3c104a7
Merge remote-tracking branch 'upstream/master' into fix/aws-events-no…
made2591 Jun 11, 2019
475301a
fix integration tests accordingly
made2591 Jun 11, 2019
19953e7
Fix import
rix0rrr Jun 12, 2019
f3e3aaa
Update some expectations
rix0rrr Jun 13, 2019
0d4c101
Merge remote-tracking branch 'upstream/master' into fix/aws-events-no…
made2591 Jun 16, 2019
d81c991
Update expectations of lambda sns and sqs
made2591 Jun 16, 2019
981a7d7
Update expectations in @aws-cdk/aws-codepipeline-actions/
made2591 Jun 16, 2019
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
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/codebuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class CodeBuildProject implements events.IRuleTarget {
*/
public bind(_rule: events.IRule): events.RuleTargetConfig {
return {
id: this.project.node.id,
id: this.project.node.uniqueId,
arn: this.project.projectArn,
role: singletonEventRole(this.project, [new iam.PolicyStatement()
.addAction('codebuild:StartBuild')
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/codepipeline.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class CodePipeline implements events.IRuleTarget {

public bind(_rule: events.IRule): events.RuleTargetConfig {
return {
id: this.pipeline.node.id,
id: this.pipeline.node.uniqueId,
arn: this.pipeline.pipelineArn,
role: singletonEventRole(this.pipeline, [new iam.PolicyStatement()
.addResource(this.pipeline.pipelineArn)
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/ecs-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export class EcsTask implements events.IRuleTarget {
.addResource(this.taskDefinition.taskRole.roleArn));
}

const id = this.taskDefinition.node.id + '-on-' + this.cluster.node.id;
const id = this.taskDefinition.node.uniqueId + '-on-' + this.cluster.node.uniqueId;
const arn = this.cluster.clusterArn;
const role = singletonEventRole(this.taskDefinition, policyStatements);
const containerOverrides = this.props.containerOverrides && this.props.containerOverrides
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/lambda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class LambdaFunction implements events.IRuleTarget {
}

return {
id: this.handler.node.id,
id: this.handler.node.uniqueId,
arn: this.handler.functionArn,
input: this.props.event,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/sns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class SnsTopic implements events.IRuleTarget {
this.topic.grantPublish(new iam.ServicePrincipal('events.amazonaws.com'));

return {
id: this.topic.node.id,
id: this.topic.node.uniqueId,
arn: this.topic.topicArn,
input: this.props.message,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/sqs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export class SqsQueue implements events.IRuleTarget {
);

const result = {
id: this.queue.node.id,
id: this.queue.node.uniqueId,
arn: this.queue.queueArn,
input: this.props.message,
};
Expand Down
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-events-targets/lib/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class SfnStateMachine implements events.IRuleTarget {
*/
public bind(_rule: events.IRule): events.RuleTargetConfig {
return {
id: this.machine.node.id,
id: this.machine.node.uniqueId,
arn: this.machine.stateMachineArn,
role: singletonEventRole(this.machine, [new iam.PolicyStatement()
.addAction('states:StartExecution')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"Arn"
]
},
"Id": "MyProject",
"Id": "awscdkcodebuildeventsMyProjectEF919B0E",
"RoleArn": {
"Fn::GetAtt": [
"MyProjectEventsRole5B7D93F5",
Expand All @@ -56,7 +56,7 @@
"Arn": {
"Ref": "MyTopic86869434"
},
"Id": "MyTopic",
"Id": "awscdkcodebuildeventsMyTopic550011DC",
"InputTransformer": {
"InputPathsMap": {
"f1": "$.detail.repositoryName",
Expand Down Expand Up @@ -284,7 +284,7 @@
"Arn": {
"Ref": "MyTopic86869434"
},
"Id": "MyTopic"
"Id": "awscdkcodebuildeventsMyTopic550011DC"
}
]
}
Expand Down Expand Up @@ -313,7 +313,7 @@
"Arn": {
"Ref": "MyTopic86869434"
},
"Id": "MyTopic",
"Id": "awscdkcodebuildeventsMyTopic550011DC",
"InputTransformer": {
"InputPathsMap": {
"f1": "$.detail.completed-phase"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@
]
]
},
"Id": "Pipeline",
"Id": "pipelineeventsPipelineD8DD4529",
"RoleArn": {
"Fn::GetAtt": [
"PipelineEventsRole46BEEA7C",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@
"Ref": "TaskDef54694570"
}
},
"Id": "TaskDef-on-EcsCluster",
"Id": "wsecsintegecsTaskDef8DD0C801-on-awsecsintegecsEcsCluster028757CF",
"Input": "{\"containerOverrides\":[{\"name\":\"TheContainer\",\"environment\":[{\"name\":\"I_WAS_TRIGGERED\",\"value\":\"From CloudWatch Events\"}]}]}",
"RoleArn": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -609,7 +609,7 @@
"Arn"
]
},
"Id": "TaskDef-on-EcsCluster",
"Id": "awsecsintegfargateTaskDef8878AF94-on-awsecsintegfargateEcsCluster46E816CB",
made2591 marked this conversation as resolved.
Show resolved Hide resolved
"EcsParameters": {
"TaskDefinitionArn": {
"Ref": "TaskDef54694570"
Expand Down Expand Up @@ -645,7 +645,7 @@
}
]
},
"physicalResourceId": "TaskDef-on-EcsCluster"
"physicalResourceId": "awsecsintegfargateTaskDef8878AF94-on-awsecsintegfargateEcsCluster46E816CB"
},
"Update": {
"service": "CloudWatchEvents",
Expand Down Expand Up @@ -686,7 +686,7 @@
"Arn"
]
},
"Id": "TaskDef-on-EcsCluster",
"Id": "awsecsintegfargateTaskDef8878AF94-on-awsecsintegfargateEcsCluster46E816CB",
"EcsParameters": {
"TaskDefinitionArn": {
"Ref": "TaskDef54694570"
Expand Down Expand Up @@ -722,7 +722,7 @@
}
]
},
"physicalResourceId": "TaskDef-on-EcsCluster"
"physicalResourceId": "awsecsintegfargateTaskDef8878AF94-on-awsecsintegfargateEcsCluster46E816CB"
}
}
},
Expand Down Expand Up @@ -933,7 +933,7 @@
"Ref": "TaskDef54694570"
}
},
"Id": "TaskDef-on-EcsCluster",
"Id": "egfargateTaskDef8878AF94-on-awsecsintegfargateEcsCluster46E816CB",
"Input": "{\"containerOverrides\":[{\"name\":\"TheContainer\",\"environment\":[{\"name\":\"I_WAS_TRIGGERED\",\"value\":\"From CloudWatch Events\"}]}]}",
"RoleArn": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,138 +1,105 @@
{
"Resources": {
"MyFuncServiceRole54065130": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": {
"Fn::Join": [
"",
[
"lambda.",
{
"Ref": "AWS::URLSuffix"
}
"Resources": {
"MyFuncServiceRole54065130": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [{
"Action": "sts:AssumeRole",
"Effect": "Allow",
"Principal": {
"Service": {
"Fn::Join": [
"", [
"lambda.",
{
"Ref": "AWS::URLSuffix"
}
]
]
}
}
}],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [{
"Fn::Join": [
"", [
"arn:",
{
"Ref": "AWS::Partition"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
]
}
}
}]
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
{
"Fn::Join": [
"",
[
"arn:",
{
"Ref": "AWS::Partition"
"MyFunc8A243A2C": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "exports.handler = function handler(event, _context, callback) {\n console.log(JSON.stringify(event, undefined, 2));\n return callback();\n}"
},
":iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
]
]
}
]
}
},
"MyFunc8A243A2C": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ZipFile": "exports.handler = function handler(event, _context, callback) {\n console.log(JSON.stringify(event, undefined, 2));\n return callback();\n}"
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": ["MyFuncServiceRole54065130", "Arn"]
},
"Runtime": "nodejs8.10"
},
"DependsOn": ["MyFuncServiceRole54065130"]
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
"MyFuncServiceRole54065130",
"Arn"
]
"MyFuncAllowEventRulelambdaeventsTimer0E6AB6D8E3B334A3": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": ["MyFunc8A243A2C", "Arn"]
},
"Principal": "events.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": ["TimerBF6F831F", "Arn"]
}
}
},
"Runtime": "nodejs8.10"
},
"DependsOn": [
"MyFuncServiceRole54065130"
]
},
"MyFuncAllowEventRulelambdaeventsTimer0E6AB6D8E3B334A3": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"MyFunc8A243A2C",
"Arn"
]
"MyFuncAllowEventRulelambdaeventsTimer27F866A1E0669C645": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": ["MyFunc8A243A2C", "Arn"]
},
"Principal": "events.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": ["Timer2B6F162E9", "Arn"]
}
}
},
"Principal": "events.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": [
"TimerBF6F831F",
"Arn"
]
}
}
},
"MyFuncAllowEventRulelambdaeventsTimer27F866A1E0669C645": {
"Type": "AWS::Lambda::Permission",
"Properties": {
"Action": "lambda:InvokeFunction",
"FunctionName": {
"Fn::GetAtt": [
"MyFunc8A243A2C",
"Arn"
]
"TimerBF6F831F": {
"Type": "AWS::Events::Rule",
"Properties": {
"ScheduleExpression": "rate(1 minute)",
"State": "ENABLED",
"Targets": [{
"Arn": {
"Fn::GetAtt": ["MyFunc8A243A2C", "Arn"]
},
"Id": "lambdaeventsMyFunc910E580F"
}]
}
},
"Principal": "events.amazonaws.com",
"SourceArn": {
"Fn::GetAtt": [
"Timer2B6F162E9",
"Arn"
]
"Timer2B6F162E9": {
"Type": "AWS::Events::Rule",
"Properties": {
"ScheduleExpression": "rate(2 minutes)",
"State": "ENABLED",
"Targets": [{
"Arn": {
"Fn::GetAtt": ["MyFunc8A243A2C", "Arn"]
},
"Id": "lambdaeventsMyFunc910E580F"
}]
}
}
}
},
"TimerBF6F831F": {
"Type": "AWS::Events::Rule",
"Properties": {
"ScheduleExpression": "rate(1 minute)",
"State": "ENABLED",
"Targets": [
{
"Arn": {
"Fn::GetAtt": [
"MyFunc8A243A2C",
"Arn"
]
},
"Id": "MyFunc"
}
]
}
},
"Timer2B6F162E9": {
"Type": "AWS::Events::Rule",
"Properties": {
"ScheduleExpression": "rate(2 minutes)",
"State": "ENABLED",
"Targets": [
{
"Arn": {
"Fn::GetAtt": [
"MyFunc8A243A2C",
"Arn"
]
},
"Id": "MyFunc"
}
]
}
}
}
}
Loading