Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .cfnlintrc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ ignore_templates:
- tests/translator/output/**/function_with_metrics_config.json
- tests/translator/output/**/function_with_self_managed_kafka_and_schema_registry.json # cfnlint is not updated to recognize the SchemaRegistryConfig property
- tests/translator/output/**/function_with_msk_with_schema_registry_config.json # cfnlint is not updated to recognize the SchemaRegistryConfig property
- tests/translator/output/**/*capacity_provider*.json # TODO: Remove this once CFN updates
- tests/translator/output/aws-*/*capacity_provider*.json # Ignore Capacity Provider test format in non-aws partitions
- tests/translator/output/**/function_with_tenancy_config.json # cfnlint is not updated to recognize the TenancyConfig property
- tests/translator/output/**/function_with_tenancy_and_api_event.json # cfnlint is not updated to recognize the TenancyConfig property
- tests/translator/output/**/function_with_tenancy_and_httpapi_event.json # cfnlint is not updated to recognize the TenancyConfig property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,12 +88,12 @@ class Properties(BaseModel):
# TODO: Change back to passthrough_prop after CloudFormation schema is updated with AWS::Lambda::CapacityProvider
# Optional KMS key ARN - passes through directly to CFN for encryption configuration
# Uses PassThroughProp because it's a direct 1:1 mapping with no SAM transformation
# KMSKeyArn: Optional[PassThroughProp] = passthrough_prop(
# KmsKeyArn: Optional[PassThroughProp] = passthrough_prop(
# PROPERTIES_STEM,
# "KMSKeyArn",
# ["AWS::Lambda::CapacityProvider", "Properties", "KMSKeyArn"],
# "KmsKeyArn",
# ["AWS::Lambda::CapacityProvider", "Properties", "KmsKeyArn"],
# )
KMSKeyArn: Optional[PassThroughProp] # TODO: add documentation
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation


class Globals(BaseModel):
Expand All @@ -120,7 +120,7 @@ class Globals(BaseModel):
# Uses custom ScalingConfig class because SAM renames construct (CapacityProviderScalingConfig→ScalingConfig)
ScalingConfig: Optional[ScalingConfig] = properties("ScalingConfig")

KMSKeyArn: Optional[PassThroughProp] # TODO: add documentation
KmsKeyArn: Optional[PassThroughProp] # TODO: add documentation


class Resource(ResourceAttributes):
Expand Down
4 changes: 2 additions & 2 deletions samtranslator/model/capacity_provider/generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ def _create_capacity_provider(self) -> LambdaCapacityProvider:
if self.scaling_config:
capacity_provider.CapacityProviderScalingConfig = self._transform_scaling_config()

# Set the KMSKeyArn if provided
# Set the KmsKeyArn if provided
if self.kms_key_arn:
capacity_provider.KMSKeyArn = self.kms_key_arn
capacity_provider.KmsKeyArn = self.kms_key_arn

# Pass through resource attributes
if self.passthrough_resource_attributes:
Expand Down
4 changes: 2 additions & 2 deletions samtranslator/model/capacity_provider/resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LambdaCapacityProvider(Resource):
"Tags": GeneratedProperty(),
"InstanceRequirements": GeneratedProperty(),
"CapacityProviderScalingConfig": GeneratedProperty(),
"KMSKeyArn": GeneratedProperty(),
"KmsKeyArn": GeneratedProperty(),
}

CapacityProviderName: Optional[Intrinsicable[str]]
Expand All @@ -31,7 +31,7 @@ class LambdaCapacityProvider(Resource):
Tags: Optional[List[Dict[str, Any]]]
InstanceRequirements: Optional[Dict[str, Any]]
CapacityProviderScalingConfig: Optional[Dict[str, Any]]
KMSKeyArn: Optional[Intrinsicable[str]]
KmsKeyArn: Optional[Intrinsicable[str]]

runtime_attrs = {
"name": lambda self: ref(self.logical_id),
Expand Down
6 changes: 3 additions & 3 deletions samtranslator/model/sam_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ class SamCapacityProvider(SamResourceMacro):
"PropagateTags": Property(False, IS_BOOL),
"InstanceRequirements": Property(False, IS_DICT),
"ScalingConfig": Property(False, IS_DICT),
"KMSKeyArn": Property(False, one_of(IS_STR, IS_DICT)),
"KmsKeyArn": Property(False, one_of(IS_STR, IS_DICT)),
}

