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
Add Tags, Tracing, KmsKeyArn, DLQ to serverless(SAM) #853
Conversation
There was a problem hiding this 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).
tests/test_serverless.py
Outdated
@@ -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 |
There was a problem hiding this comment.
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).
troposphere/serverless.py
Outdated
|
||
def validate(self): | ||
valid_types = ['SQS', 'SNS'] | ||
if self.properties['Type'] not in valid_types: |
There was a problem hiding this comment.
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:
...
troposphere/serverless.py
Outdated
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'] |
There was a problem hiding this comment.
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), |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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)
Nice job. Thanks! |
SAM(Serverless) is missing some of the function properties, add following properties to the template: