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

Event source disabled #690

Merged
merged 3 commits into from
Dec 5, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 3 additions & 1 deletion samtranslator/model/eventsources/pull.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ class PullEventSource(ResourceMacro):
'Stream': PropertyType(False, is_str()),
'Queue': PropertyType(False, is_str()),
'BatchSize': PropertyType(False, is_type(int)),
'StartingPosition': PropertyType(False, is_str())
'StartingPosition': PropertyType(False, is_str()),
'Enabled': PropertyType(False, is_type(bool))
}

def get_policy_arn(self):
Expand Down Expand Up @@ -61,6 +62,7 @@ def to_cloudformation(self, **kwargs):
lambda_eventsourcemapping.EventSourceArn = self.Stream or self.Queue
lambda_eventsourcemapping.StartingPosition = self.StartingPosition
lambda_eventsourcemapping.BatchSize = self.BatchSize
lambda_eventsourcemapping.Enabled = self.Enabled

if 'role' in kwargs:
self._link_policy(kwargs['role'])
Expand Down
9 changes: 9 additions & 0 deletions samtranslator/validator/sam_schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,9 @@
},
"Stream": {
"type": "string"
},
"Enabled": {
"type": "boolean"
}
},
"required": [
Expand Down Expand Up @@ -512,6 +515,9 @@
},
"Stream": {
"type": "string"
},
"Enabled": {
"type": "boolean"
}
},
"required": [
Expand All @@ -534,6 +540,9 @@
"type": "object"
}
]
},
"Enabled": {
"type": "boolean"
}
},
"required": [
Expand Down
1 change: 1 addition & 0 deletions tests/translator/input/sqs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ Resources:
Properties:
Queue: arn:aws:sqs:us-west-2:012345678901:my-queue
BatchSize: 10
Enabled: false
1 change: 1 addition & 0 deletions tests/translator/input/streams.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Resources:
Stream: arn:aws:kinesis:us-west-2:012345678901:stream/my-stream
BatchSize: 100
StartingPosition: TRIM_HORIZON
Enabled: false
DynamoDBFunction:
Type: 'AWS::Serverless::Function'
Properties:
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/aws-cn/sqs.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 10,
"Enabled": false,
"EventSourceArn": "arn:aws:sqs:us-west-2:012345678901:my-queue",
"FunctionName": {
"Ref": "SQSFunction"
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/aws-cn/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 100,
"Enabled": false,
"EventSourceArn": "arn:aws:kinesis:us-west-2:012345678901:stream/my-stream",
"FunctionName": {
"Ref": "KinesisFunction"
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/aws-us-gov/sqs.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 10,
"Enabled": false,
"EventSourceArn": "arn:aws:sqs:us-west-2:012345678901:my-queue",
"FunctionName": {
"Ref": "SQSFunction"
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/aws-us-gov/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 100,
"Enabled": false,
"EventSourceArn": "arn:aws:kinesis:us-west-2:012345678901:stream/my-stream",
"FunctionName": {
"Ref": "KinesisFunction"
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/sqs.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 10,
"Enabled": false,
"EventSourceArn": "arn:aws:sqs:us-west-2:012345678901:my-queue",
"FunctionName": {
"Ref": "SQSFunction"
Expand Down
1 change: 1 addition & 0 deletions tests/translator/output/streams.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"BatchSize": 100,
"Enabled": false,
"EventSourceArn": "arn:aws:kinesis:us-west-2:012345678901:stream/my-stream",
"FunctionName": {
"Ref": "KinesisFunction"
Expand Down
6 changes: 6 additions & 0 deletions versions/2016-10-31.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,7 @@ Property Name | Type | Description
Stream | `string` | **Required.** ARN of the Amazon Kinesis stream.
StartingPosition | `string` | **Required.** One of `TRIM_HORIZON` or `LATEST`.
BatchSize | `integer` | Maximum number of stream records to process per function invocation.
Enabled | `boolean` | Indicates whether Lambda begins polling the event source.

##### Example: Kinesis event source object

Expand All @@ -360,6 +361,7 @@ Properties:
Stream: arn:aws:kinesis:us-east-1:123456789012:stream/my-stream
StartingPosition: TRIM_HORIZON
BatchSize: 10
Enabled: false
```

#### DynamoDB
Expand All @@ -373,6 +375,7 @@ Property Name | Type | Description
Stream | `string` | **Required.** ARN of the DynamoDB stream.
StartingPosition | `string` | **Required.** One of `TRIM_HORIZON` or `LATEST`.
BatchSize | `integer` | Maximum number of stream records to process per function invocation.
Enabled | `boolean` | Indicates whether Lambda begins polling the event source.

##### Example: DynamoDB event source object

Expand All @@ -382,6 +385,7 @@ Properties:
Stream: arn:aws:dynamodb:us-east-1:123456789012:table/TestTable/stream/2016-08-11T21:21:33.291
StartingPosition: TRIM_HORIZON
BatchSize: 10
Enabled: false
```

#### SQS
Expand All @@ -394,6 +398,7 @@ Property Name | Type | Description
---|:---:|---
Queue | `string` | **Required.** ARN of the SQS queue.
BatchSize | `integer` | Maximum number of messages to process per function invocation.
Enabled | `boolean` | Indicates whether Lambda begins polling the event source.

##### Example: SQS event source object

Expand All @@ -402,6 +407,7 @@ Type: SQS
Properties:
Queue: arn:aws:sqs:us-west-2:012345678901:my-queue # NOTE: FIFO SQS Queues are not yet supported
BatchSize: 10
Enabled: false
```

#### Api
Expand Down