Skip to content

Commit

Permalink
feat: surface Enabled property on stream event sources (#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
tryantwit authored and jlhood committed Dec 5, 2018
1 parent 910ffce commit f27c460
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 1 deletion.
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 @@ -442,6 +442,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 @@ -451,6 +452,7 @@ Properties:
Stream: arn:aws:kinesis:us-east-1:123456789012:stream/my-stream
StartingPosition: TRIM_HORIZON
BatchSize: 10
Enabled: false
```

#### DynamoDB
Expand All @@ -464,6 +466,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 @@ -473,6 +476,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 @@ -485,6 +489,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 @@ -493,6 +498,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

0 comments on commit f27c460

Please sign in to comment.