ThoughtWorksStudios / eb_deployer

AWS Elastic Beanstalk blue-green deployment automation from ThoughtWorks Mingle Team
MIT License
400 stars 94 forks source link

Environment variables w/ "\n" fail #64

Closed fredkelly closed 8 years ago

fredkelly commented 8 years ago

Firstly, this is a great tool, thank you for creating it!

I'm finding a little niggle trying to set an environment variable that is read from a file (i.e. containing newline characters).

I have something like this (see YAML doc):

# config/eb_deployer.yml
      - namespace: aws:elasticbeanstalk:application:environment
        option_name: MY_VAR
        value: |
          First line
          Second line

If I load this through IRB, all is fine:

require 'yaml'
deployer = YAML.load_file('config/eb_deployer.yml')
deployer['environments']['staging']['option_settings'].select{|opt| opt['option_name'] =='MY_VAR'}.first['value']
=> "First line\nSecond line"

When I come to run a deployment using the gem, I get an error:

(Namespace: 'aws:cloudformation:template:parameter', OptionName: 'EnvironmentVariables'): Not a List of Key/Value pairs.

Is there a way I can include file values in ENV that contain newlines without error?

Much appreciated!

xli commented 8 years ago

A simplest way to handle it is you change it to be ",", then handle it in your application code.

fredkelly commented 8 years ago

Hey Xiao, thanks for the response, I ended up opting for a similar solution. It's a shame this can't be supported in the way I describe, but I guess that's more a limitation of the eb tool than anything else.

xli commented 8 years ago

It's either EB aws-sdk bug, or more likely is EB server side bug.

wpc commented 8 years ago

@fredkelly eb_deployer will just simply pass through any value you provide to ElasticBeanstalk api. Seems like ElasticBeanstalk service internally treats any multiple line value as a collection value. You may contact with AWS support for this.