Skip to content

Commit 414132d

Browse files
authored
Merge pull request #3850 from aws/release-v1.104.0
Release 1.104.0 (to main)
2 parents 9a32a6d + f23b9d5 commit 414132d

File tree

93 files changed

+9208
-47
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+9208
-47
lines changed

.cfnlintrc.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ ignore_templates:
144144
- tests/translator/output/**/function_with_metrics_config.json
145145
- tests/translator/output/**/function_with_self_managed_kafka_and_schema_registry.json # cfnlint is not updated to recognize the SchemaRegistryConfig property
146146
- tests/translator/output/**/function_with_msk_with_schema_registry_config.json # cfnlint is not updated to recognize the SchemaRegistryConfig property
147+
- tests/translator/output/**/*capacity_provider*.json # TODO: Remove this once CFN updates
147148
- tests/translator/output/**/function_with_tenancy_config.json # cfnlint is not updated to recognize the TenancyConfig property
148149
- tests/translator/output/**/function_with_tenancy_and_api_event.json # cfnlint is not updated to recognize the TenancyConfig property
149150
- tests/translator/output/**/function_with_tenancy_and_httpapi_event.json # cfnlint is not updated to recognize the TenancyConfig property

samtranslator/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.103.0"
1+
__version__ = "1.104.0"
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
from __future__ import annotations
2+
3+
from typing import List, Literal, Optional
4+
5+
from samtranslator.internal.schema_source.common import (
6+
BaseModel,
7+
DictStrAny,
8+
PassThroughProp,
9+
ResourceAttributes,
10+
SamIntrinsicable,
11+
get_prop,
12+
)
13+
14+
PROPERTIES_STEM = "sam-resource-capacityprovider"
15+
VPC_CONFIG_STEM = "sam-property-capacityprovider-vpcconfig"
16+
INSTANCE_REQUIREMENTS_STEM = "sam-property-capacityprovider-instancerequirements"
17+
SCALING_CONFIG_STEM = "sam-property-capacityprovider-scalingconfig"
18+
19+
properties = get_prop(PROPERTIES_STEM)
20+
vpcconfig = get_prop(VPC_CONFIG_STEM)
21+
instancerequirements = get_prop(INSTANCE_REQUIREMENTS_STEM)
22+
scalingconfig = get_prop(SCALING_CONFIG_STEM)
23+
24+
25+
class VpcConfig(BaseModel):
26+
# Optional list of security group IDs - supports intrinsic functions for dynamic references
27+
SecurityGroupIds: Optional[List[SamIntrinsicable[str]]] = vpcconfig("SecurityGroupIds")
28+
# Required list of subnet IDs - supports intrinsic functions for dynamic VPC configuration
29+
SubnetIds: List[SamIntrinsicable[str]] = vpcconfig("SubnetIds")
30+
31+
32+
class InstanceRequirements(BaseModel):
33+
# Optional list of CPU architectures - maps to CFN InstanceRequirements.Architecture
34+
# Uses List[SamIntrinsicable[str]] to support intrinsic functions like !Ref for dynamic architecture values
35+
Architectures: Optional[List[SamIntrinsicable[str]]] = instancerequirements("Architectures")
36+
# Optional list of allowed EC2 instance types - maps to CFN InstanceRequirements.AllowedInstanceTypes
37+
# Uses List[SamIntrinsicable[str]] to support intrinsic functions like !Ref for dynamic instance types
38+
AllowedTypes: Optional[List[SamIntrinsicable[str]]] = instancerequirements("AllowedTypes")
39+
# Optional list of excluded EC2 instance types - maps to CFN InstanceRequirements.ExcludedInstanceTypes
40+
# Uses List[SamIntrinsicable[str]] to support intrinsic functions like !Ref for dynamic instance types
41+
ExcludedTypes: Optional[List[SamIntrinsicable[str]]] = instancerequirements("ExcludedTypes")
42+
43+
44+
class ScalingConfig(BaseModel):
45+
# Optional maximum instance count - maps to CFN CapacityProviderScalingConfig.MaxVCpuCount
46+
# Uses SamIntrinsicable[int] to support dynamic scaling limits via parameters/conditions
47+
MaxVCpuCount: Optional[SamIntrinsicable[int]] = scalingconfig("MaxVCpuCount")
48+
# Average CPU utilization target (0-100) - maps to CFN ScalingPolicies with CPU metric type
49+
# When specified, automatically sets ScalingMode to "Manual"
50+
# Uses SamIntrinsicable[float] to support dynamic scaling targets via parameters/conditions
51+
AverageCPUUtilization: Optional[SamIntrinsicable[float]] = scalingconfig("AverageCPUUtilization")
52+
53+
54+
class Properties(BaseModel):
55+
# TODO: Change back to passthrough_prop after CloudFormation schema is updated with AWS::Lambda::CapacityProvider
56+
# Optional capacity provider name - passes through directly to CFN AWS::Lambda::CapacityProvider
57+
# Uses PassThroughProp because it's a direct 1:1 mapping with no SAM transformation
58+
# CapacityProviderName: Optional[PassThroughProp] = passthrough_prop(
59+
# PROPERTIES_STEM,
60+
# "CapacityProviderName",
61+
# ["AWS::Lambda::CapacityProvider", "Properties", "CapacityProviderName"],
62+
# )
63+
CapacityProviderName: Optional[PassThroughProp] # TODO: add documentation
64+
65+
# Required VPC configuration - preserves CFN structure, required for EC2 instance networking
66+
# Uses custom VpcConfig class to validate required SubnetIds while maintaining passthrough behavior
67+
VpcConfig: VpcConfig = properties("VpcConfig")
68+
69+
# Optional operator role ARN - if not provided, SAM auto-generates one with EC2 management permissions
70+
OperatorRole: Optional[PassThroughProp] = properties("OperatorRole")
71+
72+
# Optional tags - SAM transforms key-value pairs to CFN Tag objects before passing to CFN
73+
# Uses DictStrAny to support flexible tag structure with string keys and any values
74+
Tags: Optional[DictStrAny] = properties("Tags")
75+
76+
# Optional flag to propagate tags to resources created by this capacity provider
77+
# When true, all tags defined on the capacity provider will be propagated to generated resources
78+
PropagateTags: Optional[bool] = properties("PropagateTags")
79+
80+
# Optional instance requirements - maps to CFN InstanceRequirements with property name shortening
81+
# Uses custom InstanceRequirements class because SAM shortens names
82+
InstanceRequirements: Optional[InstanceRequirements] = properties("InstanceRequirements")
83+
84+
# Optional scaling configuration - maps to CFN CapacityProviderScalingConfig
85+
# Uses custom ScalingConfig class because SAM renames construct (CapacityProviderScalingConfig→ScalingConfig)
86+
ScalingConfig: Optional[ScalingConfig] = properties("ScalingConfig")
87+
88+
# TODO: Change back to passthrough_prop after CloudFormation schema is updated with AWS::Lambda::CapacityProvider
89+
# Optional KMS key ARN - passes through directly to CFN for encryption configuration
90+
# Uses PassThroughProp because it's a direct 1:1 mapping with no SAM transformation
91+
# KMSKeyArn: Optional[PassThroughProp] = passthrough_prop(
92+
# PROPERTIES_STEM,
93+
# "KMSKeyArn",
94+
# ["AWS::Lambda::CapacityProvider", "Properties", "KMSKeyArn"],
95+
# )
96+
KMSKeyArn: Optional[PassThroughProp] # TODO: add documentation
97+
98+
99+
class Globals(BaseModel):
100+
# Global VPC configuration - can be inherited by capacity providers if not overridden
101+
# Uses custom VpcConfig class to validate required SubnetIds while maintaining passthrough behavior
102+
VpcConfig: Optional[VpcConfig] = properties("VpcConfig")
103+
104+
# Global operator role ARN - can be inherited by capacity providers if not overridden
105+
OperatorRole: Optional[PassThroughProp] = properties("OperatorRole")
106+
107+
# Global tags - can be inherited and merged with resource-specific tags
108+
# Uses DictStrAny to support flexible tag structure with string keys and any values
109+
Tags: Optional[DictStrAny] = properties("Tags")
110+
111+
# Global flag to propagate tags to resources created by capacity providers
112+
# When true, all tags defined on capacity providers will be propagated to generated resources
113+
PropagateTags: Optional[bool] = properties("PropagateTags")
114+
115+
# Global instance requirements - can be inherited by capacity providers if not overridden
116+
# Uses custom InstanceRequirements class because SAM shortens names
117+
InstanceRequirements: Optional[InstanceRequirements] = properties("InstanceRequirements")
118+
119+
# Global scaling configuration - can be inherited by capacity providers if not overridden
120+
# Uses custom ScalingConfig class because SAM renames construct (CapacityProviderScalingConfig→ScalingConfig)
121+
ScalingConfig: Optional[ScalingConfig] = properties("ScalingConfig")
122+
123+
KMSKeyArn: Optional[PassThroughProp] # TODO: add documentation
124+
125+
126+
class Resource(ResourceAttributes):
127+
# Literal type ensures only correct resource type is accepted
128+
Type: Literal["AWS::Serverless::CapacityProvider"]
129+
# Required properties using the Properties class for full validation
130+
Properties: Properties

