Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial Terraform Setup + droplet #4

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions terraform/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Local .terraform directories
**/.terraform/*

# .env files
.env
*.env

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json
!terraform.template.tfvars

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc
26 changes: 26 additions & 0 deletions terraform/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions terraform/droplet.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# IEEE Main server ssh key
data "digitalocean_ssh_key" "ieee-server01" {
name = "ieee-server01"
}

resource "digitalocean_droplet" "hackathon_droplet" {
image = var.droplet_image
name = var.droplet_name
region = var.region
size = var.droplet_size
ssh_keys = [data.digitalocean_ssh_key.ieee-server01.id]
}

output "droplet_ip_address" {
value = digitalocean_droplet.hackathon_droplet.ipv4_address
}
12 changes: 12 additions & 0 deletions terraform/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
terraform {
required_providers {
digitalocean = {
source = "digitalocean/digitalocean"
version = "~> 2.0"
}
}
}

provider "digitalocean" {
token = var.do_token
}
7 changes: 7 additions & 0 deletions terraform/terraform.template.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Required
do_token = ""
droplet_name = ""

# Optional - (Remove if you want to keep default values)
region = ""
droplet_size = ""
24 changes: 24 additions & 0 deletions terraform/vars.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
variable "do_token" {
type = string
}

variable "region" {
type = string
default = "TOR1"
}

# Droplet Config Vars

variable "droplet_name" {
type = string
}

variable "droplet_size" {
type = string
default = "s-1vcpu-1gb" # Smallest Droplet
}

variable "droplet_image" {
type = string
default = "ubuntu-18-04-x64"
}