5

I receive the following error while trying to upload my instance in aws elasticbeanstalk:

The configuration file .ebextensions/setup.config in application version t5 contains invalid YAML or JSON. 
YAML exception: while scanning a quoted scalar in "<reader>", line 3, column 18: command: 
"aws s3 cp s3:elasticbeanstalk-u ... ^ found unexpected end of stream in "<reader>", 
line 5, column 1: ^ , JSON exception: Unexpected character (c) at position 0.. Update the configuration file.

Below is what is included in the setup.config file:

container_commands:
    01_setup_apache:
        command: "aws s3 cp s3:elasticbeanstalk-us-west-2-273610000489/enable_mod_rewrite.conf /etc/httpd/co

I am working with AWS elastic beanstalk and since I can't modify the httdp conf file to AllowOverride All in order to clean-up my URL with rewritte rule, I was suggested to work with ebextensions: http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/customize-containers.html

Update:

enter image description here

I think what runs problem is this:

RewriteEngine On

located in htaccess. almost like it cant accept rewritenegine being turned on.

Update2:

In /var/log/httpd/access_log

In /var/log/eb-activity.log:

Command CMD-TailLogs succeeded.
[2015-07-10T10:25:09.784Z] INFO  [25589] - [CMD-TailLogs] : Starting activity...
[2015-07-10T10:25:10.206Z] INFO  [25589] - [CMD-TailLogs/AddonsBefore] : Starting activity...
[2015-07-10T10:25:10.207Z] INFO  [25589] - [CMD-TailLogs/AddonsBefore] : Completed activity.
[2015-07-10T10:25:10.207Z] INFO  [25589] - [CMD-TailLogs/TailLogs] : Starting activity...
[2015-07-10T10:25:10.207Z] INFO  [25589] - [CMD-TailLogs/TailLogs/TailLogs] : Starting activity...

In /var/log/eb-commandprocessor.log

    [2015-07-10T10:37:19.644Z] DEBUG [25873] : Checking if the command processor should execute...
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Checking whether the command is applicable to instance (i-80bbbd77)..
[2015-07-10T10:37:19.645Z] INFO  [25873] : Command is applicable to this instance (i-80bbbd77)..
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Checking if the received command stage is valid..
[2015-07-10T10:37:19.645Z] INFO  [25873] : No stage_num in command. Valid stage..
[2015-07-10T10:37:19.645Z] INFO  [25873] : Command processor should execute command.
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Storing current stage..
[2015-07-10T10:37:19.645Z] DEBUG [25873] : Stage_num does not exist. Not saving null stage. Returning..
[2015-07-10T10:37:19.646Z] INFO  [25873] : Executing command: CMD-TailLogs...
[2015-07-10T10:37:19.646Z] DEBUG [25873] : Reading config file: /etc/elasticbeanstalk/.aws-eb-stack.properties
[2015-07-10T10:37:19.647Z] DEBUG [25873] : Refreshing metadata..
[2015-07-10T10:37:20.061Z] DEBUG [25873] : Refreshed environment metadata.
[2015-07-10T10:37:20.061Z] DEBUG [25873] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_ContainerConfigFileContent||commands..
[2015-07-10T10:37:20.062Z] DEBUG [25873] : Retrieving metadata for key: AWS::ElasticBeanstalk::Ext||_API||_Commands..
[2015-07-10T10:37:20.064Z] INFO  [25873] : Found enabled addons: ["logpublish"].
[2015-07-10T10:37:20.066Z] INFO  [25873] : Updating Command definition of addon logpublish.
[2015-07-10T10:37:20.066Z] DEBUG [25873] : Loaded definition of Command CMD-TailLogs.
[2015-07-10T10:37:20.066Z] INFO  [25873] : Executing command CMD-TailLogs activities...
[2015-07-10T10:37:20.066Z] DEBUG [25873] : Setting environment variables..
[2015-07-10T10:37:20.066Z] INFO  [25873] : Running AddonsBefore for command CMD-TailLogs...
[2015-07-10T10:37:20.067Z] DEBUG [25873] : Running stages of Command CMD-TailLogs from stage 0 to stage 0...
[2015-07-10T10:37:20.067Z] INFO  [25873] : Running stage 0 of command CMD-TailLogs...
[2015-07-10T10:37:20.067Z] DEBUG [25873] : Loaded 1 actions for stage 0.
[2015-07-10T10:37:20.067Z] INFO  [25873] : Running 1 of 1 actions: TailLogs...

update 3:

enter image description here

code_legend
  • 3,547
  • 15
  • 51
  • 95

2 Answers2

3

Always check your .ebextensions before committing them into Elastic Beanstalk. A resource that I use to check my files http://www.yamllint.com/

If you are trying to modify Apache config then I would suggest using 'files' in ebextensions. read more...

I believe you're trying to achieve the following:

files:          
  "/etc/httpd/conf.d/enable_mod_rewrite.conf": 
     mode: "644"
     owner: root
     group: root
     content: |
       AllowOverride All
George Rushby
  • 1,305
  • 8
  • 13
  • thank you for the clarification and edit. when uploading the new instance with your suggested command added in setup.config, the health of the instance turned to red as shown in my image update under my initial post – code_legend Jul 09 '15 at 16:11
  • check your error logs - might be something useful there. – George Rushby Jul 10 '15 at 10:04
  • thanks for your suggestion. i've updated an update 2 under my initial post. specially under /var/log/httpd/error_log nothing is written there – code_legend Jul 10 '15 at 10:42
  • in your EBStalk configuration; under Networking Tier, Load Balancing what is your EC2 Instance Health Check ? If you have one take it out and try again. – George Rushby Jul 10 '15 at 16:41
  • hi. what do mean EC2 Instance Health Check ? ive updated my initial post with the values found in ec2 health. its still red, with this config file + rewrite in htacess gives red, without this config file its green but obviously htaccess does not work – code_legend Jul 10 '15 at 18:04
  • I manage to turn it to green, but the issue I am facing is that anywhere in the website leads to ERR_CONNECTION_REFUSED. I try restarting the server but no hope – code_legend Jul 12 '15 at 01:56
  • can you log into the EC2 instance and check the Apache logs both error and access? – George Rushby Jul 21 '15 at 07:35
0

Based on George's answer, this worked for me. May help some other who ran into the same glitch:

files:
  "/etc/httpd/conf.d/enable_mod_rewrite.conf":
     mode: "644"
     owner: root
     group: root
     content: |
       <Directory /opt/python/current/app/>
       AllowOverride All
       </Directory>

This is using a django app, so you need to place the .htaccess file in the main project directory. If you place in the static folder only unauthorised users still can see/click some content after pressing cancel on the login popup.

HeyMan
  • 1,529
  • 18
  • 32