Deploy Ruby on Rails 5 to AWS Elastic Beanstalk - ruby-on-rails

I'm attempting to deploy a Ruby on Rails application to AWS Elastic Beanstalk using the aws cli and the elasticbeanstalk cli installed via homebrew.
I've created my application in Elastic Beanstalk via the eb init command and then using the following command to attempt to build my production environment
eb create production -db -db.engine postgres
This command succeeds in building some of the resources required, but fails on the second security group it tries to build, the one which is required for the RDS instance (postgresql). The output from the failure is as follows:
Printing Status:
INFO: createEnvironment is starting.
INFO: Using elasticbeanstalk-us-east-1-060304732879 as Amazon S3 storage bucket for environment data.
INFO: Created security group named: sg-6df63b27
INFO: Created load balancer named: awseb-e-v-AWSEBLoa-SNYOVF7XI1O
INFO: Created security group named: awseb-e-vfpiydbe4p-stack-AWSEBSecurityGroup-7CUYEFRLYW20
INFO: Created Auto Scaling launch configuration named: awseb-e-vfpiydbe4p-stack-AWSEBAutoScalingLaunchConfiguration-PBAKQ91A7F1C
ERROR: Stack named 'awseb-e-vfpiydbe4p-stack' aborted operation. Current state: 'CREATE_FAILED' Reason: The following resource(s) failed to create: [AWSEBRDSDBSecurityGroup].
ERROR: Creating RDS database security group named: awseb-e-vfpiydbe4p-stack-awsebrdsdbsecuritygroup-1er5fh5espelw failed Reason: Either the resource does not exist, or you do not have the required permissions.
INFO: Launched environment: production. However, there were issues during launch. See event log for details.
Has anyone else encountered this issue? I've double checked (and also reset) my AWS credentials and ensured that the one and only use I have set up in my IAM console is set to AdministratorAccess and I'm using the AWS Access and Secret Key set up for that user.
Any assistance would be greatly appreciated!

Related

Elastic Beanstalk Environment for multi-container docker fails to be created due to LaunchWaitCondition

I'm gonna set up sample elasticbeanstalk environment for multi-container docker.
But it is not created due to error.
environment tier: web-server
other configuration info: https://i.stack.imgur.com/gKwBn.png
I want to create sample elasticbeanstalk environment for multi-container docker.
But the actual is not created.
Here is the error statement.
WARN Environment health has transitioned from Pending to Severe.
Initialization in progress (running for 15 minutes). None of the instances are sending data.
ERROR Stack named 'awseb-e-at4dw9xg2u-stack' aborted operation.
Current state: 'CREATE_FAILED' Reason: The following resource(s) failed to create: [AWSEBInstanceLaunchWaitCondition].
ERROR LaunchWaitCondition failed.
The expected number of EC2 instances were not initialized within the given time.
Rebuild the environment. If this persists, contact support.
This issue is solved by allowing inbound & outbound traffic for default ACL network.
inbound
outbound

Want to deploy my app to my domain, what to do when after eb deploy is successful?

Pardon me if my question sounds stupid, but I've been cracking my brain on this for quite a while, obviously its my first time deploying and i'm a beginner.
I've followed this tutorial (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_rails.html) to deploy my rails app to elastic beanstalk. Everything is successful, eb deploy is successful, eb open opens my application in the terminal(w3m) too.
BUT what am I suppose to do next? I mean
Am i suppose to do anything with the 'upload and deploy' button on Elastic Beanstalk Console? Currently its at Sample Application.
I've tried aws elasticbeanstalk create-application-version --application-name my-application --version-label v2 --source-bundle S3Bucket=(bucket name),S3Key=(zip file)
but in return I get A client error (InvalidParameterCombination) occurred when calling the CreateApplicationVersion operation: Unable to download from S3 location (Bucket: name of bucket Key: name of zip file). Reason: Moved Permanently
What am I suppose to do at the hosted zones at Route 53? I put type: CNAME and value as the url in elastic beanstalk console, and obviously going to my domain says 'Congratulations Your first AWS Elastic Beanstalk Ruby Application is now running on your own dedicated environment in the AWS Cloud' since 'upload and deploy' is at sample application.
OR is my thought process all wrong? Hope someone can enlighten me and tell me what to do. I just need to deploy my web app to my own domain. Thanks in advance.
I don't know if this is useful, the message after eb deploy:
Creating application version archive "(name of app)".
Uploading (name of app).zip to S3. This may take a while.
Upload Complete.
INFO: Environment update is starting.
INFO: Deploying new version to instance(s).
INFO: Environment health has transitioned from Ok to Info. Command is executing on all instances.
INFO: New application version was deployed to running EC2 instances.
INFO: Environment update completed successfully.
Okay, I feel dumb.
I just have to type eb status --verbose into the terminal, copy and paste the CNAME given into Route 53 hosted zone.

