|
1 | | -""" SAM macro definitions """ |
| 1 | +""" SAM macro definitions """ |
2 | 2 |
|
3 | 3 | import copy |
4 | 4 | from contextlib import suppress |
@@ -181,6 +181,7 @@ class SamFunction(SamResourceMacro): |
181 | 181 | "RuntimeManagementConfig": PassThroughProperty(False), |
182 | 182 | "LoggingConfig": PassThroughProperty(False), |
183 | 183 | "RecursiveLoop": PassThroughProperty(False), |
| 184 | + "SourceKMSKeyArn": PassThroughProperty(False), |
184 | 185 | } |
185 | 186 |
|
186 | 187 | FunctionName: Optional[Intrinsicable[str]] |
@@ -224,6 +225,7 @@ class SamFunction(SamResourceMacro): |
224 | 225 | FunctionUrlConfig: Optional[Dict[str, Any]] |
225 | 226 | LoggingConfig: Optional[Dict[str, Any]] |
226 | 227 | RecursiveLoop: Optional[str] |
| 228 | + SourceKMSKeyArn: Optional[str] |
227 | 229 |
|
228 | 230 | event_resolver = ResourceTypeResolver( |
229 | 231 | samtranslator.model.eventsources, |
@@ -439,7 +441,7 @@ def _validate_and_inject_resource( |
439 | 441 | ARN property, so to handle conditional ifs we have to inject if conditions in the auto created |
440 | 442 | SQS/SNS resources as well as in the policy documents. |
441 | 443 | """ |
442 | | - accepted_types_list = ["SQS", "SNS", "EventBridge", "Lambda"] |
| 444 | + accepted_types_list = ["SQS", "SNS", "EventBridge", "Lambda", "S3Bucket"] |
443 | 445 | auto_inject_list = ["SQS", "SNS"] |
444 | 446 | resource: Optional[Union[SNSTopic, SQSQueue]] = None |
445 | 447 | policy = {} |
@@ -630,6 +632,8 @@ def _add_event_invoke_managed_policy( |
630 | 632 | return IAMRolePolicies.event_bus_put_events_role_policy(dest_arn, logical_id) |
631 | 633 | if _type == "Lambda": |
632 | 634 | return IAMRolePolicies.lambda_invoke_function_role_policy(dest_arn, logical_id) |
| 635 | + if _type == "S3Bucket": |
| 636 | + return IAMRolePolicies.s3_send_event_payload_role_policy(dest_arn, logical_id) |
633 | 637 | return {} |
634 | 638 |
|
635 | 639 | def _construct_role( |
@@ -885,7 +889,10 @@ def _construct_inline_code(*args: Any, **kwargs: Dict[str, Any]) -> Dict[str, An |
885 | 889 | else: |
886 | 890 | raise InvalidResourceException(self.logical_id, "Either 'InlineCode' or 'CodeUri' must be set.") |
887 | 891 | dispatch_function: Callable[..., Dict[str, Any]] = artifact_dispatch[filtered_key] |
888 | | - return dispatch_function(artifacts[filtered_key], self.logical_id, filtered_key) |
| 892 | + code_dict = dispatch_function(artifacts[filtered_key], self.logical_id, filtered_key) |
| 893 | + if self.SourceKMSKeyArn and packagetype == ZIP: |
| 894 | + code_dict["SourceKMSKeyArn"] = self.SourceKMSKeyArn |
| 895 | + return code_dict |
889 | 896 |
|
890 | 897 | def _construct_version( # noqa: PLR0912 |
891 | 898 | self, |
|
0 commit comments