CapacityProviderName: Optional[Intrinsicable[str]]
Expand All @@ -1478,7 +1478,7 @@ class SamCapacityProvider(SamResourceMacro):
PropagateTags: Optional[bool]
InstanceRequirements: Optional[Dict[str, Any]]
ScalingConfig: Optional[Dict[str, Any]]
KMSKeyArn: Optional[Intrinsicable[str]]
KmsKeyArn: Optional[Intrinsicable[str]]

# Validation rules
__validation_rules__ = [
Expand Down Expand Up @@ -1509,7 +1509,7 @@ def to_cloudformation(self, **kwargs: Any) -> List[Resource]:
model.InstanceRequirements.dict(exclude_none=True) if model.InstanceRequirements else None
),
scaling_config=model.ScalingConfig.dict(exclude_none=True) if model.ScalingConfig else None,
kms_key_arn=passthrough_value(model.KMSKeyArn),
kms_key_arn=passthrough_value(model.KmsKeyArn),
depends_on=self.depends_on,
resource_attributes=self.resource_attributes,
passthrough_resource_attributes=self.get_passthrough_resource_attributes(),
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/plugins/globals/globals.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ class Globals:
"Tags",
"InstanceRequirements",
"ScalingConfig",
"KMSKeyArn",
"KmsKeyArn",
"PropagateTags",
],
}
Expand Down
4 changes: 2 additions & 2 deletions samtranslator/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -278147,7 +278147,7 @@
"markdownDescription": "Instance requirements for the capacity provider.\n*Type*: [InstanceRequirements](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-capacityprovider-instancerequirements.html)\n*Required*: No\n*AWS CloudFormation compatibility*: This property is passed directly to the [`InstanceRequirements`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements) property of an `AWS::Lambda::CapacityProvider` resource.",
"title": "InstanceRequirements"
},
"KMSKeyArn": {
"KmsKeyArn": {
"$ref": "#/definitions/PassThroughProp"
},
"OperatorRole": {
Expand Down Expand Up @@ -278206,7 +278206,7 @@
"markdownDescription": "Instance requirements for the capacity provider.\n*Type*: [InstanceRequirements](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-capacityprovider-instancerequirements.html)\n*Required*: No\n*AWS CloudFormation compatibility*: This property is passed directly to the [`InstanceRequirements`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements) property of an `AWS::Lambda::CapacityProvider` resource.",
"title": "InstanceRequirements"
},
"KMSKeyArn": {
"KmsKeyArn": {
"$ref": "#/definitions/PassThroughProp"
},
"OperatorRole": {
Expand Down
4 changes: 2 additions & 2 deletions schema_source/sam.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5138,7 +5138,7 @@
"markdownDescription": "Instance requirements for the capacity provider.\n*Type*: [InstanceRequirements](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-capacityprovider-instancerequirements.html)\n*Required*: No\n*AWS CloudFormation compatibility*: This property is passed directly to the [`InstanceRequirements`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements) property of an `AWS::Lambda::CapacityProvider` resource.",
"title": "InstanceRequirements"
},
"KMSKeyArn": {
"KmsKeyArn": {
"$ref": "#/definitions/PassThroughProp"
},
"OperatorRole": {
Expand Down Expand Up @@ -5197,7 +5197,7 @@
"markdownDescription": "Instance requirements for the capacity provider.\n*Type*: [InstanceRequirements](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-property-capacityprovider-instancerequirements.html)\n*Required*: No\n*AWS CloudFormation compatibility*: This property is passed directly to the [`InstanceRequirements`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-capacityprovider.html#cfn-lambda-capacityprovider-instancerequirements) property of an `AWS::Lambda::CapacityProvider` resource.",
"title": "InstanceRequirements"
},
"KMSKeyArn": {
"KmsKeyArn": {
"$ref": "#/definitions/PassThroughProp"
},
"OperatorRole": {
Expand Down
2 changes: 1 addition & 1 deletion tests/model/capacity_provider/test_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def test_to_cloudformation_with_provided_permissions(self):
properties["VpcConfig"], {"SubnetIds": ["subnet-123", "subnet-456"], "SecurityGroupIds": ["sg-123"]}
)
self.assertEqual(properties["PermissionsConfig"]["CapacityProviderOperatorRoleArn"], operator_role)
self.assertEqual(properties["KMSKeyArn"], self.kms_key_arn)
self.assertEqual(properties["KmsKeyArn"], self.kms_key_arn)

def test_to_cloudformation_with_auto_generated_permissions(self):
"""Test to_cloudformation with auto-generated operator role"""
Expand Down
4 changes: 2 additions & 2 deletions tests/model/capacity_provider/test_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def test_properties(self):
{"PredefinedMetricType": "LambdaCapacityProviderAverageCPUUtilization", "TargetValue": 70.0}
],
}
capacity_provider.KMSKeyArn = "arn:aws:kms:us-west-2:123456789012:key/abcd1234-ab12-cd34-ef56-abcdef123456"
capacity_provider.KmsKeyArn = "arn:aws:kms:us-west-2:123456789012:key/abcd1234-ab12-cd34-ef56-abcdef123456"

# Verify properties
self.assertEqual(capacity_provider.CapacityProviderName, "test-provider")
Expand Down Expand Up @@ -64,7 +64,7 @@ def test_properties(self):
},
)
self.assertEqual(
capacity_provider.KMSKeyArn, "arn:aws:kms:us-west-2:123456789012:key/abcd1234-ab12-cd34-ef56-abcdef123456"
capacity_provider.KmsKeyArn, "arn:aws:kms:us-west-2:123456789012:key/abcd1234-ab12-cd34-ef56-abcdef123456"
)

