Coder Social home page Coder Social logo

terraform-digitalocean-docker's Introduction

Terraform Setup DigitalOcean Droplet With Docker

Introduction & Goals

I wanted to run a Dockerized script cheaply on the cloud, and DigitalOcean seemed like a good way to go about that. As an infrastructure geek, I wanted to be able to setup, modify and tear down the infra with Terraform, my favorite IaC tool. After going through the documentation and working through its steps manually from DigitalOcean and Hashicorp, I translated those steps to Terraform.

Technologies Used

  • Terraform
  • Cloud-config

Architecture Diagram (if any) / Infrastructure

  • DigitalOcean droplet with accompanying SSH key running Docker

How It Works (High-Level)

  • Terraform creates and is used to manage a DO Droplet with an accompanying SSH key.

Pre-reqs

  • Terraform installed

How To Use

  • Clone this repo
  • Generate an SSH key named tf-digitalocean"(or change the keyname in the TF): ssh-keygen -t rsa -C "your-email-here" -f ./tf-digitalocean
  • Insert the public SSH key (tf-digitalocean.pub) into ssh_authorized_keys in cloud-init-data.yaml

TO DOs

  • Install Docker with Ansible
  • Update to Ubuntu 20.04
  • Automate the SSH key generation fully
  • Add a proper firewall and other security improvements.
  • Add accompanying VPC at same point.

Lessons Learned / Observations

  • This was my first time working with TF and DO, I found it pretty streamlined like the rest of working with DO.
  • Became more familiar with cloud-init, which was the most crunchy part of the process -- seemed hard to debug between the log files either being too verbose or not verbose enough. I'd rather use Ansible or even a TF provisioner, maybe Packer or the like for a custom image.
  • Realized the cloud-init docs for cloud-config are pretty uninformative.
  • Didn't use the CLI for DO, going to try and use it moving forward, but very little needed to be done in the UI at all.
  • Learned some best practices for setting up DO servers by going through the docs.

References

https://developer.hashicorp.com/terraform/tutorials/applications/digitalocean-provider https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup https://www.digitalocean.com/community/tutorials/initial-server-setup-with-ubuntu-22-04

terraform-digitalocean-docker's People

Contributors

emilyburak avatar

Stargazers

Alex Mills avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.