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
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class CodeUri(BaseModel):
Bucket: SamIntrinsicable[str] = codeuri("Bucket")
Key: SamIntrinsicable[str] = codeuri("Key")
Version: SamIntrinsicable[str] | None = codeuri("Version")
StorageMode: SamIntrinsicable[str] | None = codeuri("StorageMode")


class Hooks(BaseModel):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ class ContentUri(BaseModel):
"Version",
["AWS::Lambda::LayerVersion.Content", "S3ObjectVersion"],
)
StorageMode: PassThroughProp | None = passthrough_prop(
CONTENT_URI_STEM,
"StorageMode",
["AWS::Lambda::LayerVersion.Content", "S3ObjectStorageMode"],
)


class Properties(BaseModel):
Expand Down
4 changes: 3 additions & 1 deletion samtranslator/internal/schema_source/sam-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@
"sam-property-function-functioncode": {
"Bucket": "An Amazon S3 bucket in the same AWS Region as your function. \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`S3Bucket`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3bucket) property of the `AWS::Lambda::Function` `Code` data type.",
"Key": "The Amazon S3 key of the deployment package. \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`S3Key`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3key) property of the `AWS::Lambda::Function` `Code` data type.",
"StorageMode": "Controls how Lambda stores the deployment package. Valid values: `COPY` (Lambda copies the object to its own storage; the object can be deleted after function creation) and `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the function). \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectStorageMode`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectstoragemode) property of the `AWS::Lambda::Function` `Code` data type.",
"Version": "For versioned objects, the version of the deployment package object to use. \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectVersion`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectversion) property of the `AWS::Lambda::Function` `Code` data type."
},
"sam-property-function-functionscalingconfig": {
Expand Down Expand Up @@ -609,6 +610,7 @@
"sam-property-layerversion-layercontent": {
"Bucket": "The Amazon S3 bucket of the layer archive. \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`S3Bucket`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3bucket) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
"Key": "The Amazon S3 key of the layer archive. \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`S3Key`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3key) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
"StorageMode": "Controls how Lambda stores the layer archive. Valid values: `COPY` (Lambda copies the object to its own storage; the object can be deleted after layer creation) and `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the layer version). \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectStorageMode`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectstoragemode) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
"Version": "For versioned objects, the version of the layer archive object to use. \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectVersion`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectversion) property of the `AWS::Lambda::LayerVersion` `Content` data type."
},
"sam-property-simpletable-primarykeyobject": {
Expand Down Expand Up @@ -996,4 +998,4 @@
"NetworkProtocol": "The network protocol for the VPC egress connection. \n*Valid values*: `IPv4`, `DualStack` \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`NetworkProtocol`](https://docs.aws.amazon.com/AWSCloudFormation/latest/TemplateReference/aws-properties-lambda-networkconnector-vpcegressconfiguration.html#cfn-lambda-networkconnector-vpcegressconfiguration-networkprotocol) property of `Configuration.VpcEgressConfiguration` of an `AWS::Lambda::NetworkConnector` resource."
}
}
}
}
2 changes: 2 additions & 0 deletions samtranslator/model/s3_utils/uri_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,6 @@ def construct_s3_location_object(
code = {"S3Bucket": s3_pointer["Bucket"], "S3Key": s3_pointer["Key"]}
if "Version" in s3_pointer:
code["S3ObjectVersion"] = s3_pointer["Version"]
if "StorageMode" in s3_pointer:
code["S3ObjectStorageMode"] = s3_pointer["StorageMode"]
return code
24 changes: 24 additions & 0 deletions samtranslator/schema/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -191395,6 +191395,8 @@
"type": "string"
},
"S3ObjectStorageMode": {
"markdownDescription": "Controls how Lambda stores the deployment package: `COPY` (Lambda copies the object to its own storage) or `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the function).",
"title": "S3ObjectStorageMode",
"type": "string"
},
"S3ObjectVersion": {
Expand Down Expand Up @@ -191801,6 +191803,11 @@
"title": "S3Key",
"type": "string"
},
"S3ObjectStorageMode": {
"markdownDescription": "Controls how Lambda stores the layer archive: `COPY` (Lambda copies the object to its own storage) or `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the layer version).",
"title": "S3ObjectStorageMode",
"type": "string"
},
"S3ObjectVersion": {
"markdownDescription": "For versioned objects, the version of the layer archive object to use.",
"title": "S3ObjectVersion",
Expand Down Expand Up @@ -365032,6 +365039,18 @@
"markdownDescription": "The Amazon S3 key of the deployment package. \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`S3Key`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3key) property of the `AWS::Lambda::Function` `Code` data type.",
"title": "Key"
},
"StorageMode": {
"anyOf": [
{
"type": "object"
},
{
"type": "string"
}
],
"markdownDescription": "Controls how Lambda stores the deployment package. Valid values: `COPY` (Lambda copies the object to its own storage; the object can be deleted after function creation) and `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the function). \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectStorageMode`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectstoragemode) property of the `AWS::Lambda::Function` `Code` data type.",
"title": "StorageMode"
},
"Version": {
"anyOf": [
{
Expand Down Expand Up @@ -365193,6 +365212,11 @@
"title": "Key",
"type": "string"
},
"StorageMode": {
"markdownDescription": "Controls how Lambda stores the layer archive. Valid values: `COPY` (Lambda copies the object to its own storage; the object can be deleted after layer creation) and `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the layer version). \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectStorageMode`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectstoragemode) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
"title": "StorageMode",
"type": "string"
},
"Version": {
"markdownDescription": "For versioned objects, the version of the layer archive object to use. \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectVersion`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectversion) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
"title": "Version",
Expand Down
7 changes: 7 additions & 0 deletions schema_source/cloudformation.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -191346,6 +191346,8 @@
"type": "string"
},
"S3ObjectStorageMode": {
"markdownDescription": "Controls how Lambda stores the deployment package: `COPY` (Lambda copies the object to its own storage) or `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the function).",
"title": "S3ObjectStorageMode",
"type": "string"
},
"S3ObjectVersion": {
Expand Down Expand Up @@ -191752,6 +191754,11 @@
"title": "S3Key",
"type": "string"
},
"S3ObjectStorageMode": {
"markdownDescription": "Controls how Lambda stores the layer archive: `COPY` (Lambda copies the object to its own storage) or `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the layer version).",
"title": "S3ObjectStorageMode",
"type": "string"
},
"S3ObjectVersion": {
"markdownDescription": "For versioned objects, the version of the layer archive object to use.",
"title": "S3ObjectVersion",
Expand Down
29 changes: 29 additions & 0 deletions schema_source/sam.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,18 @@
"markdownDescription": "The Amazon S3 key of the deployment package. \n*Type*: String \n*Required*: Yes \n*CloudFormation compatibility*: This property is passed directly to the [`S3Key`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3key) property of the `AWS::Lambda::Function` `Code` data type.",
"title": "Key"
},
"StorageMode": {
"anyOf": [
{
"type": "object"
},
{
"type": "string"
}
],
"markdownDescription": "Controls how Lambda stores the deployment package. Valid values: `COPY` (Lambda copies the object to its own storage; the object can be deleted after function creation) and `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the function). \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectStorageMode`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-function-code.html#cfn-lambda-function-code-s3objectstoragemode) property of the `AWS::Lambda::Function` `Code` data type.",
"title": "StorageMode"
},
"Version": {
"anyOf": [
{
Expand Down Expand Up @@ -642,6 +654,23 @@
],
"title": "Key"
},
"StorageMode": {
"__samPassThrough": {
"markdownDescriptionOverride": "Controls how Lambda stores the layer archive. Valid values: `COPY` (Lambda copies the object to its own storage; the object can be deleted after layer creation) and `REFERENCE` (Lambda references the object in your S3 bucket; the object must remain in place for the lifetime of the layer version). \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectStorageMode`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectstoragemode) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
"schemaPath": [
"definitions",
"AWS::Lambda::LayerVersion.Content",
"properties",
"S3ObjectStorageMode"
]
},
"allOf": [
{
"$ref": "#/definitions/PassThroughProp"
}
],
"title": "StorageMode"
},
"Version": {
"__samPassThrough": {
"markdownDescriptionOverride": "For versioned objects, the version of the layer archive object to use. \n*Type*: String \n*Required*: No \n*CloudFormation compatibility*: This property is passed directly to the [`S3ObjectVersion`](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-lambda-layerversion-content.html#cfn-lambda-layerversion-content-s3objectversion) property of the `AWS::Lambda::LayerVersion` `Content` data type.",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Resources:
FunctionWithCopyMode:
Type: AWS::Serverless::Function
Properties:
CodeUri:
Bucket: somebucket
Key: somekey
Version: '1'
StorageMode: COPY
Handler: hello.handler
Runtime: python3.12

FunctionWithReferenceMode:
Type: AWS::Serverless::Function
Properties:
CodeUri:
Bucket: somebucket
Key: somekey
Version: '1'
StorageMode: REFERENCE
Handler: hello.handler
Runtime: python3.12
26 changes: 26 additions & 0 deletions tests/translator/input/layer_with_s3_object_storage_mode.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Metadata:
# cfn-lint's bundled CFN schema does not yet recognize S3ObjectStorageMode on
# AWS::Lambda::LayerVersion.Content. Suppress E3002 until upstream catches up.
cfn-lint:
config:
ignore_checks:
- E3002

Resources:
LayerWithCopyMode:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri:
Bucket: somebucket
Key: somekey
Version: '1'
StorageMode: COPY

LayerWithReferenceMode:
Type: AWS::Serverless::LayerVersion
Properties:
ContentUri:
Bucket: somebucket
Key: somekey
Version: '1'
StorageMode: REFERENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
{
"Resources": {
"FunctionWithCopyMode": {
"Properties": {
"Code": {
"S3Bucket": "somebucket",
"S3Key": "somekey",
"S3ObjectStorageMode": "COPY",
"S3ObjectVersion": "1"
},
"Handler": "hello.handler",
"Role": {
"Fn::GetAtt": [
"FunctionWithCopyModeRole",
"Arn"
]
},
"Runtime": "python3.12",
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::Lambda::Function"
},
"FunctionWithCopyModeRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
],
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::IAM::Role"
},
"FunctionWithReferenceMode": {
"Properties": {
"Code": {
"S3Bucket": "somebucket",
"S3Key": "somekey",
"S3ObjectStorageMode": "REFERENCE",
"S3ObjectVersion": "1"
},
"Handler": "hello.handler",
"Role": {
"Fn::GetAtt": [
"FunctionWithReferenceModeRole",
"Arn"
]
},
"Runtime": "python3.12",
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::Lambda::Function"
},
"FunctionWithReferenceModeRole": {
"Properties": {
"AssumeRolePolicyDocument": {
"Statement": [
{
"Action": [
"sts:AssumeRole"
],
"Effect": "Allow",
"Principal": {
"Service": [
"lambda.amazonaws.com"
]
}
}
],
"Version": "2012-10-17"
},
"ManagedPolicyArns": [
"arn:aws-cn:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole"
],
"Tags": [
{
"Key": "lambda:createdBy",
"Value": "SAM"
}
]
},
"Type": "AWS::IAM::Role"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
{
"Metadata": {
"cfn-lint": {
"config": {
"ignore_checks": [
"E3002"
]
}
}
},
"Resources": {
"LayerWithCopyModee8d50fb359": {
"DeletionPolicy": "Retain",
"Properties": {
"Content": {
"S3Bucket": "somebucket",
"S3Key": "somekey",
"S3ObjectStorageMode": "COPY",
"S3ObjectVersion": "1"
},
"LayerName": "LayerWithCopyMode"
},
"Type": "AWS::Lambda::LayerVersion"
},
"LayerWithReferenceMode0ed616eec0": {
"DeletionPolicy": "Retain",
"Properties": {
"Content": {
"S3Bucket": "somebucket",
"S3Key": "somekey",
"S3ObjectStorageMode": "REFERENCE",
"S3ObjectVersion": "1"
},
"LayerName": "LayerWithReferenceMode"
},
"Type": "AWS::Lambda::LayerVersion"
}
}
}
Loading