Skip to content

Latest commit

 

History

History
60 lines (58 loc) · 2.76 KB

File metadata and controls

60 lines (58 loc) · 2.76 KB
  1. Create an account at aws.amazon.com
  2. Generate an ssh key (instructions here). Go up to step 4 where you do pbcopy
  3. You should have your public key in your clipboard
  4. In AWS go to "EC2 ->Network & Security->Key Pairs"
  5. Import Key Pair (name could be "My Mac"). Paste in the public key and click "import"
  6. Go back to AWS dasboard and click on "OpsWorks"
  7. Click on "Add Stack"
  8. Name: Your Application
  9. Default SSH Key: Select the key you created
  10. Click "Add Stack"
  11. Click on "Add a layer"
  12. Select Node.js as layer type and click "Add Layer"
  13. Under Navigation, click "Instances" and click "Add an instance"
  14. Under "Size" select "t2.micro" (smallest server)
  15. Add Instance
  16. Click "Start" to start up your instance
  17. Under Navigation, click "Apps" and click "Add an App"
  18. Name: Name of your app
  19. Repository URL: from github code repo copy the SSH clone URL on the right (ex: git@github.com:nycitt/codementor-example.git)
  20. Go to "Settings" in Github repo and click "Deploy keys"
  21. Follow same steps as here BUT when it asks "Enter file in which to save the key" name your key "yourapplication" with No Passphrase
  22. Copy the public key that's generated into the "Key" field in Github
  23. Name it "Amazon" and click "Add Key"
  24. Go back to AWS and copy the private key into the Repository SSH key field
  25. Fill in environmental variables by looking at the config file. Convert everything to Uppercase 1. camelCase -> CAMEL_CASE 2. nested object becomes PARENT_CHILD
    {
      parse: {
        masterKey: ''
      }
    }
    
    Environment Variable: PARSE_MASTER_KEY
    
  26. Click "Add App"
  27. Click "Deploy" and "Deploy again"
  28. You will be able to access your app by going to Navigation->Instances and looking for the public ip of your server
  29. If you need to debug do ssh ec2-user@IP-ADDRESS and it should automatically log in using your private key. All files are located in /srv/www/<name of app>/current

Setting Up Auto Deploy on Push

  1. In Github repo go to "settings"
  2. Go to "Webhooks & Services"
  3. Add Service -> OpsWorks
  4. Fill in info
  5. In AWS go to "IAM"
  6. Go to "Users"
  7. Create new user
  8. Name it "aws"
  9. Create Create
  10. Show User Security Credentials
  11. Copy security credentials to the GitHub page
  12. Close and click on user.
  13. Go to "Permissions"
  14. Click "attach policy
  15. Filter for "ops" and attach the 1st policy
  16. AppId: In opsworks, click on your app, and it's going to be the "OpsWorks ID" 13: Stack ID: In OpsWorks selet "Stack" from navigation, go to "Stack Settings". It's going to be the OpsWorks Id
  17. branch name: master