Skip to content

Commit 0101320

Browse files
authored
chore: more improved schema pass-throughs (#3057)
1 parent a28afd4 commit 0101320

File tree

4 files changed

+105
-88
lines changed

4 files changed

+105
-88
lines changed

samtranslator/internal/schema_source/aws_serverless_function.py

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -552,16 +552,31 @@ class Properties(BaseModel):
552552
"FunctionName",
553553
)
554554
FunctionUrlConfig: Optional[FunctionUrlConfig] = prop("FunctionUrlConfig")
555-
Handler: Optional[Handler] = prop("Handler")
555+
Handler: Optional[Handler] = passthrough_prop(
556+
PROPERTIES_STEM,
557+
"Handler",
558+
"AWS::Lambda::Function",
559+
"Handler",
560+
)
556561
ImageConfig: Optional[PassThroughProp] = prop("ImageConfig")
557562
ImageUri: Optional[PassThroughProp] = prop("ImageUri")
558563
InlineCode: Optional[PassThroughProp] = prop("InlineCode")
559564
KmsKeyArn: Optional[KmsKeyArn] = prop("KmsKeyArn")
560565
Layers: Optional[Layers] = prop("Layers")
561566
MemorySize: Optional[MemorySize] = prop("MemorySize")
562567
PackageType: Optional[PassThroughProp] = prop("PackageType")
563-
RolePath: Optional[RolePath] = prop("RolePath")
564-
PermissionsBoundary: Optional[PermissionsBoundary] = prop("PermissionsBoundary")
568+
RolePath: Optional[RolePath] = passthrough_prop(
569+
PROPERTIES_STEM,
570+
"RolePath",
571+
"AWS::IAM::Role",
572+
"Path",
573+
)
574+
PermissionsBoundary: Optional[PermissionsBoundary] = passthrough_prop(
575+
PROPERTIES_STEM,
576+
"PermissionsBoundary",
577+
"AWS::IAM::Role",
578+
"PermissionsBoundary",
579+
)
565580
Policies: Optional[Union[str, DictStrAny, List[Union[str, DictStrAny]]]] = prop("Policies")
566581
ProvisionedConcurrencyConfig: Optional[ProvisionedConcurrencyConfig] = passthrough_prop(
567582
PROPERTIES_STEM,
@@ -571,7 +586,12 @@ class Properties(BaseModel):
571586
)
572587
ReservedConcurrentExecutions: Optional[ReservedConcurrentExecutions] = prop("ReservedConcurrentExecutions")
573588
Role: Optional[SamIntrinsicable[str]] = prop("Role")
574-
Runtime: Optional[Runtime] = prop("Runtime")
589+
Runtime: Optional[Runtime] = passthrough_prop(
590+
PROPERTIES_STEM,
591+
"Runtime",
592+
"AWS::Lambda::Function",
593+
"Runtime",
594+
)
575595
SnapStart: Optional[SnapStart] = prop("SnapStart")
576596
RuntimeManagementConfig: Optional[RuntimeManagementConfig] = prop("RuntimeManagementConfig")
577597
Tags: Optional[Tags] = prop("Tags")
@@ -582,8 +602,18 @@ class Properties(BaseModel):
582602

583603

584604
class Globals(BaseModel):
585-
Handler: Optional[Handler] = prop("Handler")
586-
Runtime: Optional[Runtime] = prop("Runtime")
605+
Handler: Optional[Handler] = passthrough_prop(
606+
PROPERTIES_STEM,
607+
"Handler",
608+
"AWS::Lambda::Function",
609+
"Handler",
610+
)
611+
Runtime: Optional[Runtime] = passthrough_prop(
612+
PROPERTIES_STEM,
613+
"Runtime",
614+
"AWS::Lambda::Function",
615+
"Runtime",
616+
)
587617
CodeUri: Optional[CodeUriType] = prop("CodeUri")
588618
DeadLetterQueue: Optional[DeadLetterQueueType] = prop("DeadLetterQueue")
589619
Description: Optional[Description] = prop("Description")
@@ -602,8 +632,18 @@ class Globals(BaseModel):
602632
Layers: Optional[Layers] = prop("Layers")
603633
AutoPublishAlias: Optional[AutoPublishAlias] = prop("AutoPublishAlias")
604634
DeploymentPreference: Optional[DeploymentPreference] = prop("DeploymentPreference")
605-
RolePath: Optional[RolePath] = prop("RolePath")
606-
PermissionsBoundary: Optional[PermissionsBoundary] = prop("PermissionsBoundary")
635+
RolePath: Optional[RolePath] = passthrough_prop(
636+
PROPERTIES_STEM,
637+
"RolePath",
638+
"AWS::IAM::Role",
639+
"Path",
640+
)
641+
PermissionsBoundary: Optional[PermissionsBoundary] = passthrough_prop(
642+
PROPERTIES_STEM,
643+
"PermissionsBoundary",
644+
"AWS::IAM::Role",
645+
"PermissionsBoundary",
646+
)
607647
ReservedConcurrentExecutions: Optional[ReservedConcurrentExecutions] = prop("ReservedConcurrentExecutions")
608648
ProvisionedConcurrencyConfig: Optional[ProvisionedConcurrencyConfig] = prop("ProvisionedConcurrencyConfig")
609649
AssumeRolePolicyDocument: Optional[AssumeRolePolicyDocument] = prop("AssumeRolePolicyDocument")

samtranslator/internal/schema_source/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@ def replace_passthrough(d: Dict[str, Any]) -> Dict[str, Any]:
154154
passthrough = d["__samPassThrough"]
155155
schema = deepcopy(_deep_get(cfn_schema, passthrough["schemaPath"]))
156156
schema["markdownDescription"] = passthrough["markdownDescriptionOverride"]
157+
schema["title"] = d["title"] # Still want the original title, CFN property name could be different
157158
return schema
158159

159160
_replace_in_dict(

0 commit comments

Comments
 (0)