serverless-application-model icon indicating copy to clipboard operation
serverless-application-model copied to clipboard

Resource metadata is removed when converting 'AWS::Serverless::Function' to 'AWS::Lambda::Function'

Open sunnyone opened this issue 8 years ago • 9 comments

"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.

sunnyone avatar Jan 23 '18 07:01 sunnyone

Also running into the same issue

jamesjia94 avatar Mar 28 '18 04:03 jamesjia94

Unfortunately, resource metadata is currently not supported in SAM yet. You can submit a PR for this feature. Otherwise, we will prioritize this accordingly.

Simon2228 avatar Jul 30 '18 17:07 Simon2228

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)?

jlhood avatar Jan 09 '20 17:01 jlhood

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?

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

PatMyron avatar Jun 17 '20 16:06 PatMyron

Metadata should be supported, and preserved, in Globals too .. to avoid C&P Metadata in multiple function

drAlberT avatar Jun 26 '20 10:06 drAlberT

Any updates on preserving metadata? We're trying to use the resource-level metadata in order to support configuration of custom macros.

RonitRudra avatar Aug 10 '20 15:08 RonitRudra

Closing this ticket as the fix is merged.

c2tarun avatar Feb 02 '21 18:02 c2tarun

This issue is still not resolved from SAM side.

c2tarun avatar Feb 11 '21 18:02 c2tarun

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!

mndeveci avatar Jun 09 '21 17:06 mndeveci