Resource metadata is removed when converting 'AWS::Serverless::Function' to 'AWS::Lambda::Function'
"Metadata" in AWS::Serverless::Function is removed when it's converted to AWS::Lambda::Function.
MyFunction:
Type: 'AWS::Serverless::Function'
Properties:
Handler: index.handler
Runtime: nodejs6.10
Policies:
- Version: '2012-10-17'
Statement:
- Effect: Allow
Action:
- cloudformation:DescribeStackResource
Resource: (...ARN...)
Metadata: # <--- REMOVED!!!
CustomData: ABC
ImageConvertFunctionArn: !ImportValue OtherFunctionArn
Resource metadata is useful to customize behaviors in a function on Lambda@Edge since it does not support environmental variables of Lambda.
Also running into the same issue
Unfortunately, resource metadata is currently not supported in SAM yet. You can submit a PR for this feature. Otherwise, we will prioritize this accordingly.
This issue came up for cfn-lint since Metadata can be used to add inline cfn-lint configuration within a template. See https://github.com/aws-cloudformation/cfn-python-lint/issues/1294 for details.
One question I have is: should SAM (1) pass Metadata on AWS::Serverless::Function through to just the AWS::Lambda::Function resource or (2) pass Metadata through to all resources created as a result of that AWS::Serverless::Function? My intuition is we should go with (1), but just wondering if anyone has a use case for (2)?
One question I have is: should SAM (1) pass Metadata on
AWS::Serverless::Functionthrough to just theAWS::Lambda::Functionresource or (2) pass Metadata through to all resources created as a result of thatAWS::Serverless::Function?
Inclined towards 2. Easier to support going forward and makes more sense for every AWS::Serverless resource type to blindly pass metadata to every resource it creates because we can't understand all use-cases. If we pick and choose passing to only certain resources created by AWS::Serverless resources, we end up with the same problem where there are still certain resources where customers cannot set metadata
Metadata should be supported, and preserved, in Globals too .. to avoid C&P Metadata in multiple function
Any updates on preserving metadata? We're trying to use the resource-level metadata in order to support configuration of custom macros.
Closing this ticket as the fix is merged.
This issue is still not resolved from SAM side.
Closing this issue since it is been released with SAM v1.36.0 and SAM CLI v1.24.0.
You can read more about how resource level attributes are handled in SAM via our updated documentation; https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification-resource-attributes.html
Thanks!