Fmt all the config files

Signed-off-by: Valentin Pichard <valentin.pichard@corp.ovh.com>
This commit is contained in:
Valentin Pichard 2016-09-22 11:49:09 +00:00
parent 196955c93c
commit c6beaa7ce8
43 changed files with 582 additions and 533 deletions

View File

@ -8,6 +8,7 @@ resource "aws_elb" "web-elb" {
# The same availability zone as our instances # The same availability zone as our instances
availability_zones = ["${split(",", var.availability_zones)}"] availability_zones = ["${split(",", var.availability_zones)}"]
listener { listener {
instance_port = 80 instance_port = 80
instance_protocol = "http" instance_protocol = "http"
@ -22,7 +23,6 @@ resource "aws_elb" "web-elb" {
target = "HTTP:80/" target = "HTTP:80/"
interval = 30 interval = 30
} }
} }
resource "aws_autoscaling_group" "web-asg" { resource "aws_autoscaling_group" "web-asg" {
@ -34,6 +34,7 @@ resource "aws_autoscaling_group" "web-asg" {
force_delete = true force_delete = true
launch_configuration = "${aws_launch_configuration.web-lc.name}" launch_configuration = "${aws_launch_configuration.web-lc.name}"
load_balancers = ["${aws_elb.web-elb.name}"] load_balancers = ["${aws_elb.web-elb.name}"]
#vpc_zone_identifier = ["${split(",", var.availability_zones)}"] #vpc_zone_identifier = ["${split(",", var.availability_zones)}"]
tag { tag {
key = "Name" key = "Name"
@ -46,6 +47,7 @@ resource "aws_launch_configuration" "web-lc" {
name = "terraform-example-lc" name = "terraform-example-lc"
image_id = "${lookup(var.aws_amis, var.aws_region)}" image_id = "${lookup(var.aws_amis, var.aws_region)}"
instance_type = "${var.instance_type}" instance_type = "${var.instance_type}"
# Security group # Security group
security_groups = ["${aws_security_group.default.id}"] security_groups = ["${aws_security_group.default.id}"]
user_data = "${file("userdata.sh")}" user_data = "${file("userdata.sh")}"

View File

@ -1,12 +1,15 @@
output "security_group" { output "security_group" {
value = "${aws_security_group.default.id}" value = "${aws_security_group.default.id}"
} }
output "launch_configuration" { output "launch_configuration" {
value = "${aws_launch_configuration.web-lc.id}" value = "${aws_launch_configuration.web-lc.id}"
} }
output "asg_name" { output "asg_name" {
value = "${aws_autoscaling_group.web-asg.id}" value = "${aws_autoscaling_group.web-asg.id}"
} }
output "elb_name" { output "elb_name" {
value = "${aws_elb.web-elb.dns_name}" value = "${aws_elb.web-elb.dns_name}"
} }

View File

@ -39,4 +39,3 @@ variable "asg_desired" {
description = "Desired numbers of servers in ASG" description = "Desired numbers of servers in ASG"
default = "1" default = "1"
} }

View File

@ -4,6 +4,7 @@ provider "aws" {
resource "aws_cloudwatch_event_rule" "foo" { resource "aws_cloudwatch_event_rule" "foo" {
name = "${var.rule_name}" name = "${var.rule_name}"
event_pattern = <<PATTERN event_pattern = <<PATTERN
{ {
"detail-type": [ "detail-type": [
@ -16,11 +17,13 @@ resource "aws_cloudwatch_event_rule" "foo" {
} }
} }
PATTERN PATTERN
role_arn = "${aws_iam_role.role.arn}" role_arn = "${aws_iam_role.role.arn}"
} }
resource "aws_iam_role" "role" { resource "aws_iam_role" "role" {
name = "${var.iam_role_name}" name = "${var.iam_role_name}"
assume_role_policy = <<POLICY assume_role_policy = <<POLICY
{ {
"Version": "2012-10-17", "Version": "2012-10-17",
@ -41,6 +44,7 @@ POLICY
resource "aws_iam_role_policy" "policy" { resource "aws_iam_role_policy" "policy" {
name = "tf-example-policy" name = "tf-example-policy"
role = "${aws_iam_role.role.id}" role = "${aws_iam_role.role.id}"
policy = <<POLICY policy = <<POLICY
{ {
"Version": "2012-10-17", "Version": "2012-10-17",

View File

@ -4,6 +4,7 @@ provider "aws" {
resource "aws_cloudwatch_event_rule" "foo" { resource "aws_cloudwatch_event_rule" "foo" {
name = "${var.rule_name}" name = "${var.rule_name}"
event_pattern = <<PATTERN event_pattern = <<PATTERN
{ {
"detail-type": [ "detail-type": [

View File

@ -20,7 +20,6 @@ resource "aws_elb" "web" {
instances = ["${aws_instance.web.*.id}"] instances = ["${aws_instance.web.*.id}"]
} }
resource "aws_instance" "web" { resource "aws_instance" "web" {
instance_type = "m1.small" instance_type = "m1.small"
ami = "${lookup(var.aws_amis, var.aws_region)}" ami = "${lookup(var.aws_amis, var.aws_region)}"

View File

@ -26,6 +26,7 @@ resource "aws_internet_gateway" "gw" {
resource "aws_route_table" "r" { resource "aws_route_table" "r" {
vpc_id = "${aws_vpc.main.id}" vpc_id = "${aws_vpc.main.id}"
route { route {
cidr_block = "0.0.0.0/0" cidr_block = "0.0.0.0/0"
gateway_id = "${aws_internet_gateway.gw.id}" gateway_id = "${aws_internet_gateway.gw.id}"
@ -51,6 +52,7 @@ resource "aws_autoscaling_group" "app" {
data "template_file" "cloud_config" { data "template_file" "cloud_config" {
template = "${file("${path.module}/cloud-config.yml")}" template = "${file("${path.module}/cloud-config.yml")}"
vars { vars {
aws_region = "${var.aws_region}" aws_region = "${var.aws_region}"
ecs_cluster_name = "${aws_ecs_cluster.main.name}" ecs_cluster_name = "${aws_ecs_cluster.main.name}"
@ -62,31 +64,37 @@ data "template_file" "cloud_config" {
data "aws_ami" "stable_coreos" { data "aws_ami" "stable_coreos" {
most_recent = true most_recent = true
filter { filter {
name = "description" name = "description"
values = ["CoreOS stable *"] values = ["CoreOS stable *"]
} }
filter { filter {
name = "architecture" name = "architecture"
values = ["x86_64"] values = ["x86_64"]
} }
filter { filter {
name = "virtualization-type" name = "virtualization-type"
values = ["hvm"] values = ["hvm"]
} }
owners = ["595879546273"] # CoreOS owners = ["595879546273"] # CoreOS
} }
resource "aws_launch_configuration" "app" { resource "aws_launch_configuration" "app" {
security_groups = [ security_groups = [
"${aws_security_group.instance_sg.id}" "${aws_security_group.instance_sg.id}",
] ]
key_name = "${var.key_name}" key_name = "${var.key_name}"
image_id = "${data.aws_ami.stable_coreos.id}" image_id = "${data.aws_ami.stable_coreos.id}"
instance_type = "${var.instance_type}" instance_type = "${var.instance_type}"
iam_instance_profile = "${aws_iam_instance_profile.app.name}" iam_instance_profile = "${aws_iam_instance_profile.app.name}"
user_data = "${data.template_file.cloud_config.rendered}" user_data = "${data.template_file.cloud_config.rendered}"
associate_public_ip_address = true associate_public_ip_address = true
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true
} }
@ -111,8 +119,9 @@ resource "aws_security_group" "lb_sg" {
from_port = 0 from_port = 0
to_port = 0 to_port = 0
protocol = "-1" protocol = "-1"
cidr_blocks = [ cidr_blocks = [
"0.0.0.0/0" "0.0.0.0/0",
] ]
} }
} }
@ -126,18 +135,22 @@ resource "aws_security_group" "instance_sg" {
protocol = "tcp" protocol = "tcp"
from_port = 22 from_port = 22
to_port = 22 to_port = 22
cidr_blocks = [ cidr_blocks = [
"${var.admin_cidr_ingress}" "${var.admin_cidr_ingress}",
] ]
} }
ingress { ingress {
protocol = "tcp" protocol = "tcp"
from_port = 8080 from_port = 8080
to_port = 8080 to_port = 8080
security_groups = [ security_groups = [
"${aws_security_group.lb_sg.id}" "${aws_security_group.lb_sg.id}",
] ]
} }
egress { egress {
from_port = 0 from_port = 0
to_port = 0 to_port = 0
@ -146,7 +159,6 @@ resource "aws_security_group" "instance_sg" {
} }
} }
## ECS ## ECS
resource "aws_ecs_cluster" "main" { resource "aws_ecs_cluster" "main" {
@ -155,6 +167,7 @@ resource "aws_ecs_cluster" "main" {
data "template_file" "task_definition" { data "template_file" "task_definition" {
template = "${file("${path.module}/task-definition.json")}" template = "${file("${path.module}/task-definition.json")}"
vars { vars {
image_url = "ghost:latest" image_url = "ghost:latest"
container_name = "ghost" container_name = "ghost"
@ -183,15 +196,15 @@ resource "aws_ecs_service" "test" {
depends_on = [ depends_on = [
"aws_iam_role_policy.ecs_service", "aws_iam_role_policy.ecs_service",
"aws_alb_listener.front_end" "aws_alb_listener.front_end",
] ]
} }
## IAM ## IAM
resource "aws_iam_role" "ecs_service" { resource "aws_iam_role" "ecs_service" {
name = "tf_example_ecs_role" name = "tf_example_ecs_role"
assume_role_policy = <<EOF assume_role_policy = <<EOF
{ {
"Version": "2008-10-17", "Version": "2008-10-17",
@ -212,6 +225,7 @@ EOF
resource "aws_iam_role_policy" "ecs_service" { resource "aws_iam_role_policy" "ecs_service" {
name = "tf_example_ecs_policy" name = "tf_example_ecs_policy"
role = "${aws_iam_role.ecs_service.name}" role = "${aws_iam_role.ecs_service.name}"
policy = <<EOF policy = <<EOF
{ {
"Version": "2012-10-17", "Version": "2012-10-17",
@ -240,6 +254,7 @@ resource "aws_iam_instance_profile" "app" {
resource "aws_iam_role" "app_instance" { resource "aws_iam_role" "app_instance" {
name = "tf-ecs-example-instance-role" name = "tf-ecs-example-instance-role"
assume_role_policy = <<EOF assume_role_policy = <<EOF
{ {
"Version": "2012-10-17", "Version": "2012-10-17",
@ -259,6 +274,7 @@ EOF
data "template_file" "instance_profile" { data "template_file" "instance_profile" {
template = "${file("${path.module}/instance-profile-policy.json")}" template = "${file("${path.module}/instance-profile-policy.json")}"
vars { vars {
app_log_group_arn = "${aws_cloudwatch_log_group.app.arn}" app_log_group_arn = "${aws_cloudwatch_log_group.app.arn}"
ecs_log_group_arn = "${aws_cloudwatch_log_group.ecs.arn}" ecs_log_group_arn = "${aws_cloudwatch_log_group.ecs.arn}"

View File

@ -39,7 +39,6 @@ resource "aws_security_group" "default" {
} }
} }
resource "aws_instance" "web" { resource "aws_instance" "web" {
instance_type = "t2.micro" instance_type = "t2.micro"
@ -61,6 +60,7 @@ resource "aws_instance" "web" {
# In this case, we just install nginx and start it. By default, # In this case, we just install nginx and start it. By default,
# this should be on port 80 # this should be on port 80
user_data = "${file("userdata.sh")}" user_data = "${file("userdata.sh")}"
#Instance tags #Instance tags
tags { tags {
Name = "eip-example" Name = "eip-example"

View File

@ -1,6 +1,7 @@
output "address" { output "address" {
value = "${aws_instance.web.private_ip}" value = "${aws_instance.web.private_ip}"
} }
output "elastic ip" { output "elastic ip" {
value = "${aws_eip.default.public_ip}" value = "${aws_eip.default.public_ip}"
} }

View File

@ -14,4 +14,3 @@ variable "aws_amis" {
variable "key_name" { variable "key_name" {
description = "Name of the SSH keypair to use in AWS." description = "Name of the SSH keypair to use in AWS."
} }

View File

@ -63,6 +63,7 @@ resource "aws_elb" "web" {
# The same availability zone as our instance # The same availability zone as our instance
availability_zones = ["${aws_instance.web.availability_zone}"] availability_zones = ["${aws_instance.web.availability_zone}"]
security_groups = ["${aws_security_group.elb.id}"] security_groups = ["${aws_security_group.elb.id}"]
listener { listener {
instance_port = 80 instance_port = 80
instance_protocol = "http" instance_protocol = "http"
@ -85,7 +86,6 @@ resource "aws_elb" "web" {
idle_timeout = 400 idle_timeout = 400
connection_draining = true connection_draining = true
connection_draining_timeout = 400 connection_draining_timeout = 400
} }
resource "aws_lb_cookie_stickiness_policy" "default" { resource "aws_lb_cookie_stickiness_policy" "default" {
@ -96,7 +96,6 @@ resource "aws_lb_cookie_stickiness_policy" "default" {
} }
resource "aws_instance" "web" { resource "aws_instance" "web" {
instance_type = "t2.micro" instance_type = "t2.micro"
# Lookup the correct AMI based on the region # Lookup the correct AMI based on the region
@ -114,6 +113,7 @@ resource "aws_instance" "web" {
security_groups = ["${aws_security_group.default.name}"] security_groups = ["${aws_security_group.default.name}"]
user_data = "${file("userdata.sh")}" user_data = "${file("userdata.sh")}"
#Instance tags #Instance tags
tags { tags {
Name = "elb-example" Name = "elb-example"

View File

@ -14,4 +14,3 @@ variable "aws_amis" {
"us-west-2" = "ami-7f675e4f" "us-west-2" = "ami-7f675e4f"
} }
} }

View File

@ -1,10 +1,11 @@
output "subnet_group" { output "subnet_group" {
value = "${aws_db_subnet_group.default.name}" value = "${aws_db_subnet_group.default.name}"
} }
output "db_instance_id" { output "db_instance_id" {
value = "${aws_db_instance.default.id}" value = "${aws_db_instance.default.id}"
} }
output "db_instance_address" { output "db_instance_address" {
value = "${aws_db_instance.default.address}" value = "${aws_db_instance.default.address}"
} }

View File

@ -7,4 +7,3 @@ variable "sg_name" {
default = "rds_sg" default = "rds_sg"
description = "Tag Name for sg" description = "Tag Name for sg"
} }

View File

@ -21,4 +21,3 @@ variable "az_2" {
variable "vpc_id" { variable "vpc_id" {
description = "Your VPC ID" description = "Your VPC ID"
} }

View File

@ -15,6 +15,7 @@ variable "engine" {
variable "engine_version" { variable "engine_version" {
description = "Engine version" description = "Engine version"
default = { default = {
mysql = "5.6.22" mysql = "5.6.22"
postgres = "9.4.1" postgres = "9.4.1"

View File

@ -11,6 +11,7 @@ resource "aws_s3_bucket" "prod" {
bucket = "${var.bucket_name}" bucket = "${var.bucket_name}"
acl = "private" acl = "private"
policy = <<POLICY policy = <<POLICY
{ {
"Version": "2012-10-17", "Version": "2012-10-17",

View File

@ -1,8 +1,11 @@
variable "prod_access_key" {} variable "prod_access_key" {}
variable "prod_secret_key" {} variable "prod_secret_key" {}
variable "test_account_id" {} variable "test_account_id" {}
variable "test_access_key" {} variable "test_access_key" {}
variable "test_secret_key" {} variable "test_secret_key" {}
variable "bucket_name" {} variable "bucket_name" {}

View File

@ -82,7 +82,6 @@ resource "aws_security_group" "default" {
} }
} }
resource "aws_elb" "web" { resource "aws_elb" "web" {
name = "terraform-example-elb" name = "terraform-example-elb"
@ -96,7 +95,6 @@ resource "aws_elb" "web" {
lb_port = 80 lb_port = 80
lb_protocol = "http" lb_protocol = "http"
} }
} }
resource "aws_key_pair" "auth" { resource "aws_key_pair" "auth" {
@ -138,7 +136,7 @@ resource "aws_instance" "web" {
inline = [ inline = [
"sudo apt-get -y update", "sudo apt-get -y update",
"sudo apt-get -y install nginx", "sudo apt-get -y install nginx",
"sudo service nginx start" "sudo service nginx start",
] ]
} }
} }

View File

@ -23,14 +23,14 @@ resource "clc_server" "node" {
cpu = 2 cpu = 2
memory_mb = 2048 memory_mb = 2048
password = "Green123$" password = "Green123$"
additional_disks
{ additional_disks {
path = "/var" path = "/var"
size_gb = 100 size_gb = 100
type = "partitioned" type = "partitioned"
} }
additional_disks
{ additional_disks {
size_gb = 10 size_gb = 10
type = "raw" type = "raw"
} }
@ -41,35 +41,35 @@ resource "clc_server" "node" {
resource "clc_public_ip" "backdoor" { resource "clc_public_ip" "backdoor" {
server_id = "${clc_server.node.0.id}" server_id = "${clc_server.node.0.id}"
internal_ip_address = "${clc_server.node.0.private_ip_address}" internal_ip_address = "${clc_server.node.0.private_ip_address}"
ports
{ ports {
protocol = "ICMP" protocol = "ICMP"
port = -1 port = -1
} }
ports
{ ports {
protocol = "TCP" protocol = "TCP"
port = 22 port = 22
} }
source_restrictions
{ cidr = "173.60.0.0/16" }
source_restrictions {
cidr = "173.60.0.0/16"
}
# ssh in and start a simple http server on :8080 # ssh in and start a simple http server on :8080
provisioner "remote-exec" { provisioner "remote-exec" {
inline = [ inline = [
"cd /tmp; python -mSimpleHTTPServer > /dev/null 2>&1 &" "cd /tmp; python -mSimpleHTTPServer > /dev/null 2>&1 &",
] ]
connection { connection {
host = "${clc_public_ip.backdoor.id}" host = "${clc_public_ip.backdoor.id}"
user = "root" user = "root"
password = "${clc_server.node.password}" password = "${clc_server.node.password}"
} }
} }
} }
# -------------------- # --------------------
# Provision a load balancer # Provision a load balancer
resource "clc_load_balancer" "frontdoor" { resource "clc_load_balancer" "frontdoor" {
@ -87,8 +87,8 @@ resource "clc_load_balancer_pool" "pool" {
method = "roundRobin" method = "roundRobin"
persistence = "standard" persistence = "standard"
port = 80 port = 80
nodes
{ nodes {
status = "enabled" status = "enabled"
ipAddress = "${clc_server.node.private_ip_address}" ipAddress = "${clc_server.node.private_ip_address}"
privatePort = 8000 privatePort = 8000

View File

@ -1,6 +1,7 @@
variable "clc_username" { variable "clc_username" {
default = "<username>" default = "<username>"
} }
variable "clc_password" { variable "clc_password" {
default = "<password>" default = "<password>"
} }

View File

@ -34,6 +34,7 @@ resource "consul_keys" "test" {
value = "${aws_instance.test.id}" value = "${aws_instance.test.id}"
delete = true delete = true
} }
key { key {
name = "address" name = "address"
path = "tf_test/public_dns" path = "tf_test/public_dns"

View File

@ -19,8 +19,9 @@ resource "digitalocean_droplet" "mywebserver" {
inline = [ inline = [
"export PATH=$PATH:/usr/bin", "export PATH=$PATH:/usr/bin",
"sudo apt-get update", "sudo apt-get update",
"sudo apt-get -y install nginx" "sudo apt-get -y install nginx",
] ]
connection { connection {
type = "ssh" type = "ssh"
key_file = "file(${HOME}/.ssh/id_rsa)" key_file = "file(${HOME}/.ssh/id_rsa)"

View File

@ -1,6 +1,9 @@
# #### # ####
# Current Availiable Datacenter Regions # Current Availiable Datacenter Regions
# As of 05-07-2016 # As of 05-07-2016
# #
variable "do_ams2" { variable "do_ams2" {

View File

@ -105,9 +105,11 @@ resource "google_compute_vpn_tunnel" "tunnel1" {
peer_ip = "${google_compute_address.vpn_static_ip2.address}" peer_ip = "${google_compute_address.vpn_static_ip2.address}"
shared_secret = "a secret message" shared_secret = "a secret message"
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway1.self_link}" target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway1.self_link}"
depends_on = ["google_compute_forwarding_rule.fr1_udp500", depends_on = ["google_compute_forwarding_rule.fr1_udp500",
"google_compute_forwarding_rule.fr1_udp4500", "google_compute_forwarding_rule.fr1_udp4500",
"google_compute_forwarding_rule.fr1_esp"] "google_compute_forwarding_rule.fr1_esp",
]
} }
resource "google_compute_vpn_tunnel" "tunnel2" { resource "google_compute_vpn_tunnel" "tunnel2" {
@ -116,9 +118,11 @@ resource "google_compute_vpn_tunnel" "tunnel2" {
peer_ip = "${google_compute_address.vpn_static_ip1.address}" peer_ip = "${google_compute_address.vpn_static_ip1.address}"
shared_secret = "a secret message" shared_secret = "a secret message"
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway2.self_link}" target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway2.self_link}"
depends_on = ["google_compute_forwarding_rule.fr2_udp500", depends_on = ["google_compute_forwarding_rule.fr2_udp500",
"google_compute_forwarding_rule.fr2_udp4500", "google_compute_forwarding_rule.fr2_udp4500",
"google_compute_forwarding_rule.fr2_esp"] "google_compute_forwarding_rule.fr2_esp",
]
} }
# Each route tells the associated network to send all traffic in the dest_range # Each route tells the associated network to send all traffic in the dest_range
@ -145,12 +149,15 @@ resource "google_compute_firewall" "network1-allow-network1" {
name = "network1-allow-network1" name = "network1-allow-network1"
network = "${google_compute_network.network1.name}" network = "${google_compute_network.network1.name}"
source_ranges = ["${google_compute_network.network1.ipv4_range}"] source_ranges = ["${google_compute_network.network1.ipv4_range}"]
allow { allow {
protocol = "tcp" protocol = "tcp"
} }
allow { allow {
protocol = "udp" protocol = "udp"
} }
allow { allow {
protocol = "icmp" protocol = "icmp"
} }
@ -160,12 +167,15 @@ resource "google_compute_firewall" "network1-allow-network2" {
name = "network1-allow-network2" name = "network1-allow-network2"
network = "${google_compute_network.network1.name}" network = "${google_compute_network.network1.name}"
source_ranges = ["${google_compute_network.network2.ipv4_range}"] source_ranges = ["${google_compute_network.network2.ipv4_range}"]
allow { allow {
protocol = "tcp" protocol = "tcp"
} }
allow { allow {
protocol = "udp" protocol = "udp"
} }
allow { allow {
protocol = "icmp" protocol = "icmp"
} }

View File

@ -41,6 +41,7 @@ resource "google_compute_instance" "www" {
network_interface { network_interface {
network = "default" network = "default"
access_config { access_config {
# Ephemeral # Ephemeral
} }
@ -53,6 +54,7 @@ resource "google_compute_instance" "www" {
provisioner "file" { provisioner "file" {
source = "${var.install_script_src_path}" source = "${var.install_script_src_path}"
destination = "${var.install_script_dest_path}" destination = "${var.install_script_dest_path}"
connection { connection {
type = "ssh" type = "ssh"
user = "root" user = "root"
@ -68,9 +70,10 @@ resource "google_compute_instance" "www" {
private_key = "${file("${var.private_key_path}")}" private_key = "${file("${var.private_key_path}")}"
agent = false agent = false
} }
inline = [ inline = [
"chmod +x ${var.install_script_dest_path}", "chmod +x ${var.install_script_dest_path}",
"sudo ${var.install_script_dest_path} ${count.index}" "sudo ${var.install_script_dest_path} ${count.index}",
] ]
} }

View File

@ -30,18 +30,21 @@ resource "openstack_networking_router_interface_v2" "terraform" {
resource "openstack_compute_secgroup_v2" "terraform" { resource "openstack_compute_secgroup_v2" "terraform" {
name = "terraform" name = "terraform"
description = "Security group for the Terraform example instances" description = "Security group for the Terraform example instances"
rule { rule {
from_port = 22 from_port = 22
to_port = 22 to_port = 22
ip_protocol = "tcp" ip_protocol = "tcp"
cidr = "0.0.0.0/0" cidr = "0.0.0.0/0"
} }
rule { rule {
from_port = 80 from_port = 80
to_port = 80 to_port = 80
ip_protocol = "tcp" ip_protocol = "tcp"
cidr = "0.0.0.0/0" cidr = "0.0.0.0/0"
} }
rule { rule {
from_port = -1 from_port = -1
to_port = -1 to_port = -1
@ -62,18 +65,21 @@ resource "openstack_compute_instance_v2" "terraform" {
key_pair = "${openstack_compute_keypair_v2.terraform.name}" key_pair = "${openstack_compute_keypair_v2.terraform.name}"
security_groups = ["${openstack_compute_secgroup_v2.terraform.name}"] security_groups = ["${openstack_compute_secgroup_v2.terraform.name}"]
floating_ip = "${openstack_compute_floatingip_v2.terraform.address}" floating_ip = "${openstack_compute_floatingip_v2.terraform.address}"
network { network {
uuid = "${openstack_networking_network_v2.terraform.id}" uuid = "${openstack_networking_network_v2.terraform.id}"
} }
provisioner "remote-exec" { provisioner "remote-exec" {
connection { connection {
user = "${var.ssh_user_name}" user = "${var.ssh_user_name}"
key_file = "${var.ssh_key_file}" key_file = "${var.ssh_key_file}"
} }
inline = [ inline = [
"sudo apt-get -y update", "sudo apt-get -y update",
"sudo apt-get -y install nginx", "sudo apt-get -y install nginx",
"sudo service nginx start" "sudo service nginx start",
] ]
} }
} }

View File

@ -14,8 +14,7 @@ variable "ssh_user_name" {
default = "ubuntu" default = "ubuntu"
} }
variable "external_gateway" { variable "external_gateway" {}
}
variable "pool" { variable "pool" {
default = "public" default = "public"