11

I am trying to deploy a rails app to Amazon Elastic Beanstalk(eb) environment

I got this error back:

Uploading: [##################################################] 100% Done...
2019-01-24 09:42:16    INFO    Environment update is starting.      
2019-01-24 09:42:26    ERROR   Service:AmazonCloudFormation, Message:Template format error: Parameter 'EnvironmentVariables' default value '[****]' length is greater than 4096.
2019-01-24 09:42:26    ERROR   Failed to deploy application.

I found this

The combined size of all environment properties cannot exceed 4,096 bytes when stored as strings with the format key=value.

in the amazon docs here.

My environment properties key value combined is much bigger than 4096 chars.

as most of the values are credentials for API and Payments, thus I end up with just a dozen of keys.

My app work just fine in Heroku, there is no such limitation on the env variables. I am wondering what is the reason behind this restrictions in eb.

Is there anyone experience with this?

In my case, I would like to increase the limit (4096). I don't wanna change my code just to fit the eb restrictions.

I am also open for any kind of workaround to overcome this 4096 chars.

Many thanks in advance!

djvg
  • 11,722
  • 5
  • 72
  • 103
channa ly
  • 9,479
  • 14
  • 53
  • 86
  • If you have a lot of long environment variable values that you can store as certificate files instead, see [this issue](https://stackoverflow.com/a/53991672/1753903) – littleforest Jan 26 '19 at 22:30
  • The [docs](https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-softwaresettings.html#environments-cfg-softwaresettings-console) also say "Values can contain up to 256 characters. ", but, at this very moment I'm looking at a fully functional environment with several environment property values more than 400 characters each... – djvg Oct 08 '21 at 15:56

1 Answers1

8

Beanstalk uses Cloudformation underneath to provision environments. As a result, there is a limit on environment variables. You can not increase this limit because it is hard-coded in the kernel to PAGE_SIZE.

This is a nice resource that explains an alternative approach for solving this problem.

Tony Vincent
  • 13,354
  • 7
  • 49
  • 68
  • I think I will go with hybrid ways to make sure I can run the app and see other challenges with eb as early as possible. After having done successfully I will try the approach you mentioned above. Thanks a lot. – channa ly Feb 01 '19 at 01:45
  • 1
    From the same other than the linked resource. Fresh blog post on Aws::SSM https://www.honeybadger.io/blog/configuration-with-ssm-parameter-store/ – Mathieu J. Oct 29 '19 at 00:14
  • @MathieuJ.Thanks. Updated answer – Tony Vincent Apr 17 '20 at 17:14
  • Thanks for the insight! Still, this remains a very inconvenient restriction. – djvg Oct 08 '21 at 15:01
  • did any one found any other workaround except Aws::SSM – Rahul Jul 11 '23 at 12:27