aws-cloudformation / rain

A development workflow tool for working with AWS CloudFormation.
Apache License 2.0
784 stars 70 forks source link

Modules can't contain directives #180

Closed ericzbeard closed 1 year ago

ericzbeard commented 1 year ago
unable to package template '/Users/ezbeard/Desktop/lambda-template.yaml': yaml: unmarshal errors:
line 0: cannot unmarshal !!map into string
Description: A module for lambda

Parameters:
  SourceDir:
    Type: String

Resources:
  ModuleExtension:
    Metadata: 
      Extends: AWS::Lambda::Function
    Properties:
      Runtime: python3.9
      Handler: index.handler
      ReservedConcurrentExecutions: 100
      Code: !Rain::S3 
        Path: !Ref SourceDir 
        Zip: true
        BucketProperty: S3Bucket
        KeyProperty: S3Key
ericzbeard commented 1 year ago

The problem is in the !Rain::S3 handler. It expects Path to be a string, since it has to zip and upload the code to S3. A !Ref needs to be resolved, which we could do if it was a normal template with the parameter provided on the command line. But the S3 handler doesn't know anything about the parent module, which is where the path is defined.