def test_runtime_attributes(self):
Expand Down
8 changes: 4 additions & 4 deletions tests/translator/input/capacity_provider_full.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ Resources:
ScalingConfig:
MaxVCpuCount: 10
AverageCPUUtilization: 75.0
KMSKeyArn: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv
KmsKeyArn: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv

CapacityProviderTwo:
Type: AWS::Serverless::CapacityProvider
Properties:
CapacityProviderName: customized-capacity-provider
CapacityProviderName: customized-capacity-provider2
VpcConfig:
SecurityGroupIds:
- sg-12345678
Expand All @@ -39,7 +39,7 @@ Resources:
- subnet-12345678
ScalingConfig:
AverageCPUUtilization: 75.0
KMSKeyArn: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv
KmsKeyArn: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv

PartialCapacityProviderThree:
Type: AWS::Serverless::CapacityProvider
Expand All @@ -57,4 +57,4 @@ Resources:
- c5.xlarge
ScalingConfig:
MaxVCpuCount: 10
KMSKeyArn: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv
KmsKeyArn: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Globals:
InstanceRequirements:
Architectures:
- x86_64
KMSKeyArn: some-kms-arn
KmsKeyArn: some-kms-arn

Function:
Runtime: python3.12
Expand Down Expand Up @@ -131,8 +131,6 @@ Resources:
Properties:
CapacityProviderName: !Sub "${AWS::StackName}-${Environment}-capacity-provider"
InstanceRequirements:
Architectures:
- arm64
ExcludedTypes:
- t2.micro
- t2.small
Expand Down
2 changes: 2 additions & 0 deletions tests/translator/input/capacity_provider_minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,5 @@ Resources:
VpcConfig:
SubnetIds:
- subnet-12345678
SecurityGroupIds:
- sg-12345678
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Parameters:
Type: Number
Default: 81.2

KMSKeyArn:
KmsKeyArn:
Type: String
Default: arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv

