Skip to content

Commit

Permalink
Add support for Advanced logging in SAM
Browse files Browse the repository at this point in the history
  • Loading branch information
xazhao committed Nov 16, 2023
1 parent 3b53f8f commit 625913c
Show file tree
Hide file tree
Showing 13 changed files with 46 additions and 1,536 deletions.
1 change: 1 addition & 0 deletions docs/globals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ Currently, the following resources and properties are being supported:
Architectures:
EphemeralStorage:
RuntimeManagementConfig:
LoggingConfig:
Api:
# Properties of AWS::Serverless::Api
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ class ScheduleV2Event(BaseModel):
EphemeralStorage = Optional[PassThroughProp]
SnapStart = Optional[PassThroughProp] # TODO: check the type
RuntimeManagementConfig = Optional[PassThroughProp] # TODO: check the type
LoggingConfig = Optional[PassThroughProp] # TODO: add documentation


class Properties(BaseModel):
Expand Down Expand Up @@ -632,6 +633,7 @@ class Properties(BaseModel):
Tracing: Optional[Tracing] = prop("Tracing")
VersionDescription: Optional[PassThroughProp] = prop("VersionDescription")
VpcConfig: Optional[VpcConfig] = prop("VpcConfig")
LoggingConfig: Optional[PassThroughProp] # TODO: add documentation


class Globals(BaseModel):
Expand Down Expand Up @@ -689,6 +691,7 @@ class Globals(BaseModel):
)
SnapStart: Optional[SnapStart] = prop("SnapStart")
RuntimeManagementConfig: Optional[RuntimeManagementConfig] = prop("RuntimeManagementConfig")
LoggingConfig: Optional[PassThroughProp] # TODO: add documentation


class Resource(ResourceAttributes):
Expand Down
2 changes: 2 additions & 0 deletions samtranslator/model/lambda_.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class LambdaFunction(Resource):
"SnapStart": GeneratedProperty(),
"EphemeralStorage": GeneratedProperty(),
"RuntimeManagementConfig": GeneratedProperty(),
"LoggingConfig": GeneratedProperty(),
}

Code: Dict[str, Any]
Expand All @@ -60,6 +61,7 @@ class LambdaFunction(Resource):
SnapStart: Optional[Dict[str, Any]]
EphemeralStorage: Optional[Dict[str, Any]]
RuntimeManagementConfig: Optional[Dict[str, Any]]
LoggingConfig: Optional[Dict[str, Any]]

runtime_attrs = {"name": lambda self: ref(self.logical_id), "arn": lambda self: fnGetAtt(self.logical_id, "Arn")}

Expand Down
3 changes: 3 additions & 0 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class SamFunction(SamResourceMacro):
"SnapStart": PropertyType(False, IS_DICT),
"FunctionUrlConfig": PropertyType(False, IS_DICT),
"RuntimeManagementConfig": PassThroughProperty(False),
"LoggingConfig": PassThroughProperty(False),
}

FunctionName: Optional[Intrinsicable[str]]
Expand Down Expand Up @@ -220,6 +221,7 @@ class SamFunction(SamResourceMacro):
Architectures: Optional[List[Any]]
SnapStart: Optional[Dict[str, Any]]
FunctionUrlConfig: Optional[Dict[str, Any]]
LoggingConfig: Optional[Dict[str, Any]]

event_resolver = ResourceTypeResolver(
samtranslator.model.eventsources,
Expand Down Expand Up @@ -603,6 +605,7 @@ def _construct_lambda_function(self, intrinsics_resolver: IntrinsicsResolver) ->
lambda_function.CodeSigningConfigArn = self.CodeSigningConfigArn

lambda_function.RuntimeManagementConfig = self.RuntimeManagementConfig # type: ignore[attr-defined]
lambda_function.LoggingConfig = self.LoggingConfig
self._validate_package_type(lambda_function)
return lambda_function

Expand Down
1 change: 1 addition & 0 deletions samtranslator/plugins/globals/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ class Globals:
"EphemeralStorage",
"FunctionUrlConfig",
"RuntimeManagementConfig",
"LoggingConfig",
],
# Everything except
# DefinitionBody: because its hard to reason about merge of Swagger dictionaries
Expand Down
Loading

0 comments on commit 625913c

Please sign in to comment.