-
2015-11-10: Abandoned AWS EB.
Got
Create environment operation is complete, but with errors. For more information, see troubleshooting documentation.
.Tried to set up CloudWatch Logs but got
The following resource(s) failed to create: [AWSEBCWLHttp4xxMetricFilter, AWSEBCWLHttp5xxMetricFilter].
- Modify region name (
eu-central-1
), app name (your_app
) etc according to your requirements.
-
If your
Gemfile
includes Git sources add Git to packages since it's not included in the default EB AMI.# .ebextensions/packages.config packages: yum: git: []
-
EB doesn't automatically create and populate
config/database.yml
. Unignore and modify it (assuming you are using Figaro):# config/database.yml development: &dev adapter: postgresql host: <%= ENV["POSTGRES_HOST"] %> encoding: unicode database: <%= ENV["POSTGRES_DB"] %> pool: 5 username: <%= ENV["POSTGRES_USER"] %> password: <%= ENV["POSTGRES_PASSWORD"] %> template: template0 test: <<: *dev database: your_app_test production: <<: *dev database: your_app_production
# config/application.yml # This must be ignored and used only for local dev. We'll set these at the post-config stage # using EB CLI like: # `eb setenv POSTGRES_HOST=... POSTGRES_DB=... POSTGRES_USER=... POSTGRES_PASSWORD='...'` # or through the web interface. POSTGRES_HOST: <etc>.<etc>.eu-central-1.rds.amazonaws.com POSTGRES_DB: your_app_production POSTGRES_USER: <RDS user> POSTGRES_PASSWORD: <RDS password>
-
Create a RDS Instance
RDS > Get Started Now
- Select Engine > PostgreSQL
- Production? > Multi-AZ strongly recommended
- Specify DB Details
- DB Engine Version: Latest
- Storage Type: One of the SSD options
- Allocated Storage*: > 20 GB
- Optional Steps #1
-
Add your SSH key (EC2 > Key Pairs > Import Key Pair)
-
(Optional) Set up memory reporting
-
(Optional) set up CloudWatch Logs
-
Create New Environment > Create web server
-
Environment Type
- Predefined configuration > Ruby
- Change platform version > Select Puma
-
Additional Resources
- Don't select "Create an RDS DB Instance with this environment", since some RDS options can't be modified from here. An example is Storage Type, which defaults to magnetic and modifying it later to SSD incurs IO and CPU penalties. We'll create the RDS instance separately and enter its credentials as environment variables.
-
Configuration Details
- EC2 key pair: Select the SSH key you've uploaded at Preparation step 3.
- Email address: Enter your email address
- Root volume type: General Purpose (SSD)
-
Enter appropriate values from your
config/application.yml
of Preparation step 2 including db credentials at Web Tier > Software Configuration > Environment Properties or using EB CLI. -
Allow your EC2 instances to connect to your RDS instance:
-
VPC Console > Security Groups > Create Security Group
- Name tag:
- Group name: db
- Description: db
- VPC: Select the same VPC instance as your EC2 instances.
- Type: PostgreSQL (5432)
- Source: Select the Security Group of your EC2 instances.
-
RDS > Modify > Security Group > Select the one you've just created above.
-
-
If you want to change the collation of your db (
en_US.UTF-8
by default):-
SSH into one of your instances (
eb ssh
) -
Connect to your RDS instance:
psql -h etc.etc.eu-central-1.rds.amazonaws.com -U user -d db
-
Create a new database:
CREATE DATABASE your_app_production TEMPLATE template0 ENCODING 'UTF-8' LC_COLLATE 'tr_TR.UTF-8' LC_CTYPE 'tr_TR.UTF-8';
-
eb deploy
-
We are doing this after all other steps because modifying more than 1 instance takes a lot longer than a single instance.
Configuration > Web Tier > Scaling > Auto Scaling
- Minimum instance count: Increase to at least 2 for HA.
- Maximum instance count: Increase according to your expected traffic level (along with min. count).
@halilim
Tried to set up CloudWatch Logs but got The following resource(s) failed to create: [AWSEBCWLHttp4xxMetricFilter, AWSEBCWLHttp5xxMetricFilter].
You can resolve this by changing your policy to:I'm sure there's a much stricter policy that will do the job, but I'm no expert with this and the documentation is scarce on the topic. Hope this helped.