samtranslator/internal/schema_source/aws_serverless_function.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
alexaskilleventproperties = get_prop("sam-property-function-alexaskill")
2121
apiauth = get_prop("sam-property-function-apifunctionauth")
2222
apieventproperties = get_prop("sam-property-function-api")
23+
capacityproviderconfig = get_prop("sam-property-function-capacityproviderconfig")
2324
cloudwatcheventproperties = get_prop("sam-property-function-cloudwatchevent")
2425
cloudwatchlogseventproperties = get_prop("sam-property-function-cloudwatchlogs")
2526
codeuri = get_prop("sam-property-function-functioncode")
@@ -535,6 +536,16 @@ class ScheduleV2Event(BaseModel):
535536
TenancyConfig = Optional[PassThroughProp]
536537

537538

539+
class CapacityProviderConfig(BaseModel):
540+
Arn: SamIntrinsicable[str] = capacityproviderconfig("Arn")
541+
PerExecutionEnvironmentMaxConcurrency: Optional[SamIntrinsicable[int]] = capacityproviderconfig(
542+
"PerExecutionEnvironmentMaxConcurrency"
543+
)
544+
ExecutionEnvironmentMemoryGiBPerVCpu: Optional[SamIntrinsicable[Union[int, float]]] = capacityproviderconfig(
545+
"ExecutionEnvironmentMemoryGiBPerVCpu"
546+
)
547+
548+
538549
class Properties(BaseModel):
539550
Architectures: Optional[Architectures] = passthrough_prop(
540551
PROPERTIES_STEM,
@@ -661,6 +672,12 @@ class Properties(BaseModel):
661672
LoggingConfig: Optional[PassThroughProp] # TODO: add documentation
662673
RecursiveLoop: Optional[PassThroughProp] # TODO: add documentation
663674
SourceKMSKeyArn: Optional[PassThroughProp] # TODO: add documentation
675+
CapacityProviderConfig: Optional[CapacityProviderConfig] = prop("CapacityProviderConfig") # TODO: add documentation
676+
FunctionScalingConfig: Optional[PassThroughProp] # TODO: add documentation
677+
VersionDeletionPolicy: Optional[SamIntrinsicable[Union[str, bool]]] = prop(
678+
"VersionDeletionPolicy"
679+
) # TODO: add documentation
680+
PublishToLatestPublished: Optional[SamIntrinsicable[Union[str, bool]]] # TODO: add documentation
664681
TenancyConfig: Optional[PassThroughProp] # TODO: add documentation
665682

666683

@@ -722,6 +739,12 @@ class Globals(BaseModel):
722739
LoggingConfig: Optional[PassThroughProp] # TODO: add documentation
723740
RecursiveLoop: Optional[PassThroughProp] # TODO: add documentation
724741
SourceKMSKeyArn: Optional[PassThroughProp] # TODO: add documentation
742+
CapacityProviderConfig: Optional[CapacityProviderConfig] = prop("CapacityProviderConfig") # TODO: add documentation
743+
FunctionScalingConfig: Optional[PassThroughProp] # TODO: add documentation
744+
VersionDeletionPolicy: Optional[SamIntrinsicable[Union[str, bool]]] = prop(
745+
"VersionDeletionPolicy"
746+
) # TODO: add documentation
747+
PublishToLatestPublished: Optional[SamIntrinsicable[Union[str, bool]]] # TODO: add documentation
725748
TenancyConfig: Optional[PassThroughProp] # TODO: add documentation
726749

727750

0 commit comments

Comments
 (0)