Skip to content

Commit

Permalink
Update unit test for function_event_conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
hawflau committed Nov 14, 2020
1 parent df914bd commit e14f2e6
Show file tree
Hide file tree
Showing 4 changed files with 314 additions and 85 deletions.
13 changes: 13 additions & 0 deletions tests/translator/input/function_event_conditions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,15 @@ Resources:
Topic:
Ref: Notifications

SNSTopicWithSQSSubscription:
Type: SNS
Properties:
Topic:
Ref: Notifications
SqsSubscription:
QueueArn: !GetAtt Queue.Arn
QueueUrl: !Ref Queue

KinesisStream:
Type: Kinesis
Properties:
Expand All @@ -99,3 +108,7 @@ Resources:

Images:
Type: AWS::S3::Bucket

Queue:
Condition: MyCondition
Type: AWS::SQS::Queue
74 changes: 73 additions & 1 deletion tests/translator/output/aws-cn/function_event_conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@
"ManagedPolicyArns": [
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole",
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole"
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole",
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
],
"Tags": [
{
Expand Down Expand Up @@ -459,6 +460,77 @@
"DependsOn": [
"FunctionOneImageBucketPermission"
]
},
"MyAwesomeFunctionSNSTopicWithSQSSubscription": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": {
"Fn::GetAtt": [
"Queue",
"Arn"
]
},
"Protocol": "sqs",
"TopicArn": {
"Ref": "Notifications"
}
},
"Condition": "MyCondition"
},
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionQueuePolicy": {
"Type": "AWS::SQS::QueuePolicy",
"Properties": {
"Queues": [
{
"Ref": "Queue"
}
],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sqs:SendMessage",
"Resource": {
"Fn::GetAtt": [
"Queue",
"Arn"
]
},
"Effect": "Allow",
"Condition": {
"ArnEquals": {
"aws:SourceArn": {
"Ref": "Notifications"
}
}
},
"Principal": "*"
}
]
}
},
"Condition": "MyCondition"
},
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionEventSourceMapping": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 10,
"Enabled": true,
"FunctionName": {
"Ref": "MyAwesomeFunctionAliasLive"
},
"EventSourceArn": {
"Fn::GetAtt": [
"Queue",
"Arn"
]
}
},
"Condition": "MyCondition"
},
"Queue": {
"Type": "AWS::SQS::Queue",
"Condition": "MyCondition"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,8 @@
"ManagedPolicyArns": [
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole",
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole"
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole",
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
],
"Tags": [
{
Expand Down Expand Up @@ -459,6 +460,77 @@
"DependsOn": [
"FunctionOneImageBucketPermission"
]
},
"MyAwesomeFunctionSNSTopicWithSQSSubscription": {
"Type": "AWS::SNS::Subscription",
"Properties": {
"Endpoint": {
"Fn::GetAtt": [
"Queue",
"Arn"
]
},
"Protocol": "sqs",
"TopicArn": {
"Ref": "Notifications"
}
},
"Condition": "MyCondition"
},
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionQueuePolicy": {
"Type": "AWS::SQS::QueuePolicy",
"Properties": {
"Queues": [
{
"Ref": "Queue"
}
],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Action": "sqs:SendMessage",
"Resource": {
"Fn::GetAtt": [
"Queue",
"Arn"
]
},
"Effect": "Allow",
"Condition": {
"ArnEquals": {
"aws:SourceArn": {
"Ref": "Notifications"
}
}
},
"Principal": "*"
}
]
}
},
"Condition": "MyCondition"
},
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionEventSourceMapping": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 10,
"Enabled": true,
"FunctionName": {
"Ref": "MyAwesomeFunctionAliasLive"
},
"EventSourceArn": {
"Fn::GetAtt": [
"Queue",
"Arn"
]
}
},
"Condition": "MyCondition"
},
"Queue": {
"Type": "AWS::SQS::Queue",
"Condition": "MyCondition"
}
}
}

0 comments on commit e14f2e6

Please sign in to comment.