github.com/mohanarpit/terraform@v0.6.16-0.20160909104007-291f29853544/builtin/providers/cobbler/acceptance_env/main.tf (about)

     1  # This will spin up an instance and install cobbler onto it so we can run
     2  
     3  # the Terraform acceptance tests against it.
     4  
     5  module "ami" {
     6    source        = "github.com/terraform-community-modules/tf_aws_ubuntu_ami/ebs"
     7    region        = "us-west-2"
     8    distribution  = "trusty"
     9    instance_type = "t2.nano"
    10  }
    11  
    12  module "vpc" {
    13    source = "github.com/terraform-community-modules/tf_aws_vpc"
    14  
    15    name            = "cobbler"
    16    cidr            = "10.0.0.0/16"
    17    private_subnets = "10.0.1.0/24"
    18    public_subnets  = "10.0.101.0/24"
    19    azs             = "us-west-2a"
    20  }
    21  
    22  resource "aws_key_pair" "cobbler" {
    23    key_name   = "tf-cobbler-acctests"
    24    public_key = "${file("~/.ssh/id_rsa.pub")}"
    25  }
    26  
    27  resource "aws_security_group" "cobbler" {
    28    vpc_id = "${module.vpc.vpc_id}"
    29  
    30    ingress {
    31      protocol    = "tcp"
    32      from_port   = 22
    33      to_port     = 22
    34      cidr_blocks = ["0.0.0.0/0"]
    35    }
    36  
    37    egress {
    38      protocol    = "-1"
    39      from_port   = 0
    40      to_port     = 0
    41      cidr_blocks = ["0.0.0.0/0"]
    42    }
    43  }
    44  
    45  resource "aws_instance" "cobbler" {
    46    instance_type          = "t2.medium"
    47    ami                    = "${module.ami.ami_id}"
    48    subnet_id              = "${module.vpc.public_subnets}"
    49    key_name               = "${aws_key_pair.cobbler.id}"
    50    vpc_security_group_ids = ["${aws_security_group.cobbler.id}"]
    51  
    52    root_block_device {
    53      volume_type = "gp2"
    54      volume_size = 40
    55    }
    56  
    57    connection {
    58      user = "ubuntu"
    59    }
    60  
    61    provisioner "remote-exec" {
    62      inline = <<-WAIT
    63  while [ ! -f /var/lib/cloud/instance/boot-finished ]; do echo 'Waiting for cloud-init...'; sleep 1; done
    64      WAIT
    65    }
    66  
    67    provisioner "remote-exec" {
    68      script = "${path.module}/deploy.sh"
    69    }
    70  }
    71  
    72  output "ssh" {
    73    value = "ubuntu@${aws_instance.cobbler.public_ip}"
    74  }