STEP 1 - Launch an EC2 instance of the desired configuration. You can learn to launch EC2 here.
STEP 2 - After successful completion of Step 1, install LEMP stack and PHP libraries, so Drupal works smoothly.
STEP 3 - Next, download the latest stable release of Drupal and place it in the server directory.
STEP 4 - Configure virtual host and other nginx settings and then hit your website from the browser.
Before moving further, make sure you are able to access your Drupal installation.
Since you have set up the codebase on an EC2 server, you now need to prepare RDS instance to store the database on your website.
STEP 5 - Launch an RDS instance with the desired configuration. Official documentation to launch an RDS instance can be found here. Make sure that RDS instance and EC2 instances are in the same virtual private cloud or at least same geographical proximity for an ideal performance. In case they are not, your application will suffer from high latency.
STEP 6 - In case you have to do minor changes in MySQL configuration, make sure it works effectively with your Drupal installation. Points you will have to focus on, are memory limits, timeouts, and query cache. All these can be configured by parameters group of RDS.
STEP 7 - You can access your domain / IP for RDS instance, database name and password from your AWS dashboard. Now go back to your Drupal installation and input the RDS configuration in database settings.
In case you are facing an error connecting to the database, check your credentials. Also, try accessing RDS from your local environment to make sure that it has started properly.
STEP 8 - Once your Drupal site is running with the current setup, you can replace file system with your S3 bucket. S3 bucket is an inexpensive alternative for file storage by AWS.
STEP 9 - To use S3 bucket with Drupal 8, follow these instructions.
While creating a field choose S3 as default storage for the file. Now when you will add node all the files added through that field will be stored in S3 bucket.
B. Replace your entire public file system with S3.
Edit your settings.php and then add the following configuration.
Now all the Drupal resources i.e Images, aggregated CSS and JS etc will be served from S3 bucket instead of the web server.
In case you face some trouble related to CSS and JS files path, ‘README’ file for the module is the solution to all those issues.
The following steps are to help you migrate your existing website to AWS:
STEP 1 - Git clone your code repository or use SFTP to transfer your code files to EC2 server.
STEP 2 - Import database into RDS and change credentials in a settings.php file.
STEP 3 - Set up the S3 bucket and then run Drush command (drush s3fs-copy-local ) to copy all the files from current files folder to S3 bucket.