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

render incompatible with CloudFormation dynamic references #260

Closed
rymndhng opened this issue Jan 6, 2021 · 2 comments
Closed

render incompatible with CloudFormation dynamic references #260

rymndhng opened this issue Jan 6, 2021 · 2 comments

Comments

@rymndhng
Copy link
Contributor

rymndhng commented Jan 6, 2021

The iidy preprocessor fails when using CloudFormation dynamic references, such as {{resolve:ssm:..}}. See https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html

Template that reproduces this error:

AWSTemplateFormatVersion: 2010-09-09
Description: Lambda function code and related resources
Parameters:
  Environment:
   Type: String

Resources:
  LambdaFunction:
    Type: AWS::Lambda::Function
    Properties:
      Environment:
        Variables:
          MY_VAR: !Sub "{{resolve:ssm:/${Environment}/foo}}"

Command used for testing:

❯ iidy render sample.yml
error Error in string template at Root.Resources.LambdaFunction.Properties.Environment.Variables.MY_VAR:
       Parse error on line 1:
{{resolve:ssm:/${Environment}/foo}}
---------------^
Expecting 'ID', got 'INVALID'
       Template: {{resolve:ssm:/${Environment}/foo}}
rymndhng pushed a commit that referenced this issue Jan 6, 2021
fs.statSync will throw an error when the "file" does not exist (in the case of "-" for stdin).

Fixes #260
tavisrudd pushed a commit that referenced this issue Jan 6, 2021
fs.statSync will throw an error when the "file" does not exist (in the case of "-" for stdin).

Fixes #260
@rymndhng
Copy link
Contributor Author

rymndhng commented Jan 6, 2021

Oops, re-opening this issue. I mis-linked the PR 🤦

@rymndhng rymndhng reopened this Jan 6, 2021
@tavisrudd
Copy link
Collaborator

The trick is to escape the handlebars braces with a double backslash:

AWSTemplateFormatVersion: 2010-09-09
Description: Lambda function code and related resources
Parameters:
  Environment:
   Type: String

Resources:
  LambdaFunction:
    Type: AWS::Lambda::Function
    Properties:
      Environment:
        Variables:
          MY_VAR: !Sub "\\{{resolve:ssm:/${Environment}/foo}}"

I've added a note about this to the docs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants