If there are any issues, you can go to your EB environment on the AWS web panel, click on “Logs,” and choose “Request Logs -> Last 100 Lines” to see the logs. You might want to wait a few minutes before doing this because Elastic Beanstalk does some stuff in the background after updating environment variables.Īfter these steps, your Rails app “should” be running. It is called “Endpoint.”Īfter this, commit your Rails app directory again, and run eb deploy. RDS_HOSTNAME: Go to “Services -> RDS,” and you can find this information under the “Connect” section of your database instance information page.RDS_PASSWORD: Password you picked when setting up your database.RDS_USERNAME: Username you picked when setting up your database.RDS_DB_NAME: Database name you picked when setting up your database.Under “Environment properties,” add the following key-value pairs:.We told Rails to get the information for the production database using the above environment variables, but now we need to make sure that our Elastic Beanstalk environment includes these variables: production : username : password : host : port : Adding relevant environment variables to Elastic Beanstalk Now, in your Rails directory, open config/database.yml. Setting up the production database configuration It should be right above the “Inbound” tab, and should look like sg-*. Click on “Add Rule.” For “Type,” choose “PostgreSQL,” and for “Source” type in the ID of the security group that you are adding this rule to.Go to the “Inbound” tab, and click on “Edit.”.Choose the security group from the previous section.Click on “Security Groups” on the left panel.In the meantime, let’s add Postgres access to your security group: Click on “Create database,” this will take a while.Pick a database name, such as my_app_production.Select “Choose existing VPC security groups,” and select the security group that looks like “…-AWSEBSecurityGroup-…” On the “Configure advanced settings” section, the important thing is the security groups.Choose a username and password, keep these handy for now, click “Next.”.Choose an instance identifier, this is sort of a “namespace.”.You can start with a db.t2.micro instance, no multi-AZ deployment and a general purpose SSD. Settle with something that is within your budget. Here, you can try different options, and see what the estimated monthly costs are.Select your use case, “Production” or “Dev/Test,” and click “Next.”.So, we will set up the database separate from our Elastic Beanstalk environment. Click on the “Apply” button at the bottom of the page.Įlastic Beanstalk provides an easy way to set up a database, which you can reach through “Configuration -> Database.” I prefer not to use that because if you need to rebuild your Elastic Beanstalk environment, your database will be deleted.You can find this file in the “config” directory of your Rails app. Under “Environment properties,” add a new key named RAILS_MASTER_KEY, and set its value to the content of your “master.key” file.Open the “Configuration” tab, and click “Modify” under the box titled “Software.”.Go to AWS, choose “Services -> Elastic Beanstalk,” then click on your environment.You can use the CLI for this purpose as well, but I prefer using the web panel for this. So far so good, now we need to set a few things before our app actually starts working.
0 Comments
Leave a Reply. |