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

Can I write the mapping templates (in api.yaml) using block strings? #26

Open
juancpgo opened this issue Apr 30, 2021 · 1 comment
Open

Comments

@juancpgo
Copy link

I'm struggling to figure out the right syntax to use in CloudFormation templates.

Is there a particular reason why the mapping templates were written with double quoted strings, as opposed to block strings?

responseTemplates:
  application/json: "#set($inputRoot = $input.path('$'))[ \
    #foreach($elem in $inputRoot.Items) { \
      \"id\":\"$elem.id.S\", \
      \"url\": \"$elem.url.S\", \
      \"timestamp\": \"$elem.timestamp.S\", \
      \"owner\": \"$elem.owner.S\"} \
    #if($foreach.hasNext),#end \
    #end]"

Using a multiline/block string seems so much more writable and readable:

responseTemplates:
  application/json: |-
    #set($inputRoot = $input.path('$'))[
      #foreach($elem in $inputRoot.Items) {
        "id": "$elem.id.S",
        "url": "$elem.url.S",
        "timestamp": "$elem.timestamp.S",
        "owner": "$elem.owner.S"}
      #if($foreach.hasNext),#end
    #end]

(this example is from api.yaml line 171)

@juancpgo
Copy link
Author

juancpgo commented May 1, 2021

Ps: After consideration I finally got it: the developer probably generated the VTL code using the AWS console and copy/pasted to the template. So it wasn't a choice of syntax, it was just his way of "playing safe" and being productive.

Anyways.. sorry, I know this isn't really an "issue". But I was mistakenly thinking that maybe it had to be done that way (with double quoted strings).

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

1 participant