Last active
July 10, 2018 01:19
-
-
Save richardsonlima/a2553da976c0f94d9c287d4a1a8a06bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform init | |
export TF_LOG=1 | |
export SSH_FP=$(ssh-keygen -E md5 -lf ~/.ssh/id_rsa.pub | awk '{print $2}'| cut -c5-) | |
export DO_PAT={YOUR_PERSONAL_ACCESS_TOKEN} | |
terraform plan \ | |
-var "do_token=${DO_PAT}" \ | |
-var "pub_key=$HOME/.ssh/id_rsa.pub" \ | |
-var "pvt_key=$HOME/.ssh/id_rsa" \ | |
-var "ssh_fingerprint=${SSH_FP}" | |
terraform apply \ | |
-var "do_token=${DO_PAT}" \ | |
-var "pub_key=$HOME/.ssh/id_rsa.pub" \ | |
-var "pvt_key=$HOME/.ssh/id_rsa" \ | |
-var "ssh_fingerprint=${SSH_FP}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "digitalocean_droplet" "k8s-master-01" { | |
image = "ubuntu-16-04-x64" | |
name = "k8s-master-01" | |
region = "nyc3" | |
size = "1gb" | |
private_networking = true | |
ssh_keys = [ | |
"${var.ssh_fingerprint}" | |
] | |
connection { | |
user = "root" | |
type = "ssh" | |
private_key = "${file(var.pvt_key)}" | |
timeout = "2m" | |
} | |
provisioner "remote-exec" { | |
inline = [ | |
"export PATH=$PATH:/usr/bin", | |
# install nginx | |
"sudo apt-get update", | |
"sudo apt-get -y install htop glances" | |
] | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "do_token" {} | |
variable "pub_key" {} | |
variable "pvt_key" {} | |
variable "ssh_fingerprint" {} | |
provider "digitalocean" { | |
token = "${var.do_token}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment