11""" SAM macro definitions """
2- from copy import deepcopy
3-
42from six import string_types
53from tags .resource_tagging import get_tag_list
64import samtranslator .model .eventsources
@@ -56,7 +54,8 @@ class SamFunction(SamResourceMacro):
5654 'AutoPublishAlias' : PropertyType (False , one_of (is_str ()))
5755 }
5856 event_resolver = ResourceTypeResolver (samtranslator .model .eventsources , samtranslator .model .eventsources .pull ,
59- samtranslator .model .eventsources .push , samtranslator .model .eventsources .cloudwatchlogs )
57+ samtranslator .model .eventsources .push ,
58+ samtranslator .model .eventsources .cloudwatchlogs )
6059
6160 # DeadLetterQueue
6261 dead_letter_queue_policy_actions = {'SQS' : 'sqs:SendMessage' , 'SNS' : 'sns:Publish' }
@@ -67,7 +66,6 @@ class SamFunction(SamResourceMacro):
6766 "Version" : LambdaVersion .resource_type ,
6867 }
6968
70-
7169 def resources_to_link (self , resources ):
7270 try :
7371 return {
@@ -148,7 +146,6 @@ def _get_resolved_alias_name(self, property_name, original_alias_value, intrinsi
148146
149147 return resolved_alias_name
150148
151-
152149 def _construct_lambda_function (self ):
153150 """Constructs and returns the Lambda function.
154151
@@ -216,7 +213,9 @@ def _construct_role(self, managed_policy_map):
216213 policy_documents = []
217214
218215 if self .DeadLetterQueue :
219- policy_documents .append (IAMRolePolicies .dead_letter_queue_policy (self .dead_letter_queue_policy_actions [self .DeadLetterQueue ['Type' ]], self .DeadLetterQueue ['TargetArn' ]))
216+ policy_documents .append (IAMRolePolicies .dead_letter_queue_policy (
217+ self .dead_letter_queue_policy_actions [self .DeadLetterQueue ['Type' ]],
218+ self .DeadLetterQueue ['TargetArn' ]))
220219
221220 for index , policy_entry in enumerate (function_policies .get ()):
222221
@@ -247,8 +246,9 @@ def _construct_role(self, managed_policy_map):
247246 managed_policy_arns .append (policy_arn )
248247 else :
249248 # Policy Templates are not supported here in the "core"
250- raise InvalidResourceException (self .logical_id ,
251- "Policy at index {} in the 'Policies' property is not valid" .format (index ))
249+ raise InvalidResourceException (
250+ self .logical_id ,
251+ "Policy at index {} in the 'Policies' property is not valid" .format (index ))
252252
253253 execution_role .ManagedPolicyArns = list (managed_policy_arns )
254254 execution_role .Policies = policy_documents or None
@@ -420,7 +420,8 @@ def _construct_alias(self, name, function, version):
420420 def _validate_deployment_preference_and_add_update_policy (self , deployment_preference_collection , lambda_alias ,
421421 intrinsics_resolver ):
422422 if 'Enabled' in self .DeploymentPreference :
423- self .DeploymentPreference ['Enabled' ] = intrinsics_resolver .resolve_parameter_refs (self .DeploymentPreference ['Enabled' ])
423+ self .DeploymentPreference ['Enabled' ] = intrinsics_resolver .resolve_parameter_refs (
424+ self .DeploymentPreference ['Enabled' ])
424425 if isinstance (self .DeploymentPreference ['Enabled' ], dict ):
425426 raise InvalidResourceException (self .logical_id , "'Enabled' must be a boolean value" )
426427
@@ -431,8 +432,9 @@ def _validate_deployment_preference_and_add_update_policy(self, deployment_prefe
431432
432433 if deployment_preference_collection .get (self .logical_id ).enabled :
433434 if self .AutoPublishAlias is None :
434- raise InvalidResourceException (self .logical_id ,
435- "'DeploymentPreference' requires AutoPublishAlias property to be specified" )
435+ raise InvalidResourceException (
436+ self .logical_id ,
437+ "'DeploymentPreference' requires AutoPublishAlias property to be specified" )
436438 if lambda_alias is None :
437439 raise ValueError ('lambda_alias expected for updating it with the appropriate update policy' )
438440
@@ -510,7 +512,8 @@ class SamSimpleTable(SamResourceMacro):
510512 'PrimaryKey' : PropertyType (False , dict_of (is_str (), is_str ())),
511513 'ProvisionedThroughput' : PropertyType (False , dict_of (is_str (), one_of (is_type (int ), is_type (dict )))),
512514 'TableName' : PropertyType (False , one_of (is_str (), is_type (dict ))),
513- 'Tags' : PropertyType (False , is_type (dict ))
515+ 'Tags' : PropertyType (False , is_type (dict )),
516+ 'SSESpecification' : PropertyType (False , is_type (dict ))
514517 }
515518 attribute_type_conversions = {
516519 'String' : 'S' ,
@@ -523,7 +526,6 @@ def to_cloudformation(self, **kwargs):
523526
524527 return [dynamodb_resources ]
525528
526-
527529 def _construct_dynamodb_table (self ):
528530 dynamodb_table = DynamoDBTable (self .logical_id , depends_on = self .depends_on )
529531
@@ -549,6 +551,9 @@ def _construct_dynamodb_table(self):
549551
550552 dynamodb_table .ProvisionedThroughput = provisioned_throughput
551553
554+ if self .SSESpecification :
555+ dynamodb_table .SSESpecification = self .SSESpecification
556+
552557 if self .TableName :
553558 dynamodb_table .TableName = self .TableName
554559
0 commit comments