Skip to content

Missing !Sub and !If instrinsic functions #528

Closed

Description

@ericraymond

Description:

Related to issue #490, please add support for !Sub !Ref, and a minimal !If implementation for environment vars in serverless function or in a globals section.

Not having this functionality means copy-paste duplication within a template, maintaining a duplicate template for local execution, copy-paste duplication to specify env vars on the command line, and/or the inability to override default values of environment variables via parameters at runtime.

Bonus points for supporting all variations expressing the fn in Yaml and Json

In 0.3.0 this was refactored and appears only to be supporter in a very limited context (e.g., swagger urls?).

Output of sam --version: 0.4.0

Activity

  1. jfuss commented on Jul 5, 2018

    @jfuss
    Contributor

    This is also related to #450 and #476.

    Going to update labels.

  2. charsleysa commented on Dec 12, 2018

    @charsleysa
    Contributor

    @jfuss is there any progress on this?

    It's a limiter for using layers as the ARN contains the region so can't have the template just load the correct layer by subbing the region. Managed to work around this so far but with layers I don't see a workaround.

  3. mnapoli commented on Jan 10, 2019

    @mnapoli

    @charsleysa exactly! I face the same problem with region and even layer versions (I want to use environment variables for those). Related: aws/serverless-application-model#751

  4. added this to the Backlog milestone on Jan 18, 2019
  5. mnapoli commented on Feb 8, 2019

    @mnapoli

    Just a heads up for those interested, !Ref has been implemented in #657.

  6. jfuss commented on May 7, 2019

    @jfuss
    Contributor

    I have (slowly) been working on some Sub support. I have pushed the code to my branch/repo. I have some functional tests that are working but missing:

    • Unit tests
    • A note/warning on not being able to resolve some Sub. This is really important since we cannot resolve commuted properties of resources.
    • Integ tests

    If anyone is looking for a good way to contribute and need/want sub support, feel free to take what I started as the base.

  7. changed the title [-]Missing !Sub !Ref and !If instrinsic functions[/-] [+]Missing !Sub and !If instrinsic functions[/+] on Jun 17, 2019
  8. henrikbjorn commented on Jul 26, 2019

    @henrikbjorn

    Running into this also for Layers.

  9. joshpeng commented on Aug 11, 2019

    @joshpeng

    How do we get !Ref to work? I keep running into this:

    Invalid value in Template for key: MY_ENV_VAR: expected string
    

    Here is my template.yml:

    Parameters:
      SomeTestParam:
        Type: String
        Default: foobar
    
    ...
    
    SomeLambdaFunction:
        Type: AWS::Serverless::Function
        Properties:
    
          ...
    
          Environment:
            Variables:
              MY_ENV_VAR: !Ref SomeTestParam

    I am on SAM CLI v0.19.0.

  10. added
    stage/waiting-for-release
    on Aug 14, 2019
  11. daveykane commented on Sep 8, 2019

    @daveykane

    Also having trouble with !Sub not working with Layers

  12. jfuss commented on Sep 16, 2019

    @jfuss
    Contributor

    Release in v0.21.0.

    Closing

  13. ulfbrehmer commented on Oct 23, 2020

    @ulfbrehmer

    Now it's October 2020, sam cli version 1.6.2. Intrinsics like !Sub or !FindInMap don't work in sam local as far as I can see ('Unable to resolve property'). I can't find any other issue regarding this. Does that mean the plans to support this have been dropped?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/1-criticalstage/in-progressstage/waiting-for-releasetype/regression

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions