Last active
June 11, 2017 23:27
-
-
Save kintoandar/583a209474e05bbc0cd6738bf909a9a1 to your computer and use it in GitHub Desktop.
terraform_ebs_volume_attach_example.tf
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 "aws_instance" "box" { | |
| ami = "ami-1234568" | |
| instance_type = "t2.micro" | |
| key_name = "mykey" | |
| subnet_id = "subnet-12345678" | |
| user_data = "${data.template_file.template.rendered}" | |
| vpc_security_group_ids = ["sg-12345678"] | |
| associate_public_ip_address = true | |
| root_block_device { | |
| volume_size = 8 | |
| volume_type = "gp2" | |
| } | |
| } | |
| resource "aws_ebs_volume" "data_volume" { | |
| availability_zone = "eu-central-1a" | |
| size = 10 | |
| type = "gp2" | |
| # If defined a snapshot will be used | |
| snapshot_id = "" | |
| } | |
| resource "aws_volume_attachment" "attach_volume" { | |
| device_name = "/dev/xvdb" | |
| volume_id = "${aws_ebs_volume.data_volume.id}" | |
| instance_id = "${aws_instance.box.id}" | |
| } | |
| data "template_file" "template" { | |
| template = "init.tpl" | |
| vars { | |
| hostname = "toast01" | |
| domain = "bakery.inet" | |
| prometheus_enabled = true | |
| prometheus_data_dir = "/var/lib/prometheus" | |
| prometheus_volume = "/dev/xvdb" | |
| prometheus_volume_label = "DATA" | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment