Skip to content

Commit e14f2e6

Browse files
committed
Update unit test for function_event_conditions
1 parent df914bd commit e14f2e6

File tree

4 files changed

+314
-85
lines changed

4 files changed

+314
-85
lines changed

tests/translator/input/function_event_conditions.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,15 @@ Resources:
7979
Topic:
8080
Ref: Notifications
8181

82+
SNSTopicWithSQSSubscription:
83+
Type: SNS
84+
Properties:
85+
Topic:
86+
Ref: Notifications
87+
SqsSubscription:
88+
QueueArn: !GetAtt Queue.Arn
89+
QueueUrl: !Ref Queue
90+
8291
KinesisStream:
8392
Type: Kinesis
8493
Properties:
@@ -99,3 +108,7 @@ Resources:
99108

100109
Images:
101110
Type: AWS::S3::Bucket
111+
112+
Queue:
113+
Condition: MyCondition
114+
Type: AWS::SQS::Queue

tests/translator/output/aws-cn/function_event_conditions.json

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@
222222
"ManagedPolicyArns": [
223223
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
224224
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole",
225-
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole"
225+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole",
226+
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
226227
],
227228
"Tags": [
228229
{
@@ -459,6 +460,77 @@
459460
"DependsOn": [
460461
"FunctionOneImageBucketPermission"
461462
]
463+
},
464+
"MyAwesomeFunctionSNSTopicWithSQSSubscription": {
465+
"Type": "AWS::SNS::Subscription",
466+
"Properties": {
467+
"Endpoint": {
468+
"Fn::GetAtt": [
469+
"Queue",
470+
"Arn"
471+
]
472+
},
473+
"Protocol": "sqs",
474+
"TopicArn": {
475+
"Ref": "Notifications"
476+
}
477+
},
478+
"Condition": "MyCondition"
479+
},
480+
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionQueuePolicy": {
481+
"Type": "AWS::SQS::QueuePolicy",
482+
"Properties": {
483+
"Queues": [
484+
{
485+
"Ref": "Queue"
486+
}
487+
],
488+
"PolicyDocument": {
489+
"Version": "2012-10-17",
490+
"Statement": [
491+
{
492+
"Action": "sqs:SendMessage",
493+
"Resource": {
494+
"Fn::GetAtt": [
495+
"Queue",
496+
"Arn"
497+
]
498+
},
499+
"Effect": "Allow",
500+
"Condition": {
501+
"ArnEquals": {
502+
"aws:SourceArn": {
503+
"Ref": "Notifications"
504+
}
505+
}
506+
},
507+
"Principal": "*"
508+
}
509+
]
510+
}
511+
},
512+
"Condition": "MyCondition"
513+
},
514+
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionEventSourceMapping": {
515+
"Type": "AWS::Lambda::EventSourceMapping",
516+
"Properties": {
517+
"BatchSize": 10,
518+
"Enabled": true,
519+
"FunctionName": {
520+
"Ref": "MyAwesomeFunctionAliasLive"
521+
},
522+
"EventSourceArn": {
523+
"Fn::GetAtt": [
524+
"Queue",
525+
"Arn"
526+
]
527+
}
528+
},
529+
"Condition": "MyCondition"
530+
},
531+
"Queue": {
532+
"Type": "AWS::SQS::Queue",
533+
"Condition": "MyCondition"
462534
}
463535
}
464536
}

tests/translator/output/aws-us-gov/function_event_conditions.json

Lines changed: 73 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@
222222
"ManagedPolicyArns": [
223223
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole",
224224
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaKinesisExecutionRole",
225-
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole"
225+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaDynamoDBExecutionRole",
226+
"arn:aws-us-gov:iam::aws:policy/service-role/AWSLambdaSQSQueueExecutionRole"
226227
],
227228
"Tags": [
228229
{
@@ -459,6 +460,77 @@
459460
"DependsOn": [
460461
"FunctionOneImageBucketPermission"
461462
]
463+
},
464+
"MyAwesomeFunctionSNSTopicWithSQSSubscription": {
465+
"Type": "AWS::SNS::Subscription",
466+
"Properties": {
467+
"Endpoint": {
468+
"Fn::GetAtt": [
469+
"Queue",
470+
"Arn"
471+
]
472+
},
473+
"Protocol": "sqs",
474+
"TopicArn": {
475+
"Ref": "Notifications"
476+
}
477+
},
478+
"Condition": "MyCondition"
479+
},
480+
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionQueuePolicy": {
481+
"Type": "AWS::SQS::QueuePolicy",
482+
"Properties": {
483+
"Queues": [
484+
{
485+
"Ref": "Queue"
486+
}
487+
],
488+
"PolicyDocument": {
489+
"Version": "2012-10-17",
490+
"Statement": [
491+
{
492+
"Action": "sqs:SendMessage",
493+
"Resource": {
494+
"Fn::GetAtt": [
495+
"Queue",
496+
"Arn"
497+
]
498+
},
499+
"Effect": "Allow",
500+
"Condition": {
501+
"ArnEquals": {
502+
"aws:SourceArn": {
503+
"Ref": "Notifications"
504+
}
505+
}
506+
},
507+
"Principal": "*"
508+
}
509+
]
510+
}
511+
},
512+
"Condition": "MyCondition"
513+
},
514+
"MyAwesomeFunctionSNSTopicWithSQSSubscriptionEventSourceMapping": {
515+
"Type": "AWS::Lambda::EventSourceMapping",
516+
"Properties": {
517+
"BatchSize": 10,
518+
"Enabled": true,
519+
"FunctionName": {
520+
"Ref": "MyAwesomeFunctionAliasLive"
521+
},
522+
"EventSourceArn": {
523+
"Fn::GetAtt": [
524+
"Queue",
525+
"Arn"
526+
]
527+
}
528+
},
529+
"Condition": "MyCondition"
530+
},
531+
"Queue": {
532+
"Type": "AWS::SQS::Queue",
533+
"Condition": "MyCondition"
462534
}
463535
}
464536
}

0 commit comments

Comments
 (0)