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

Add Tags, Tracing, KmsKeyArn, DLQ to serverless(SAM) #853

Merged
merged 3 commits into from Oct 15, 2017
Merged

Add Tags, Tracing, KmsKeyArn, DLQ to serverless(SAM) #853

merged 3 commits into from Oct 15, 2017

Conversation

Laxenade
Copy link
Contributor

SAM(Serverless) is missing some of the function properties, add following properties to the template:

  • Tags
  • Tracing
  • KmsKeyArn
  • DeadLetterQueue
  • CodeUri, This has been covered in another PR #852

Copy link
Member

@markpeek markpeek left a comment

Choose a reason for hiding this comment

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

Looks good with a couple of cleanups needed. Fee free to pull the code implementing S3Location from my other PR to combine with this one (given the same files).

@@ -1,9 +1,39 @@
import unittest
from troposphere import Template
from troposphere.serverless import Function, Api, SimpleTable
from troposphere.serverless import Function, Api, SimpleTable, DeadLetterQueue
Copy link
Member

Choose a reason for hiding this comment

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

This should be alphabetized (yeah, I see it wasn't originally either).


def validate(self):
valid_types = ['SQS', 'SNS']
if self.properties['Type'] not in valid_types:
Copy link
Member

Choose a reason for hiding this comment

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

Type is not required so you need to check for existence before dereferencing it.

if 'Type' in self.properties and \
    self.properties['Type'] not in valid_types:
...

valid_types = ['SQS', 'SNS']
if self.properties['Type'] not in valid_types:
raise ValueError('Type must be either SQS or SNS')
return self.properties['Type']
Copy link
Member

Choose a reason for hiding this comment

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

Property validators do return a type but object validators (like this one) don't return anything.

@@ -45,7 +58,11 @@ class Function(AWSObject):
'Policies': (policy_validator, False),
'Environment': (Environment, False),
'VpcConfig': (VPCConfig, False),
'Events': (dict, False)
'Events': (dict, False),
Copy link
Member

Choose a reason for hiding this comment

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

The properties should be alphabetized (again, looks like they weren't to begin with).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is in the same order as defined here. I do prefer this order though, this way you could follow SAM's example more easily. (So you don't have to rearrange them in your mind to get something to work)

@markpeek markpeek merged commit f64ef0e into cloudtools:master Oct 15, 2017
@markpeek
Copy link
Member

Nice job. Thanks!

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

Successfully merging this pull request may close these issues.

None yet

2 participants