Skip to content

Instantly share code, notes, and snippets.

@vtno
Created May 19, 2017 08:44
Show Gist options
  • Save vtno/6199cf9598e34adf97d2d790a16dfba8 to your computer and use it in GitHub Desktop.
Save vtno/6199cf9598e34adf97d2d790a16dfba8 to your computer and use it in GitHub Desktop.
AWS-workshop instruction

AWS Workshop

Instructions

VPC

  1. Select pin on top of the page and drag VPC, EDS, ElasticCache and EC2 to it.
  2. Create VPC in Your VPC menu
  3. Create Subnet
  4. Create Gateway
  5. Associate subnet with gateway
  6. Associate routing table with subnets
  7. Create security group for each instance (VPC, EDS, etc.)
  8. Setup inbound rules for each group

RDS (db)

  1. Create subnet group for RDS
  2. Create DB instance
    • On the last step select the RDS security group
    • Select No on monitoring

ElastiCache (redis)

  1. Create subnet group
  2. Redis Setting
    • config your custom port

EC2

  1. Add keypair to EC2
# Create key pair on your machine

$ ssh-keygen -C workshop-YOUR_NAME -f ~/.ssh/workshop-YOUR_NAME
$ ssh-keygen -C workshop-YOUR_NAME-deployer -f ~/.ssh/workshop-YOUR_NAME-deployer
  1. Launch EC2 instance
  • Choose subnet
  1. Add Elastic IP (remember it!)
  • 13.113.140.115
  1. Create a load balancer
  2. Configure ELB target

SSH config

  1. Add hostname to ssh
Host workshop.YOUR_NAME.app1 XXX.XXX.XXX.XXX
  HostName XXX.XXX.XXX.XXX
  IdentityFile ~/.ssh/workshop-YOUR_NAME
  1. Connect to the db through ssh
$ ssh [email protected]_NAME.app1
$ ssh -Cfo ExitOnForwardFailure=yes -NL 5433:POSTGRES_HOSTNAME:5432 [email protected]_NAME.app1

# Try accesing the db on RDS
$ psql -v -d oozou -h localhost -p 5433 - U oozou

Note: Capistrano for deployment and Ansible for config environment 3. Config -> config/deployer/integration.rb with your host name and stuffs 4. Run EDITOR=vi ansible-vault edit devops/hosts/integration/group_vars/all to open the config file 5. Get elastic load balancer hostname 6. Change the configuration. Use your own hostname 7. Use ansible to install env on host

# Run playbook
$ ansible-playbook -i devops/hosts/integration/hosts --ask-vault-pass devops/playbooks/app_server_setup.yml
  1. Try ssh [email protected]_NAME.app1 (app instance host name)
  2. Deploy! bundle exec cap cap integration deploy
  • You need to install correct Ruby version and install Bundle gem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment