realestate-com-au / stackup

a simple CLI and Ruby API for AWS CloudFormation
MIT License
97 stars 34 forks source link

Escaped slashes break stackup #35

Closed tigris closed 7 years ago

tigris commented 7 years ago

For some reason, a template with escaped slashes, e.g. "Description": "DC\/OS AWS CloudFormation Template" will break stackup.

#-❯ docker run -v $PWD:/cwd \
  --region ap-southeast-2 \
  -e AWS_ACCESS_KEY_ID \
  -e AWS_SECRET_ACCESS_KEY \
  -e AWS_SECURITY_TOKEN \
  -e AWS_SESSION_TOKEN \
  realestate/stackup:0.9.5 \
  dpearce-mesos up -t mesos.json -p dpearce-mesos.json

/usr/local/lib/ruby/2.3.0/psych.rb:377:in `parse': (mesos.json): found unknown escape character while parsing a quoted scalar at line 3 column 18 (Psych::SyntaxError)

At first I thought ruby was having trouble with that JSON string in general. But:

#-❯ ruby -rjson -e 'puts JSON.parse(File.read("./mesos.json")).keys'
AWSTemplateFormatVersion
Description
Metadata
Parameters
Mappings
Resources
Outputs

So then I thought it was something to do with docker volumes, but:

#-❯ docker run -v $PWD:/cwd ruby:2.3 ruby -rjson -e 'puts JSON.parse(File.read("/cwd/mesos.json")).keys'
AWSTemplateFormatVersion
Description
Metadata
Parameters
Mappings
Resources
Outputs

Lastly, I verified I was testing on the correct version of ruby:

#-❯ docker run --entrypoint ruby realestate/stackup:0.9.5 -v
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
lukeck commented 7 years ago

@tigris it looks like you're using stackup 0.95 can you try this again with the latest 1.0.4 please?

tigris commented 7 years ago

@lukeck tested

Unable to find image 'realestate/stackup:1.0.4' locally
1.0.4: Pulling from realestate/stackup
3690ec4760f9: Already exists 
6353f0aa4196: Already exists 
d2d5126b7327: Pull complete 
1485806b5da4: Pull complete 
3b431878784e: Pull complete 
2db386cfbcfa: Pull complete 
c6cd263db203: Pull complete 
339f4b28eb5b: Pull complete 
5b9a945e93ed: Pull complete 
c6779b653a2c: Pull complete 
e9fa5607c7b7: Pull complete 
352bdf8f37b4: Pull complete 
693f1c289613: Pull complete 
d12415a5ee9b: Pull complete 
e850272da95f: Pull complete 
f7155121e843: Pull complete 
Digest: sha256:b401a3740637114d436754a9074ac73ad763ded81830f27a8c1e03a8c7fc267b
Status: Downloaded newer image for realestate/stackup:1.0.4
/usr/local/lib/ruby/2.3.0/psych.rb:379:in `parse': (template.json): found unknown escape character while parsing a quoted scalar at line 3 column 18 (Psych::SyntaxError)
mdub commented 7 years ago

Curious. Psych does indeed appear to have issues there.

I'll change it to use JSON to parse .json files (as God intended).