Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing !Sub and !If instrinsic functions #528

Closed
ericraymond opened this issue Jul 4, 2018 · 10 comments
Closed

Missing !Sub and !If instrinsic functions #528

ericraymond opened this issue Jul 4, 2018 · 10 comments
Labels
priority/1-critical stage/in-progress A fix is being worked on stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/regression
Milestone

Comments

@ericraymond
Copy link

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

@jfuss
Copy link
Contributor

jfuss commented Jul 5, 2018

This is also related to #450 and #476.

Going to update labels.

@charsleysa
Copy link
Contributor

charsleysa commented Dec 12, 2018

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

@mnapoli
Copy link

mnapoli commented Jan 10, 2019

@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

@dhruvsood dhruvsood added this to the Backlog milestone Jan 18, 2019
@mnapoli
Copy link

mnapoli commented Feb 8, 2019

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

@jfuss
Copy link
Contributor

jfuss commented May 7, 2019

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.

@jfuss jfuss changed the title Missing !Sub !Ref and !If instrinsic functions Missing !Sub and !If instrinsic functions Jun 17, 2019
@viksrivat viksrivat mentioned this issue Jul 9, 2019
6 tasks
@henrikbjorn
Copy link

Running into this also for Layers.

@joshpeng
Copy link

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.

@awood45 awood45 added stage/in-progress A fix is being worked on stage/in-review labels Aug 12, 2019
@jfuss jfuss added the stage/waiting-for-release Fix has been merged to develop and is waiting for a release label Aug 14, 2019
@daveykane
Copy link

Also having trouble with !Sub not working with Layers

@jfuss
Copy link
Contributor

jfuss commented Sep 16, 2019

Release in v0.21.0.

Closing

@jfuss jfuss closed this as completed Sep 16, 2019
@ulfbrehmer
Copy link

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
Labels
priority/1-critical stage/in-progress A fix is being worked on stage/waiting-for-release Fix has been merged to develop and is waiting for a release type/regression
Projects
None yet
Development

No branches or pull requests

10 participants