Last active
October 14, 2015 15:28
-
-
Save carlessanagustin/1ab8d5d57617d2f41857 to your computer and use it in GitHub Desktop.
HashiCorp Terraform AWS and DOCKER up-n-running
This file contains 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
############ AWS ############ | |
provider "aws" { | |
access_key = "${var.access_key}" | |
secret_key = "${var.secret_key}" | |
# access_key = "lalalalalalalalalala" | |
# secret_key = "lalalalalalalalalala" | |
region = "us-east-1" | |
} | |
resource "aws_instance" "example1" { | |
ami = "ami-d05e75b8" | |
instance_type = "t2.micro" | |
subnet_id = "subnet-XXXXX" | |
security_groups = ["sg-XXXXX"] | |
private_ip = "10.0.0.10" | |
tags { | |
Name = "example1" | |
Description = "Ubuntu Server 14.04 LTS (HVM), SSD Volume Type" | |
SO = "Ubuntu" | |
Usage = "testing" | |
Unit = "1" | |
} | |
} | |
output "example1_ip" { | |
value = "${aws_instance.example1.public_ip}" | |
} | |
# to retrieve output information... | |
# $ terraform output example1_ip | |
############ DOCKER ############ | |
# example command... | |
# $ docker run | |
# --name some-nginx | |
# -v /vagrant:/usr/share/nginx/html:ro | |
# -p 8080:80 | |
# -d nginx | |
resource "docker_image" "nginx" { | |
name = "nginx:latest" | |
} | |
resource "docker_container" "example4" { | |
image = "${docker_image.nginx.latest}" | |
name = "example4" | |
hostname = "some-nginx" | |
volumes { | |
container_path = "/usr/share/nginx/html" | |
host_path = "/vagrant" | |
read_only = "true" | |
} | |
ports { | |
internal = 80 | |
external = 8080 | |
} | |
} |
This file contains 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 "access_key" { | |
default = "lalalalalalalalalala" | |
} | |
variable "secret_key" { | |
default = "lalalalalalalalalala" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
About Docker server/client...
opcion 1
$ service docker stop
$ docker -H tcp://127.0.0.1:2375 -d &
opcion 2
$ vim /etc/default/docker
add DOCKER_OPTS="-H tcp://127.0.0.1:2375"
$ service docker restart
view
$ docker -H tcp://127.0.0.1:2375 ps -a
Providers documentation: https://www.terraform.io/docs/providers/