Expand All @@ -65,4 +65,4 @@ Resources:
ScalingConfig:
MaxVCpuCount: !Ref MaxVCpuCount
AverageCPUUtilization: !Ref TargetCPU
KMSKeyArn: !Ref KMSKeyArn
KmsKeyArn: !Ref KmsKeyArn
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ Resources:
- subnet-87654321
ScalingConfg: # Typo: missing 'i'
MaxVCpuCount: 10
KMSKeyArn: arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012 # Typo: should be KMSKeyArn
KMSKeyArn: arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012 # Typo: should be KmsKeyArn
# This test will actually fail only with the first error, so the rest are just ignored
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Resources:
Timeout: 30
AutoPublishAlias: Production
CapacityProviderConfig:
Arn: arn:aws:lambda:us-east-1:123456789012:capacity-provider/test-capacity-provider
Arn: arn:aws:lambda:us-east-1:123456789012:capacity-provider:test-capacity-provider
PerExecutionEnvironmentMaxConcurrency: 50
FunctionScalingConfig:
MinExecutionEnvironments: 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Resources:
Variables:
ENVIRONMENT: production
CapacityProviderConfig:
Arn: arn:aws:lambda:us-east-1:123456789012:capacity-provider/test-capacity-provider
Arn: arn:aws:lambda:us-east-1:123456789012:capacity-provider:test-capacity-provider
PerExecutionEnvironmentMaxConcurrency: 100
ExecutionEnvironmentMemoryGiBPerVCpu: 4.0
FunctionScalingConfig:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ Resources:
Handler: hello.handler
Runtime: python3.12
CapacityProviderConfig:
Arn: arn:aws:lambda:us-east-1:123456789012:capacity-provider/test-capacity-provider
Arn: arn:aws:lambda:us-east-1:123456789012:capacity-provider:test-capacity-provider
8 changes: 4 additions & 4 deletions tests/translator/output/aws-cn/capacity_provider_full.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Resources": {
"CapacityProviderTwo": {
"Properties": {
"CapacityProviderName": "customized-capacity-provider",
"CapacityProviderName": "customized-capacity-provider2",
"CapacityProviderScalingConfig": {
"ScalingMode": "Manual",
"ScalingPolicies": [
Expand All @@ -14,7 +14,7 @@
}
]
},
"KMSKeyArn": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"PermissionsConfig": {
"CapacityProviderOperatorRoleArn": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -93,7 +93,7 @@
"arm64"
]
},
"KMSKeyArn": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"PermissionsConfig": {
"CapacityProviderOperatorRoleArn": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -169,7 +169,7 @@
"c5.xlarge"
]
},
"KMSKeyArn": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"PermissionsConfig": {
"CapacityProviderOperatorRoleArn": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,14 @@
},
"InstanceRequirements": {
"Architectures": [
"x86_64",
"arm64"
"x86_64"
],
"ExcludedInstanceTypes": [
"t2.micro",
"t2.small"
]
},
"KMSKeyArn": "some-kms-arn",
"KmsKeyArn": "some-kms-arn",
"PermissionsConfig": {
"CapacityProviderOperatorRoleArn": {
"Fn::GetAtt": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
}
],
"VpcConfig": {
"SecurityGroupIds": [
"sg-12345678"
],
"SubnetIds": [
"subnet-12345678"
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"Default": "t2.micro",
"Type": "String"
},
"KMSKeyArn": {
"KmsKeyArn": {
"Default": "arn:aws:kms:us-east-1:123456789012:key/abcd1234-ef56-gh78-ij90-klmnopqrstuv",
"Type": "String"
},
Expand Down Expand Up @@ -84,8 +84,8 @@
}
]
},
"KMSKeyArn": {
"Ref": "KMSKeyArn"
"KmsKeyArn": {
"Ref": "KmsKeyArn"
},
"PermissionsConfig": {
"CapacityProviderOperatorRoleArn": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"Properties": {
"CapacityProviderConfig": {
"LambdaManagedInstancesCapacityProviderConfig": {
"CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test-capacity-provider",
"CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider:test-capacity-provider",
"PerExecutionEnvironmentMaxConcurrency": 50
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Properties": {
"CapacityProviderConfig": {
"LambdaManagedInstancesCapacityProviderConfig": {
"CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test-capacity-provider",
"CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider:test-capacity-provider",
"ExecutionEnvironmentMemoryGiBPerVCpu": 4,
"PerExecutionEnvironmentMaxConcurrency": 100
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"Properties": {
"CapacityProviderConfig": {
"LambdaManagedInstancesCapacityProviderConfig": {
"CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider/test-capacity-provider"
"CapacityProviderArn": "arn:aws:lambda:us-east-1:123456789012:capacity-provider:test-capacity-provider"
}
},
"Code": {
Expand Down
Loading
Loading