github.com/jrasell/terraform@v0.6.17-0.20160523115548-2652f5232949/examples/aws-eip/main.tf (about) 1 # Specify the provider and access details 2 provider "aws" { 3 region = "${var.aws_region}" 4 } 5 6 resource "aws_eip" "default" { 7 instance = "${aws_instance.web.id}" 8 vpc = true 9 } 10 11 # Our default security group to access 12 # the instances over SSH and HTTP 13 resource "aws_security_group" "default" { 14 name = "eip_example" 15 description = "Used in the terraform" 16 17 # SSH access from anywhere 18 ingress { 19 from_port = 22 20 to_port = 22 21 protocol = "tcp" 22 cidr_blocks = ["0.0.0.0/0"] 23 } 24 25 # HTTP access from anywhere 26 ingress { 27 from_port = 80 28 to_port = 80 29 protocol = "tcp" 30 cidr_blocks = ["0.0.0.0/0"] 31 } 32 33 # outbound internet access 34 egress { 35 from_port = 0 36 to_port = 0 37 protocol = "-1" 38 cidr_blocks = ["0.0.0.0/0"] 39 } 40 } 41 42 43 resource "aws_instance" "web" { 44 instance_type = "t2.micro" 45 46 # Lookup the correct AMI based on the region 47 # we specified 48 ami = "${lookup(var.aws_amis, var.aws_region)}" 49 50 # The name of our SSH keypair you've created and downloaded 51 # from the AWS console. 52 # 53 # https://console.aws.amazon.com/ec2/v2/home?region=us-west-2#KeyPairs: 54 # 55 key_name = "${var.key_name}" 56 57 # Our Security group to allow HTTP and SSH access 58 security_groups = ["${aws_security_group.default.name}"] 59 60 # We run a remote provisioner on the instance after creating it. 61 # In this case, we just install nginx and start it. By default, 62 # this should be on port 80 63 user_data = "${file("userdata.sh")}" 64 #Instance tags 65 tags { 66 Name = "eip-example" 67 } 68 }