Invalid AMI option for Elastic Beanstalk

I am trying to setup a Rails server on AWS using Elastic Beanstalk. I am following the guide here. I managed to configure the EB CLI, and I am at the part where I am trying to deploy the app to an EB environment. However, I am getting an error that the AMI option I provided is inval
[rails-beanstalk$] eb create first-beanstalk-env -sr aws-beanstalk-service-role
WARNING: You have uncommitted changes.
Creating application version archive "app-8bc6-160112_090122".
Uploading rails-beanstalk/app-8bc6-160112_090122.zip to S3. This may take a while.
Upload Complete.
ERROR: Configuration validation exception: Invalid option value: 'ami- 48eb8128' (Namespace: 'aws:autoscaling:launchconfiguration', OptionName: 'ImageId'): No EC2 ImageId found with id: 'ami-48eb8128'
I don't remember ever setting an AMI (or what that even is), so I am very confused as to why I'm getting this error.
Not sure what's up with that error, but I find the EB CLI quite fragile. Try to take a different approach and create the environment via the aws web console and not via the cli.
Once this is ready, use eb init to setup beanstalk for your local project and then eb deploy <env-name> to push your project to the newly created env.
If the error persists, try to change the deployment zone. AWS sometimes have local bugs in some regions.
EDIT: this seems to be an issue with AWS. I tried it myself and it fails with the default setup in all aws zones.
EDIT 2: this is now confirmed with amazon:
Unfortunately we are experiencing an issue on our side related to
Beanstalk and the default Ruby AMI in different regions. We are
already investigating the issue and we plan to fix this as soon as
possible. I will update you through this support case once we will get
any update from the Elastic Beasntalk service team.
'ami- 48eb8128'
This has a space in it and is not a valid AMI ID

Authentication failed for user when deploying to Amazon EC2

I am trying to run cap production deploy under my project folder using Capistrano 3. I am able to ssh into my production server using the pem as login credential. But when I run cap production deploy, I get the following message:
cap aborted!
SSHKit::Runner::ExecuteError: Exception while executing on host cityspade.com: Authentication failed for user ec2-user#cityspade.com
The EC2 server has already allowed my IP for SSH connecting. No idea how to fix this issue.
Capistrano uses your default available keys to login. You might need to set up ssh-agent and add the pem to the available keys.

Ruby on Rails deployment on Amazon ElasticBeanstalk:Signature Expired Error

This is the first time I am deploying my application to Amazon EC2 using Beanstalk .
I am following this guide.
Click (http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/create_deploy_Ruby_rails.html)
After filling all the info after eb init.
At the step
Select a solution stack.
It is throwing me the same error everytime
$ SignatureDoesNotMatch. Signature expired: 20141211T092422Z is now earlier than 20141212T091944Z (20141212T092444Z - 5 min.)
I am entering the access key and secret as provided by Amazon security credentials.
How can I deploy my application? Any tutorials/articles where I can find some other way around?
Found the solution,It was happening because of server clock and my local machine time was not synchronized.
It can be done by installing ntp tools on your machine.
Article followed
http://www.cyberciti.biz/faq/howto-install-ntp-to-synchronize-server-clock/

Resources