|
| 1 | +# aws-lambda-r - Configure AWS for production deployment |
| 2 | + |
| 3 | +**Note: the detailed instructions are not complete.** If you are familiar with AWS, |
| 4 | +please review the files in `scripts/` and `settings/`. |
| 5 | + |
| 6 | +These are instructions to be followed before running the scripts. At the end of |
| 7 | +these instruction you should have obtained the values for the following keys: |
| 8 | + |
| 9 | +``` |
| 10 | +IAM_ACCESS_KEY_ID="" |
| 11 | +IAM_SECRET_ACCESS_KEY="" |
| 12 | +IAM_LAMBDA_FUNCTION_ROLE="" |
| 13 | +EC2_KEY_NAME="" |
| 14 | +EC2_KEY_FILE="" |
| 15 | +EC2_SECURITY_GROUP_IDS="" |
| 16 | +EC2_SUBNET_ID="" |
| 17 | +S3_BUCKET="" |
| 18 | +API_ID="" |
| 19 | +API_RESOURCE_ID="" |
| 20 | +API_ALIAS_RESOURCE_ID="" |
| 21 | +API_AUTHORIZER_ID="" |
| 22 | +API_TOKEN="" |
| 23 | +``` |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | + |
| 28 | +## IAM |
| 29 | + |
| 30 | +IAM manages access to AWS. |
| 31 | + |
| 32 | +1. Create an IAM user account to be used only in conjunction with this app |
| 33 | + + retain the values of **ACCESS_KEY_ID** and **SECRET_ACCESS_KEY** |
| 34 | +2. Give necessary permissions to this user |
| 35 | + + [TBD: more automation --> more permissions] |
| 36 | +3. Create roles and policies |
| 37 | + + attach policies to the roles |
| 38 | + |
| 39 | + |
| 40 | +## SSH Key |
| 41 | + |
| 42 | +SSH Keys allows access through an SSH tunnel to a remove / cloud AWS EC2 instance. |
| 43 | + |
| 44 | +### Create and save SSH key for EC2 connection |
| 45 | + |
| 46 | +1. Log in to AWS Console. |
| 47 | +2. Go to EC2 Service |
| 48 | +3. Select **Key Pairs** under **NETWORK & SECURITY** menu. |
| 49 | + |
| 50 | + |
| 51 | + |
| 52 | +4. Press "Create Key Pair" button and give it a name. When you press the |
| 53 | +"Create" button, the browser will start downloading the key automatically. |
| 54 | + |
| 55 | + |
| 56 | + |
| 57 | +5. Open the folder containing downloaded key (a `.pem` file having the same name as the created key) |
| 58 | + |
| 59 | +6. Copy the `.pem` file to: |
| 60 | + - on Windows: `C:\Users\<your_user_Name>/.ssh/` folder |
| 61 | + + in order to show hidden folders go to Folder Menu > View > Check "Hidden items" |
| 62 | + - on OSX and Linux: `~/.ssh/` Additional commands might be necessary from terminal: |
| 63 | + + `chmod 700 ~/.ssh` |
| 64 | + + `chmod 400 ~/.ssh/<your_key_file>.pem` |
| 65 | + + other instructions: [1](https://unix.stackexchange.com/a/115860) and |
| 66 | + [2](http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AccessingInstancesLinux.html) |
| 67 | + |
| 68 | + |
| 69 | +## VPC [automate ?] |
| 70 | + |
| 71 | +1. Create dedicate VPC |
| 72 | +2. Create subnet |
| 73 | +3. Create security group |
| 74 | + |
| 75 | + |
| 76 | +## LAMBDA [automate ?] |
| 77 | + |
| 78 | +1. Create Lambda Authorizer function |
| 79 | + |
| 80 | + |
| 81 | +## S3 BUCKET [automate ?] |
| 82 | + |
| 83 | +1. Create S3 bucket |
| 84 | + |
| 85 | + |
| 86 | +## API GATEWAY |
| 87 | + |
| 88 | +1. Create API |
| 89 | +2. Create resources |
| 90 | +3. Create authorizer |
| 91 | +4. Create stages |
| 92 | +5. Attach role for CloudWatch logging to API |
| 93 | +6. Enable CloudWatch Logging on stages |
| 94 | + |
| 95 | + |
| 96 | +## TERMINATE UNUSED INSTANCES |
| 97 | + |
| 98 | +1. Go to AWS web console and select Frankfurt / eu-central-1 region |
| 99 | +2. To to EC2 > Instances |
| 100 | +3. Select all running instance > Actions button > Instance State > Terminate |
| 101 | + |
| 102 | +## Create Custom Settings file |
| 103 | + |
| 104 | +[steps needed to create "secrets_user.sh" and "setup_user_secrets.sh" files] |
0 commit comments