Skip to content
This repository has been archived by the owner on Dec 24, 2023. It is now read-only.

Make EventSourceMapping.starting_position optional. #25

Merged
merged 2 commits into from
Jun 28, 2018

Conversation

CyrusNajmabadi
Copy link
Contributor

Also opened as a PR against terraform here: hashicorp/terraform-provider-aws#5024

Amazon recently made it possible to have SQS events trigger Lambdas.  See: https://aws.amazon.com/blogs/aws/aws-lambda-adds-amazon-simple-queue-service-to-supported-event-sources/ for more details. 

As part of this they specifically utilize CreateSourceEventMapping to describe the mapping between SQS and Lambda: https://docs.aws.amazon.com/lambda/latest/dg/with-sqs.html

*However*, as part of this, they changed the StartingPosition message property from required to optional.  You can see that it was previous required here: https://web.archive.org/web/20171222204154/https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-eventsourcemapping.html

```
StartingPosition
    The position in the stream where Lambda starts reading. For valid values, see CreateEventSourceMapping in the AWS Lambda Developer Guide.
    Required: Yes
    Type: String
    Update requires: Replacement
```

But now is optional in the current set of docs:

```
StartingPosition
    The position in the stream where Lambda starts reading. For valid values, see CreateEventSourceMapping in the AWS Lambda Developer Guide.
    Required: No
    Type: String
    Update requires: Replacement
```

Unfortunately, this makes is (afaict) impossible to use terraform to configure this EventSourceMapping.  If i leave out the starting_position property, terraform complains with:

```
Plan apply failed:
Error creating Lambda event source mapping: ValidationException: 1 validation error detected: Value '' at 'startingPosition' failed to satisfy constraint: Member must satisfy enum value set: [LATEST, AT_TIMESTAMP, TRIM_HORIZON]
```

However, if i supply any of those, AWS itself errors out with:

```
Plan apply failed: 
Error creating Lambda event source mapping: InvalidParameterValueException: StartingPosition is not valid for SQS event sources.
```

This PR attempts to rectify things by making this property optional to match current AWS expectations.
@CyrusNajmabadi CyrusNajmabadi requested a review from lukehoban June 28, 2018 23:00
@CyrusNajmabadi
Copy link
Contributor Author

Preemptively merging in.

@CyrusNajmabadi CyrusNajmabadi merged commit 9a05d7f into pulumi-master Jun 28, 2018
@CyrusNajmabadi CyrusNajmabadi deleted the optionalProp branch June 28, 2018 23:02
Copy link

@lukehoban lukehoban left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -3,12 +3,12 @@ layout: "aws"
page_title: "AWS: aws_lambda_event_source_mapping"
sidebar_current: "docs-aws-resource-lambda-event-source-mapping"
description: |-
Provides a Lambda event source mapping. This allows Lambda functions to get events from Kinesis and DynamoDB.
Provides a Lambda event source mapping. This allows Lambda functions to get events from Kinesis, DynamoDB and SQS

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Intentional that the trailing period was dropped?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants