# AWS Configuration Cheat Sheet
###### tags: `AWS`
## Create EC2 IAM Role
1. Go to AWS Management Console
2. Search for IAM and click the IAM Service.
3. Click Roles under Access Management in the left sidebar.
4. Click the Create role button.
5. Select AWS Service under Trusted entity type. Then select EC2 under common use cases.
6. Search for AWSElasticBeanstalk and select both the AWSElasticBeanstalkWorkerTier and AWSElasticBeanstalkMulticontainerDocker policies. Click the Next button.
7. Give the role the name of aws-elasticbeanstalk-ec2-role
8. Click the Create role button.
---
## Create Elastic Beanstalk Environment
1. Go to AWS Management Console
2. Search for Elastic Beanstalk and click the Elastic Beanstalk service.
3. If you've never used Elastic Beanstalk before you will see a splash page. Click the Create Application button. If you have created Elastic Beanstalk environments and applications before, you will be taken directly to the Elastic Beanstalk dashboard. In this case, click the Create environment button. There is now a flow of 6 steps that you will be taken through.
5. You will need to provide an Application name, which will auto-populate an Environment Name.
6. Scroll down to find the Platform section. You will need to select the Platform of Docker. This will auto-populate the rest of the fields.
7. Scroll down to the Presets section and make sure that free tier eligible has been selected:
8. Click the Next button to move to Step #2.
9. You will be taken to a Service Access configuration form.
If you are presented with a blank form where the Existing Service Roles field is empty, then, you should select Create and use new service role. You will need to set the EC2 instance profile to the aws-elasticbeanstalk-ec2-role created earlier (this may be auto-populated for you).
If both Existing Service Roles and EC2 Instance Profiles are populated with default values, then, select Use an existing service role.
10. Click the Skip to Review button as Steps 3-6 are not applicable.
11. Click the Submit button and wait for your new Elastic Beanstalk application and environment to be created and launch.
12. Click the link below the checkmark under Domain. This should open the application in your browser and display a Congratulations message.
---
## Update Object Ownership of S3 Bucket
1. Go to AWS Management Console
2. Search for S3 and click the S3 service.
3. Find and click the elasticbeanstalk bucket that was automatically created with your environment.
4. Click Permissions menu tab
5. Find Object Ownership and click Edit
6. Change from ACLs disabled to ACLs enabled. Change Bucket owner Preferred to Object Writer. Check the box acknowledging the warning.
7. Click Save changes.
---
## Add AWS configuration details to .travis.yml file's deploy script
1. Set the region. The region code can be found by clicking the region in the toolbar next to your username.
eg: 'us-east-1'
2. app should be set to the Application Name (Step #4 in the Initial Setup above)
eg: 'docker'
3. env should be set to the lower case of your Beanstalk Environment name.
eg: 'docker-env'
4. Set the bucket_name. This can be found by searching for the S3 Storage service. Click the link for the elasticbeanstalk bucket that matches your region code and copy the name.
eg: 'elasticbeanstalk-us-east-1-923445599289'
5. Set the bucket_path to 'docker'
6. Set access_key_id to $AWS_ACCESS_KEY
7. Set secret_access_key to $AWS_SECRET_KEY
---
## Create an IAM User
1. Search for the "IAM Security, Identity & Compliance Service"
2. Click "Create Individual IAM Users" and click "Manage Users"
3. Click "Add User"
4. Enter any name you’d like in the "User Name" field.
eg: docker-react-travis-ci
5. Click "Next"
6. Click "Attach Policies Directly"
7. Search for "beanstalk"
8. Tick the box next to "AdministratorAccess-AWSElasticBeanstalk"
9. Click "Next"
10. Click "Create user"
11. Select the IAM user that was just created from the list of users
12. Click "Security Credentials"
13. Scroll down to find "Access Keys"
14. Click "Create access key"
15. Select "Command Line Interface (CLI)"
16. Scroll down and tick the "I understand..." check box and click "Next"
Copy and/or download the Access Key ID and Secret Access Key to use in the Travis Variable Setup.
---
## Travis Variable Setup
1. Go to your Travis Dashboard and find the project repository for the application we are working on.
2. On the repository page, click "More Options" and then "Settings"
3. Create an AWS_ACCESS_KEY variable and paste your IAM access key from step #13 above.
4. Create an AWS_SECRET_KEY variable and paste your IAM secret key from step #13 above.
## Deploying App
1. Make a small change to your src/App.js file in the greeting text.
2. In the project root, in your terminal run:
git add.
git commit -m “testing deployment"
git push origin main
3. Go to your Travis Dashboard and check the status of your build.
4. The status should eventually return with a green checkmark and show "build passing"
5. Go to your AWS Elastic Beanstalk application
6. It should say "Elastic Beanstalk is updating your environment"
7. It should eventually show a green checkmark under "Health". You will now be able to access your application at the external URL provided under the environment name.