< Return to Video

Ruby Conf 2013 - Your Development Machine in the Cloud by Charles Wood

  • 0:16 - 0:18
    CHARLES WOOD: All right. I'm Charles Max Wood
  • 0:18 - 0:25
    and I'm gonna be talking about my dev machine
    in the cloud.
  • 0:26 - 0:28
    When was it, it was like a year and
  • 0:28 - 0:30
    a half ago, I started working for a company
  • 0:30 - 0:32
    as a- I'm, I'm a freelancer. So I was
  • 0:32 - 0:35
    contracting with a company, and they decided
    that they
  • 0:35 - 0:38
    wanted us to pair with each other even though
  • 0:38 - 0:40
    we were all remote. And so what they did
  • 0:40 - 0:45
    was they set up their development machines
    in AWS,
  • 0:45 - 0:46
    and we would all login to them and we
  • 0:46 - 0:48
    would work off of them. And I've kind of
  • 0:48 - 0:50
    adapted that, so that now when I work on
  • 0:50 - 0:53
    things, I work on it in a cloud server.
  • 0:53 - 0:55
    And so I'm just gonna explain a little bit
  • 0:55 - 0:57
    of why I like it, and then I'll do
  • 0:57 - 0:59
    a little bit of demo and show you how
  • 0:59 - 1:01
    I use it.
  • 1:01 - 1:04
    So one thing that I run into a lot
  • 1:04 - 1:07
    is why. Why would you do this, right? Why
  • 1:07 - 1:10
    would you put your development environment
    in the cloud
  • 1:10 - 1:13
    when you can get a rockin', awesome machine,
    a
  • 1:13 - 1:16
    Mac Pro or something, that has all the resources
  • 1:16 - 1:19
    you want. Why would you put it up in
  • 1:19 - 1:21
    the cloud and, and do things that way?
  • 1:21 - 1:24
    Well, one of the big things for me is
  • 1:24 - 1:26
    that I like to be able to move around.
  • 1:26 - 1:29
    I generally work from home. Sometimes that
    doesn't work
  • 1:29 - 1:31
    out. And so I need to be able to
  • 1:31 - 1:33
    go somewhere. Do something a little bit different.
    Work
  • 1:33 - 1:36
    from a coffee shop. I like being flexible
    as
  • 1:36 - 1:38
    far as which machine I use. I mean, obviously
  • 1:38 - 1:41
    I've got this 2009 white MacBook, so it's
    not
  • 1:41 - 1:45
    always the ideal machine to work off of.
  • 1:45 - 1:47
    And so it, it gives me that mobility. It
  • 1:47 - 1:50
    lets me work from anywhere. It doesn't matter
    where
  • 1:50 - 1:51
    I'm at. It doesn't matter if I've just got
  • 1:51 - 1:54
    my iPad with me. I've worked off of that
  • 1:54 - 1:57
    before. I can just, I can do things wherever
  • 1:57 - 1:59
    I want. If I'm working on somebody else's
    machine,
  • 1:59 - 2:02
    somebody else's environment, somebody else's
    network, it doesn't matter
  • 2:02 - 2:04
    because I can just get on the machine where
  • 2:04 - 2:06
    I'm at, where ever I'm at.
  • 2:06 - 2:11
    Another reason is pairing. I have a handful
    of
  • 2:11 - 2:15
    subcontractors that work for me on a regular
    basis.
  • 2:15 - 2:16
    And a lot of times it's nice to be
  • 2:16 - 2:18
    able to get in and look up the code
  • 2:18 - 2:20
    that they wrote or write some code with them,
  • 2:20 - 2:22
    and work with them and work in an environment
  • 2:22 - 2:25
    that I'm familiar with. Or work in a way
  • 2:25 - 2:29
    that allows us to just move ahead and, and
  • 2:29 - 2:31
    have things already setup so that we can do
  • 2:31 - 2:31
    pairing.
  • 2:31 - 2:33
    And so it's really nice to be able to
  • 2:33 - 2:37
    do that as well. It's really simple. It's
    pretty
  • 2:37 - 2:39
    straightforward. You don't have to install
    a whole bunch
  • 2:39 - 2:41
    of stuff to make this work. I'll talk about
  • 2:41 - 2:44
    what I'm using in a minute. But really they're
  • 2:44 - 2:47
    just a handful of critical pieces and so it's,
  • 2:47 - 2:49
    it's relatively simple to setup and it's pretty
    simple
  • 2:49 - 2:51
    to use.
  • 2:51 - 2:54
    And then the last one is cost. It costs
  • 2:54 - 2:56
    me twenty dollars a month for my development
    machine
  • 2:56 - 3:00
    in the cloud. I'm hosting it on DigitalOcean,
    which
  • 3:00 - 3:03
    means that I get two gigs of ram, forty
  • 3:03 - 3:06
    gigabytes of hard drive space, which is plenty
    for
  • 3:06 - 3:08
    my development work. And it costs me twenty
    bucks
  • 3:08 - 3:10
    a month.
  • 3:10 - 3:13
    And they actually have solid state drives,
    so it's
  • 3:13 - 3:15
    reasonably fast.
  • 3:15 - 3:17
    One other reason, like I said before, is you
  • 3:17 - 3:19
    can do it on the iPad. Now, this is
  • 3:19 - 3:24
    an iPad first generation, so it doesn't do
    Air-
  • 3:24 - 3:29
    what is it? Airplay? Airplay mirroring. But
    my iPhone's
  • 3:29 - 3:31
    an iPhone5 so it does. So let me go
  • 3:31 - 3:38
    ahead and show you this really quickly.
  • 3:38 - 3:45
    Now, I have, on my machine, a program called
  • 3:50 - 3:57
    Reflector App. Turn on mirroring. Live demos.
    I've had
  • 4:00 - 4:02
    several people tell me I'm brave for doing
    something
  • 4:02 - 4:05
    like this.
  • 4:05 - 4:12
    So you can see my phone. And the app
  • 4:14 - 4:16
    that I use on my iOS devices is called
  • 4:16 - 4:23
    prompt. So there, you can see it. So now
  • 4:23 - 4:25
    I'm logged into my system. I can hide the
  • 4:25 - 4:29
    keyboard. This is much nicer on my iPad. Can,
  • 4:29 - 4:33
    can you all not read that? I can't read
  • 4:33 - 4:38
    that.
  • 4:38 - 4:39
    I'm not sure if I can bump the font
  • 4:39 - 4:42
    size up. I can read it on my phone.
  • 4:42 - 4:47
    But anyway, so.
  • 4:47 - 4:54
    This isn't. Let's see, connect. Hang on. You've
    gotta
  • 4:56 - 5:00
    love technology, right?
  • 5:00 - 5:02
    So the only way to go, by the way,
  • 5:02 - 5:06
    is to have this bluetooth keyboard, have a
    bluetooth
  • 5:06 - 5:08
    keyboard. This case that I have for my iPad
  • 5:08 - 5:15
    cost about twenty or thirty bucks on, on Amazon.
  • 5:18 - 5:21
    So now we're back to Prompt. Boy, I wish
  • 5:21 - 5:28
    I could zoom in or something. Nope, that's
    arrow
  • 5:32 - 5:36
    keys. Anyway. So you can't read it, but it
  • 5:36 - 5:43
    works. So.
  • 5:43 - 5:45
    That's the directory I'm changing to. So now
    I'm
  • 5:45 - 5:49
    in projects. So then I can list the directories.
  • 5:49 - 5:52
    I can do whatever else I need to. And
  • 5:52 - 5:54
    it works right here on my iPhone. Now typically
  • 5:54 - 5:56
    I do this on the iPad. It's a lot
  • 5:56 - 5:58
    easier to see. But you kind of get the
  • 5:58 - 5:59
    idea that you can really do it from whatever
  • 5:59 - 6:02
    device you have, as long as it allows you
  • 6:02 - 6:06
    SSH into the other machine.
  • 6:06 - 6:13
    Now, where'd I put my remote?
  • 6:16 - 6:19
    So a lot of people ask, then, well what
  • 6:19 - 6:20
    do you use? What do you do with it?
  • 6:20 - 6:22
    So obviously the big deal is you have to
  • 6:22 - 6:25
    be able SSH into the machine. SSH is good
  • 6:25 - 6:29
    because it's encrypted, and there are some
    other things
  • 6:29 - 6:29
    that you can do to make it a little
  • 6:29 - 6:33
    bit more secure.
  • 6:33 - 6:35
    I host on DigitalOcean. I was talking to my
  • 6:35 - 6:38
    friend Evan, and he made sad faces at me
  • 6:38 - 6:39
    because he works for RackSpace. You can do
    this
  • 6:39 - 6:44
    anywhere. I just like DigitalOcean because
    it's inexpensive. I
  • 6:44 - 6:46
    use Tmux. A lot of you out there who
  • 6:46 - 6:48
    have been involved in some of the remote pairing
  • 6:48 - 6:51
    discussions out there, you probably know what
    Tmux is.
  • 6:51 - 6:53
    And I'll talk through these a little bit more.
  • 6:53 - 6:55
    I, I like Emacs. You can do this with
  • 6:55 - 6:56
    Vim. I know a lot of people who do
  • 6:56 - 6:59
    it with Vim. And Chef is what I use
  • 6:59 - 7:00
    to set it up.
  • 7:00 - 7:04
    So let's talk about SSH for a minute. I
  • 7:04 - 7:06
    just use an SSH Config. So all I have
  • 7:06 - 7:08
    to do is SSH the name of the machine
  • 7:08 - 7:11
    and then it knows which public/private key
    to use.
  • 7:11 - 7:13
    It knows what the username is. It knows what
  • 7:13 - 7:16
    the IP address is. And so, it just kind
  • 7:16 - 7:19
    of works. There's nothing else to it. It's
    kind
  • 7:19 - 7:22
    of like a shortcut for your SSH.
  • 7:22 - 7:24
    And then you can setup a public/private key
    for
  • 7:24 - 7:27
    each machine. You can set one up that you
  • 7:27 - 7:30
    just use everywhere, and however it works
    is, is
  • 7:30 - 7:33
    really up to you. So it's, it's really handy
  • 7:33 - 7:37
    that way.
  • 7:37 - 7:39
    DigitalOcean is a VPS service. So you just
    pay
  • 7:39 - 7:43
    for the virtual private server. Like I said,
    they
  • 7:43 - 7:46
    use SSH, solid-state hard drives, and I use
    the
  • 7:46 - 7:49
    two gigabyte version and that seems to work
    really
  • 7:49 - 7:50
    nicely.
  • 7:50 - 7:52
    I am looking into how to use their API
  • 7:52 - 7:55
    to just provision the server. But as it works
  • 7:55 - 7:57
    right now, I go in, I tell them I
  • 7:57 - 7:59
    want a new server. I get the email back
  • 7:59 - 8:01
    with the root password and then I login and
  • 8:01 - 8:04
    setup Chef.
  • 8:04 - 8:09
    Tmux is also really nice. Now I use Tmux
  • 8:09 - 8:12
    for a variety of reasons. The main reason
    is,
  • 8:12 - 8:16
    is that with Tmux, if you setup a session,
  • 8:16 - 8:18
    and you work in it for awhile and then
  • 8:18 - 8:20
    you have to go do something else, Tmux will
  • 8:20 - 8:22
    remember your session, so when you come back
    you
  • 8:22 - 8:24
    just join that same session and you can pick
  • 8:24 - 8:27
    up right where you left off.
  • 8:27 - 8:29
    It's also really handy for pairing, because,
    again, multiple
  • 8:29 - 8:32
    machines can connect to the same session.
    And so
  • 8:32 - 8:35
    with my subcontractors, they just login to
    the guest
  • 8:35 - 8:38
    account on my machine. They join the Tmux
    session.
  • 8:38 - 8:40
    You have to make sure you setup the permissions
  • 8:40 - 8:43
    so that they can see the socket file. And
  • 8:43 - 8:46
    then you're good to go.
  • 8:46 - 8:48
    One other thing I really like is that you
  • 8:48 - 8:49
    can set it up to split screen. You can
  • 8:49 - 8:53
    do that with Emacs as well. But I found
  • 8:53 - 8:55
    that it's a little more convenient with Tmux,
    and
  • 8:55 - 8:56
    so a lot of times I'll have my code
  • 8:56 - 8:58
    on one side and then tests on the other
  • 8:58 - 9:00
    or my code on one side and have, like,
  • 9:00 - 9:02
    Guard or something running on the other side.
  • 9:02 - 9:05
    And, and Tmux allows you to do that. And
  • 9:05 - 9:06
    the really cool thing is you can configure
    it
  • 9:06 - 9:08
    to actually start all that stuff up when you
  • 9:08 - 9:12
    get in. And, like I said, I mean it's
  • 9:12 - 9:15
    so configurable that you can setup an environment,
    you
  • 9:15 - 9:17
    can make it run, and then if you have
  • 9:17 - 9:20
    to go to the coffee shop, or you're driving
  • 9:20 - 9:23
    somewhere, going to users' group, and you
    connect from
  • 9:23 - 9:25
    there, you can just pick up that session and
  • 9:25 - 9:28
    you're right back where you left off.
  • 9:28 - 9:33
    Emacs. I'm not gonna go into all of the
  • 9:33 - 9:36
    details, Emacs versus Vim. I like them both.
    I
  • 9:36 - 9:40
    just like Emacs a little bit better. But it's,
  • 9:40 - 9:43
    it's very configurable. You can program Emacs
    lisp to
  • 9:43 - 9:46
    make it do whatever you want. It's text-based,
    which
  • 9:46 - 9:50
    is what you need for an SSH thing. And
  • 9:50 - 9:55
    you have a gazillion plugins.
  • 9:55 - 9:56
    One other thing that I've, I've been able
    to
  • 9:56 - 9:59
    work through with this, I have all my dotfiles,
  • 9:59 - 10:02
    so like your dot bash rc and all of
  • 10:02 - 10:04
    your setup stuff for all of your different
    scripts
  • 10:04 - 10:07
    and things, all of that's in GitHub. I'm looking
  • 10:07 - 10:10
    to move all this into Chef, with templates
    for
  • 10:10 - 10:12
    files, but I haven't done that yet. So for
  • 10:12 - 10:14
    right now I just do a GitPull and then
  • 10:14 - 10:16
    I have an install script that puts everything
    where
  • 10:16 - 10:18
    it goes.
  • 10:18 - 10:22
    I also setup an SSH key with Chef. It's
  • 10:22 - 10:23
    just part of the setup. It generates a new
  • 10:23 - 10:26
    key. And that way, each machine has its own
  • 10:26 - 10:27
    key and I can just disable it when I
  • 10:27 - 10:30
    need to.
  • 10:30 - 10:34
    Deployments are real nice with GitHub, or
    working with
  • 10:34 - 10:37
    GitHub, because all of that stuff is running
    out
  • 10:37 - 10:39
    there instead of on my local machine. So if
  • 10:39 - 10:41
    I'm in any kind of a position where I
  • 10:41 - 10:45
    have bandwidth constraints, like, for example,
    if I'm running
  • 10:45 - 10:47
    off of the wifi on my phone, then it's
  • 10:47 - 10:50
    not that much of an issue, because it pulls
  • 10:50 - 10:52
    it all down, it connects to the other machine.
  • 10:52 - 10:54
    All of that stuff happens off of the, the
  • 10:54 - 10:59
    network at the data center that I'm running
    from.
  • 10:59 - 11:02
    And I put RVM on here. I didn't mean
  • 11:02 - 11:07
    to. That should have been on Chef.
  • 11:07 - 11:11
    So Chef is really nice for provisioning the
    machine.
  • 11:11 - 11:12
    All you really have to do, once you have
  • 11:12 - 11:15
    your Chef Recipe setup, which there's a little
    bit
  • 11:15 - 11:18
    of a learning curve to Chef, but it's not
  • 11:18 - 11:21
    terrible. But now that I have all of the
  • 11:21 - 11:22
    recipes and things, I have a role for a
  • 11:22 - 11:26
    development machine. And so that role lists
    all of
  • 11:26 - 11:28
    the recipes and all the cookbooks that you
    need
  • 11:28 - 11:31
    in order to setup a machine like this, and
  • 11:31 - 11:32
    it's so, then all I have to do is
  • 11:32 - 11:34
    Bootstrap the machine and then go onto the
    machine
  • 11:34 - 11:38
    run Chef client, and it installs Ruby, it
    installs
  • 11:38 - 11:43
    RVM, it installs Tmux, it installs Emacs.
  • 11:43 - 11:45
    And I'm pretty much good to go. It sets
  • 11:45 - 11:47
    up my user and generates that SSH, or the,
  • 11:47 - 11:51
    yeah, the SSH key for GitHub. So I do
  • 11:51 - 11:53
    have to copy that and send it to GitHub.
  • 11:53 - 11:55
    But the rest of that's all done. It takes
  • 11:55 - 11:57
    about five minutes for it to provision a new
  • 11:57 - 12:00
    machine for me. And so if anything ever happens,
  • 12:00 - 12:02
    you know, heaven forbid my machine gets compromised
    or
  • 12:02 - 12:05
    something like that, then I can just shut
    it
  • 12:05 - 12:08
    down, turn off the key. I don't have to
  • 12:08 - 12:11
    worry about anybody getting into my GitHub
    account. And
  • 12:11 - 12:16
    I have a new machine in like five minutes.
  • 12:16 - 12:19
    So let's talk about security for a minute.
    This
  • 12:19 - 12:22
    is something I get asked a lot. You have
  • 12:22 - 12:24
    your machine in the cloud. What if you get
  • 12:24 - 12:28
    hacked? For the most part, I learned my lesson.
  • 12:28 - 12:30
    I used to host things on the same machine
  • 12:30 - 12:32
    I was doing development on. That's generally
    not a
  • 12:32 - 12:35
    good idea. Mainly because it provides a target
    for
  • 12:35 - 12:40
    people to hit, and it's your development environment
    as
  • 12:40 - 12:40
    well.
  • 12:40 - 12:42
    So since I have it setup to deploy client
  • 12:42 - 12:45
    apps and things like that, it's not really
    ideal.
  • 12:45 - 12:48
    So now it's its own machine, and the only
  • 12:48 - 12:53
    thing that's consistently running is the SSH
    server. As
  • 12:53 - 12:55
    far as outside access goes.
  • 12:55 - 12:58
    And then if I need to run a Rails
  • 12:58 - 12:59
    server or something like that, then I can
    just
  • 12:59 - 13:03
    fire it up and I'm good to go.
  • 13:03 - 13:06
    So some of the security measures that I take.
  • 13:06 - 13:11
    I generally turn, turn on public/private authentication
    only, once
  • 13:11 - 13:13
    I get it setup. So I typically have to
  • 13:13 - 13:17
    login once with that root password that DigitalOcean
    sends
  • 13:17 - 13:22
    me. And then after that I just turn that
  • 13:22 - 13:24
    off so that you can't login with a password.
  • 13:24 - 13:26
    The reason is that because a lot of the
  • 13:26 - 13:28
    scripts out there will just try passwords
    and try
  • 13:28 - 13:30
    and get into your system, and so even if
  • 13:30 - 13:32
    they guess the right password that way, they
    still
  • 13:32 - 13:36
    can't get in.
  • 13:36 - 13:37
    Another thing that I do is I turn off
  • 13:37 - 13:41
    the root SSH access, which is obviously turned
    on
  • 13:41 - 13:45
    by default by DigitalOcean. And you don't
    want people
  • 13:45 - 13:48
    hacking your root account. And they'll come,
    they'll hit
  • 13:48 - 13:51
    port twenty-two, root is the user name, and
    then
  • 13:51 - 13:53
    they'll just go for it.
  • 13:53 - 13:55
    And so anybody who can pull a script off
  • 13:55 - 13:56
    the internet can do that, so you just turn
  • 13:56 - 13:59
    it off and then that way they have to
  • 13:59 - 14:01
    get into your account and then figure out
    what
  • 14:01 - 14:03
    your sudo password is.
  • 14:03 - 14:05
    So it's just another layer of indirection.
  • 14:05 - 14:08
    Setup a firewall. Again, the only thing that
    I
  • 14:08 - 14:11
    really run, that I, that I need access to
  • 14:11 - 14:16
    from outside is typically SSH. Sometimes database.
    But there
  • 14:16 - 14:18
    are Chef recipes for that, if you want to
  • 14:18 - 14:22
    turn those ports back on, or if you, you
  • 14:22 - 14:24
    know, if all you're gonna do is SSH then
  • 14:24 - 14:26
    you can turn that on. And then, you know,
  • 14:26 - 14:28
    you just, I just open up a block of
  • 14:28 - 14:31
    ports around 3000 so that I can turn on
  • 14:31 - 14:32
    Rails server and get to it from my, my
  • 14:32 - 14:35
    machine.
  • 14:35 - 14:37
    One other thing I didn't put up here is
  • 14:37 - 14:40
    that I usually change the SSH port to something
  • 14:40 - 14:43
    other than twenty-two. And again, those folks,
    they pull
  • 14:43 - 14:45
    out the script and they're just trying to
    blast
  • 14:45 - 14:49
    any servers in a vlan that they can find.
  • 14:49 - 14:51
    So you turn that off and then that can't
  • 14:51 - 14:52
    get to it.
  • 14:52 - 14:59
    I also use a tunneling service called ProXPN,
    and
  • 15:00 - 15:03
    they are really, really awesome. And you can
    pay
  • 15:03 - 15:05
    for different levels of access. But then essentially
    what
  • 15:05 - 15:07
    it does is it sets up a tunnel from
  • 15:07 - 15:13
    your machine to their machines, and it just,
    it
  • 15:13 - 15:16
    just works out well that way.
  • 15:16 - 15:18
    And finally I, I setup sudo, and I make
  • 15:18 - 15:22
    that work. So I just realized for the camera
  • 15:22 - 15:24
    people, I forgot to hit play on this thing.
  • 15:24 - 15:29
    Is that a problem? OK.
  • 15:29 - 15:31
    So I use sudo to control all the access
  • 15:31 - 15:34
    there.
  • 15:34 - 15:36
    Other than that, it just works. One thing
    that's
  • 15:36 - 15:39
    nice about this setup is that I have a
  • 15:39 - 15:41
    standing desk and a sitting, a place that
    I
  • 15:41 - 15:43
    sit in my office. And so when I switch
  • 15:43 - 15:45
    between the two I can just move seamlessly
    between
  • 15:45 - 15:50
    the two. I can make things work. And yeah.
  • 15:50 - 15:52
    So.
  • 15:52 - 15:54
    So it's worked out really well for me, and
  • 15:54 - 15:58
    I really like the flexibility that it offers.
    And
  • 15:58 - 16:00
    I just realized that I blew through a, what
  • 16:00 - 16:02
    I rehearsed to be a forty minute talk in
  • 16:02 - 16:03
    ten minutes.
  • 16:03 - 16:09
    Well, I feel bad, cause this went way faster
  • 16:09 - 16:15
    than I thought it would. But. Yeah, the pics
  • 16:15 - 16:18
    are right there.
  • 16:18 - 16:25
    All right. So anyway. Well, thanks for coming.
    If
  • 16:25 - 16:30
    you want Ruby Rogue stickers, come find me.
    And
  • 16:30 - 16:32
    if you have any questions, come talk to me
  • 16:32 - 16:35
    afterward as well. And yeah. Thanks for coming
    out
  • 16:35 - 16:35
    to RubyConf.
Title:
Ruby Conf 2013 - Your Development Machine in the Cloud by Charles Wood
Description:

more » « less
Duration:
17:03

English subtitles

Revisions