Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

elasticbeanstalk won't set virtual paths

I am trying the new AWS Elastic Beanstalk console ui. I am having a problem now to set up virtual paths on ui.

Basically I put all my static files, including index.html in a folder ui inside my bundle.

This is the bundle structure:

/ui
/ui/favicon.ico
/ui/index.html
/ui/static
/ui/static/css/...
/ui/static/js/...
/ui/static/media/...
package.json
yarn.lock
app.js // this is the node api and it works

The API works when access my [http://public]/api/alive. My intention is set virtual directories to serve static files from bundle folder ui.

The node api sends down the index.html when it doesn't match anything. This works: [http://public]/. I get the index.html.

Then the browser requests static files /static/js/main[hash].js. This works but the problem is I can't even set up any virtual path to play around. I need to map the browser request /static to /ui/static at AWS.

elasticbeanstalk error:

enter image description here

/static/: Invalid option specification (Namespace: 'aws:elasticbeanstalk:container:python:staticfiles', OptionName: '/static/'): Unknown configuration setting. static/: Invalid option specification (Namespace: 'aws:elasticbeanstalk:container:python:staticfiles', OptionName: 'static/'): Unknown configuration setting. /assets: Invalid option specification (Namespace: 'aws:elasticbeanstalk:container:python:staticfiles', OptionName: '/assets'): Unknown configuration setting. static: Invalid option specification (Namespace: 'aws:elasticbeanstalk:container:python:staticfiles', OptionName: 'static'): Unknown configuration setting.

No matter where I put the slashes, it wont work:

enter image description here

All the paths I specified exist inside my deployed app bundle, apart from /static/assets which is just to try anything different.

I am not sure if this is a bug on the new UI or not. If anyone had the same problem please let me know.

like image 528
Leonardo Avatar asked Jan 04 '18 21:01

Leonardo


People also ask

How do I link Route 53 to Elastic Beanstalk?

Sign in to the AWS Management Console and open the Route 53 console at https://console.aws.amazon.com/route53/ . In the navigation pane, choose Hosted zones. Choose the name of the hosted zone that you want to use to route traffic to your Elastic Beanstalk environment. Choose Create record.

When should you not use Elastic Beanstalk?

Elastic Beanstalk isn't great if you need a lot of environment variables. The simple reason is that Elastic Beanstalk has a hard limit of 4KB to store all key-value pairs. The environment had accumulated 74 environment variables — a few of them had exceedingly verbose names.


1 Answers

I found this question while trying to serve static content from a Python 3.7 Django application using Amazon Linux 2; however, I think the answer will be the same for different platforms.

Reading the documentation here I found this link: https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environment-cfg-staticfiles.html

which indicated a .config sample file like this

Example .ebextensions/static-files.config

option_settings:
  aws:elasticbeanstalk:environment:proxy:staticfiles:
    /html: statichtml  <-- path/to/your/static/dir/ (added by Nick)
    /images: staticimages

so, it looks like the namespace changed from aws:elasticbeanstalk:container:python:staticfiles to aws:elasticbeanstalk:environment:proxy:staticfiles. This seems to be a more generic reverse proxy to be platform agnostic which makes sense. Good job AWS.

When I tried this, amazingly the documentation was up to date and it worked.

like image 155
Nick Brady Avatar answered Sep 21 '22 09:09

Nick Brady