Fmt all the config files
Signed-off-by: Valentin Pichard <valentin.pichard@corp.ovh.com>
This commit is contained in:
parent
196955c93c
commit
c6beaa7ce8
|
@ -8,6 +8,7 @@ resource "aws_elb" "web-elb" {
|
|||
|
||||
# The same availability zone as our instances
|
||||
availability_zones = ["${split(",", var.availability_zones)}"]
|
||||
|
||||
listener {
|
||||
instance_port = 80
|
||||
instance_protocol = "http"
|
||||
|
@ -22,7 +23,6 @@ resource "aws_elb" "web-elb" {
|
|||
target = "HTTP:80/"
|
||||
interval = 30
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resource "aws_autoscaling_group" "web-asg" {
|
||||
|
@ -34,6 +34,7 @@ resource "aws_autoscaling_group" "web-asg" {
|
|||
force_delete = true
|
||||
launch_configuration = "${aws_launch_configuration.web-lc.name}"
|
||||
load_balancers = ["${aws_elb.web-elb.name}"]
|
||||
|
||||
#vpc_zone_identifier = ["${split(",", var.availability_zones)}"]
|
||||
tag {
|
||||
key = "Name"
|
||||
|
@ -46,6 +47,7 @@ resource "aws_launch_configuration" "web-lc" {
|
|||
name = "terraform-example-lc"
|
||||
image_id = "${lookup(var.aws_amis, var.aws_region)}"
|
||||
instance_type = "${var.instance_type}"
|
||||
|
||||
# Security group
|
||||
security_groups = ["${aws_security_group.default.id}"]
|
||||
user_data = "${file("userdata.sh")}"
|
||||
|
|
|
@ -1,12 +1,15 @@
|
|||
output "security_group" {
|
||||
value = "${aws_security_group.default.id}"
|
||||
}
|
||||
|
||||
output "launch_configuration" {
|
||||
value = "${aws_launch_configuration.web-lc.id}"
|
||||
}
|
||||
|
||||
output "asg_name" {
|
||||
value = "${aws_autoscaling_group.web-asg.id}"
|
||||
}
|
||||
|
||||
output "elb_name" {
|
||||
value = "${aws_elb.web-elb.dns_name}"
|
||||
}
|
||||
|
|
|
@ -39,4 +39,3 @@ variable "asg_desired" {
|
|||
description = "Desired numbers of servers in ASG"
|
||||
default = "1"
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ provider "aws" {
|
|||
|
||||
resource "aws_cloudwatch_event_rule" "foo" {
|
||||
name = "${var.rule_name}"
|
||||
|
||||
event_pattern = <<PATTERN
|
||||
{
|
||||
"detail-type": [
|
||||
|
@ -16,11 +17,13 @@ resource "aws_cloudwatch_event_rule" "foo" {
|
|||
}
|
||||
}
|
||||
PATTERN
|
||||
|
||||
role_arn = "${aws_iam_role.role.arn}"
|
||||
}
|
||||
|
||||
resource "aws_iam_role" "role" {
|
||||
name = "${var.iam_role_name}"
|
||||
|
||||
assume_role_policy = <<POLICY
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
|
@ -41,6 +44,7 @@ POLICY
|
|||
resource "aws_iam_role_policy" "policy" {
|
||||
name = "tf-example-policy"
|
||||
role = "${aws_iam_role.role.id}"
|
||||
|
||||
policy = <<POLICY
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
|
|
|
@ -4,6 +4,7 @@ provider "aws" {
|
|||
|
||||
resource "aws_cloudwatch_event_rule" "foo" {
|
||||
name = "${var.rule_name}"
|
||||
|
||||
event_pattern = <<PATTERN
|
||||
{
|
||||
"detail-type": [
|
||||
|
|
|
@ -20,7 +20,6 @@ resource "aws_elb" "web" {
|
|||
instances = ["${aws_instance.web.*.id}"]
|
||||
}
|
||||
|
||||
|
||||
resource "aws_instance" "web" {
|
||||
instance_type = "m1.small"
|
||||
ami = "${lookup(var.aws_amis, var.aws_region)}"
|
||||
|
|
|
@ -26,6 +26,7 @@ resource "aws_internet_gateway" "gw" {
|
|||
|
||||
resource "aws_route_table" "r" {
|
||||
vpc_id = "${aws_vpc.main.id}"
|
||||
|
||||
route {
|
||||
cidr_block = "0.0.0.0/0"
|
||||
gateway_id = "${aws_internet_gateway.gw.id}"
|
||||
|
@ -51,6 +52,7 @@ resource "aws_autoscaling_group" "app" {
|
|||
|
||||
data "template_file" "cloud_config" {
|
||||
template = "${file("${path.module}/cloud-config.yml")}"
|
||||
|
||||
vars {
|
||||
aws_region = "${var.aws_region}"
|
||||
ecs_cluster_name = "${aws_ecs_cluster.main.name}"
|
||||
|
@ -62,31 +64,37 @@ data "template_file" "cloud_config" {
|
|||
|
||||
data "aws_ami" "stable_coreos" {
|
||||
most_recent = true
|
||||
|
||||
filter {
|
||||
name = "description"
|
||||
values = ["CoreOS stable *"]
|
||||
}
|
||||
|
||||
filter {
|
||||
name = "architecture"
|
||||
values = ["x86_64"]
|
||||
}
|
||||
|
||||
filter {
|
||||
name = "virtualization-type"
|
||||
values = ["hvm"]
|
||||
}
|
||||
|
||||
owners = ["595879546273"] # CoreOS
|
||||
}
|
||||
|
||||
resource "aws_launch_configuration" "app" {
|
||||
security_groups = [
|
||||
"${aws_security_group.instance_sg.id}"
|
||||
"${aws_security_group.instance_sg.id}",
|
||||
]
|
||||
|
||||
key_name = "${var.key_name}"
|
||||
image_id = "${data.aws_ami.stable_coreos.id}"
|
||||
instance_type = "${var.instance_type}"
|
||||
iam_instance_profile = "${aws_iam_instance_profile.app.name}"
|
||||
user_data = "${data.template_file.cloud_config.rendered}"
|
||||
associate_public_ip_address = true
|
||||
|
||||
lifecycle {
|
||||
create_before_destroy = true
|
||||
}
|
||||
|
@ -111,8 +119,9 @@ resource "aws_security_group" "lb_sg" {
|
|||
from_port = 0
|
||||
to_port = 0
|
||||
protocol = "-1"
|
||||
|
||||
cidr_blocks = [
|
||||
"0.0.0.0/0"
|
||||
"0.0.0.0/0",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
@ -126,18 +135,22 @@ resource "aws_security_group" "instance_sg" {
|
|||
protocol = "tcp"
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
|
||||
cidr_blocks = [
|
||||
"${var.admin_cidr_ingress}"
|
||||
"${var.admin_cidr_ingress}",
|
||||
]
|
||||
}
|
||||
|
||||
ingress {
|
||||
protocol = "tcp"
|
||||
from_port = 8080
|
||||
to_port = 8080
|
||||
|
||||
security_groups = [
|
||||
"${aws_security_group.lb_sg.id}"
|
||||
"${aws_security_group.lb_sg.id}",
|
||||
]
|
||||
}
|
||||
|
||||
egress {
|
||||
from_port = 0
|
||||
to_port = 0
|
||||
|
@ -146,7 +159,6 @@ resource "aws_security_group" "instance_sg" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
## ECS
|
||||
|
||||
resource "aws_ecs_cluster" "main" {
|
||||
|
@ -155,6 +167,7 @@ resource "aws_ecs_cluster" "main" {
|
|||
|
||||
data "template_file" "task_definition" {
|
||||
template = "${file("${path.module}/task-definition.json")}"
|
||||
|
||||
vars {
|
||||
image_url = "ghost:latest"
|
||||
container_name = "ghost"
|
||||
|
@ -183,15 +196,15 @@ resource "aws_ecs_service" "test" {
|
|||
|
||||
depends_on = [
|
||||
"aws_iam_role_policy.ecs_service",
|
||||
"aws_alb_listener.front_end"
|
||||
"aws_alb_listener.front_end",
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
## IAM
|
||||
|
||||
resource "aws_iam_role" "ecs_service" {
|
||||
name = "tf_example_ecs_role"
|
||||
|
||||
assume_role_policy = <<EOF
|
||||
{
|
||||
"Version": "2008-10-17",
|
||||
|
@ -212,6 +225,7 @@ EOF
|
|||
resource "aws_iam_role_policy" "ecs_service" {
|
||||
name = "tf_example_ecs_policy"
|
||||
role = "${aws_iam_role.ecs_service.name}"
|
||||
|
||||
policy = <<EOF
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
|
@ -240,6 +254,7 @@ resource "aws_iam_instance_profile" "app" {
|
|||
|
||||
resource "aws_iam_role" "app_instance" {
|
||||
name = "tf-ecs-example-instance-role"
|
||||
|
||||
assume_role_policy = <<EOF
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
|
@ -259,6 +274,7 @@ EOF
|
|||
|
||||
data "template_file" "instance_profile" {
|
||||
template = "${file("${path.module}/instance-profile-policy.json")}"
|
||||
|
||||
vars {
|
||||
app_log_group_arn = "${aws_cloudwatch_log_group.app.arn}"
|
||||
ecs_log_group_arn = "${aws_cloudwatch_log_group.ecs.arn}"
|
||||
|
|
|
@ -39,7 +39,6 @@ resource "aws_security_group" "default" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
resource "aws_instance" "web" {
|
||||
instance_type = "t2.micro"
|
||||
|
||||
|
@ -61,6 +60,7 @@ resource "aws_instance" "web" {
|
|||
# In this case, we just install nginx and start it. By default,
|
||||
# this should be on port 80
|
||||
user_data = "${file("userdata.sh")}"
|
||||
|
||||
#Instance tags
|
||||
tags {
|
||||
Name = "eip-example"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
output "address" {
|
||||
value = "${aws_instance.web.private_ip}"
|
||||
}
|
||||
|
||||
output "elastic ip" {
|
||||
value = "${aws_eip.default.public_ip}"
|
||||
}
|
||||
|
|
|
@ -14,4 +14,3 @@ variable "aws_amis" {
|
|||
variable "key_name" {
|
||||
description = "Name of the SSH keypair to use in AWS."
|
||||
}
|
||||
|
||||
|
|
|
@ -63,6 +63,7 @@ resource "aws_elb" "web" {
|
|||
# The same availability zone as our instance
|
||||
availability_zones = ["${aws_instance.web.availability_zone}"]
|
||||
security_groups = ["${aws_security_group.elb.id}"]
|
||||
|
||||
listener {
|
||||
instance_port = 80
|
||||
instance_protocol = "http"
|
||||
|
@ -85,7 +86,6 @@ resource "aws_elb" "web" {
|
|||
idle_timeout = 400
|
||||
connection_draining = true
|
||||
connection_draining_timeout = 400
|
||||
|
||||
}
|
||||
|
||||
resource "aws_lb_cookie_stickiness_policy" "default" {
|
||||
|
@ -96,7 +96,6 @@ resource "aws_lb_cookie_stickiness_policy" "default" {
|
|||
}
|
||||
|
||||
resource "aws_instance" "web" {
|
||||
|
||||
instance_type = "t2.micro"
|
||||
|
||||
# Lookup the correct AMI based on the region
|
||||
|
@ -114,6 +113,7 @@ resource "aws_instance" "web" {
|
|||
security_groups = ["${aws_security_group.default.name}"]
|
||||
|
||||
user_data = "${file("userdata.sh")}"
|
||||
|
||||
#Instance tags
|
||||
tags {
|
||||
Name = "elb-example"
|
||||
|
|
|
@ -14,4 +14,3 @@ variable "aws_amis" {
|
|||
"us-west-2" = "ami-7f675e4f"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
output "subnet_group" {
|
||||
value = "${aws_db_subnet_group.default.name}"
|
||||
}
|
||||
|
||||
output "db_instance_id" {
|
||||
value = "${aws_db_instance.default.id}"
|
||||
}
|
||||
|
||||
output "db_instance_address" {
|
||||
value = "${aws_db_instance.default.address}"
|
||||
}
|
||||
|
||||
|
|
|
@ -7,4 +7,3 @@ variable "sg_name" {
|
|||
default = "rds_sg"
|
||||
description = "Tag Name for sg"
|
||||
}
|
||||
|
||||
|
|
|
@ -21,4 +21,3 @@ variable "az_2" {
|
|||
variable "vpc_id" {
|
||||
description = "Your VPC ID"
|
||||
}
|
||||
|
||||
|
|
|
@ -15,6 +15,7 @@ variable "engine" {
|
|||
|
||||
variable "engine_version" {
|
||||
description = "Engine version"
|
||||
|
||||
default = {
|
||||
mysql = "5.6.22"
|
||||
postgres = "9.4.1"
|
||||
|
|
|
@ -11,6 +11,7 @@ resource "aws_s3_bucket" "prod" {
|
|||
|
||||
bucket = "${var.bucket_name}"
|
||||
acl = "private"
|
||||
|
||||
policy = <<POLICY
|
||||
{
|
||||
"Version": "2012-10-17",
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
variable "prod_access_key" {}
|
||||
|
||||
variable "prod_secret_key" {}
|
||||
|
||||
variable "test_account_id" {}
|
||||
|
||||
variable "test_access_key" {}
|
||||
|
||||
variable "test_secret_key" {}
|
||||
|
||||
variable "bucket_name" {}
|
||||
|
|
|
@ -82,7 +82,6 @@ resource "aws_security_group" "default" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
resource "aws_elb" "web" {
|
||||
name = "terraform-example-elb"
|
||||
|
||||
|
@ -96,7 +95,6 @@ resource "aws_elb" "web" {
|
|||
lb_port = 80
|
||||
lb_protocol = "http"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resource "aws_key_pair" "auth" {
|
||||
|
@ -138,7 +136,7 @@ resource "aws_instance" "web" {
|
|||
inline = [
|
||||
"sudo apt-get -y update",
|
||||
"sudo apt-get -y install nginx",
|
||||
"sudo service nginx start"
|
||||
"sudo service nginx start",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,14 +23,14 @@ resource "clc_server" "node" {
|
|||
cpu = 2
|
||||
memory_mb = 2048
|
||||
password = "Green123$"
|
||||
additional_disks
|
||||
{
|
||||
|
||||
additional_disks {
|
||||
path = "/var"
|
||||
size_gb = 100
|
||||
type = "partitioned"
|
||||
}
|
||||
additional_disks
|
||||
{
|
||||
|
||||
additional_disks {
|
||||
size_gb = 10
|
||||
type = "raw"
|
||||
}
|
||||
|
@ -41,35 +41,35 @@ resource "clc_server" "node" {
|
|||
resource "clc_public_ip" "backdoor" {
|
||||
server_id = "${clc_server.node.0.id}"
|
||||
internal_ip_address = "${clc_server.node.0.private_ip_address}"
|
||||
ports
|
||||
{
|
||||
|
||||
ports {
|
||||
protocol = "ICMP"
|
||||
port = -1
|
||||
}
|
||||
ports
|
||||
{
|
||||
|
||||
ports {
|
||||
protocol = "TCP"
|
||||
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
|
||||
provisioner "remote-exec" {
|
||||
inline = [
|
||||
"cd /tmp; python -mSimpleHTTPServer > /dev/null 2>&1 &"
|
||||
"cd /tmp; python -mSimpleHTTPServer > /dev/null 2>&1 &",
|
||||
]
|
||||
|
||||
connection {
|
||||
host = "${clc_public_ip.backdoor.id}"
|
||||
user = "root"
|
||||
password = "${clc_server.node.password}"
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
# --------------------
|
||||
# Provision a load balancer
|
||||
resource "clc_load_balancer" "frontdoor" {
|
||||
|
@ -87,8 +87,8 @@ resource "clc_load_balancer_pool" "pool" {
|
|||
method = "roundRobin"
|
||||
persistence = "standard"
|
||||
port = 80
|
||||
nodes
|
||||
{
|
||||
|
||||
nodes {
|
||||
status = "enabled"
|
||||
ipAddress = "${clc_server.node.private_ip_address}"
|
||||
privatePort = 8000
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
variable "clc_username" {
|
||||
default = "<username>"
|
||||
}
|
||||
|
||||
variable "clc_password" {
|
||||
default = "<password>"
|
||||
}
|
||||
|
|
|
@ -34,6 +34,7 @@ resource "consul_keys" "test" {
|
|||
value = "${aws_instance.test.id}"
|
||||
delete = true
|
||||
}
|
||||
|
||||
key {
|
||||
name = "address"
|
||||
path = "tf_test/public_dns"
|
||||
|
|
|
@ -19,8 +19,9 @@ resource "digitalocean_droplet" "mywebserver" {
|
|||
inline = [
|
||||
"export PATH=$PATH:/usr/bin",
|
||||
"sudo apt-get update",
|
||||
"sudo apt-get -y install nginx"
|
||||
"sudo apt-get -y install nginx",
|
||||
]
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
key_file = "file(${HOME}/.ssh/id_rsa)"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
# ####
|
||||
|
||||
# Current Availiable Datacenter Regions
|
||||
|
||||
# As of 05-07-2016
|
||||
|
||||
#
|
||||
|
||||
variable "do_ams2" {
|
||||
|
|
|
@ -105,9 +105,11 @@ resource "google_compute_vpn_tunnel" "tunnel1" {
|
|||
peer_ip = "${google_compute_address.vpn_static_ip2.address}"
|
||||
shared_secret = "a secret message"
|
||||
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway1.self_link}"
|
||||
|
||||
depends_on = ["google_compute_forwarding_rule.fr1_udp500",
|
||||
"google_compute_forwarding_rule.fr1_udp4500",
|
||||
"google_compute_forwarding_rule.fr1_esp"]
|
||||
"google_compute_forwarding_rule.fr1_esp",
|
||||
]
|
||||
}
|
||||
|
||||
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}"
|
||||
shared_secret = "a secret message"
|
||||
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway2.self_link}"
|
||||
|
||||
depends_on = ["google_compute_forwarding_rule.fr2_udp500",
|
||||
"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
|
||||
|
@ -145,12 +149,15 @@ resource "google_compute_firewall" "network1-allow-network1" {
|
|||
name = "network1-allow-network1"
|
||||
network = "${google_compute_network.network1.name}"
|
||||
source_ranges = ["${google_compute_network.network1.ipv4_range}"]
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
}
|
||||
|
||||
allow {
|
||||
protocol = "udp"
|
||||
}
|
||||
|
||||
allow {
|
||||
protocol = "icmp"
|
||||
}
|
||||
|
@ -160,12 +167,15 @@ resource "google_compute_firewall" "network1-allow-network2" {
|
|||
name = "network1-allow-network2"
|
||||
network = "${google_compute_network.network1.name}"
|
||||
source_ranges = ["${google_compute_network.network2.ipv4_range}"]
|
||||
|
||||
allow {
|
||||
protocol = "tcp"
|
||||
}
|
||||
|
||||
allow {
|
||||
protocol = "udp"
|
||||
}
|
||||
|
||||
allow {
|
||||
protocol = "icmp"
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ resource "google_compute_instance" "www" {
|
|||
|
||||
network_interface {
|
||||
network = "default"
|
||||
|
||||
access_config {
|
||||
# Ephemeral
|
||||
}
|
||||
|
@ -53,6 +54,7 @@ resource "google_compute_instance" "www" {
|
|||
provisioner "file" {
|
||||
source = "${var.install_script_src_path}"
|
||||
destination = "${var.install_script_dest_path}"
|
||||
|
||||
connection {
|
||||
type = "ssh"
|
||||
user = "root"
|
||||
|
@ -68,9 +70,10 @@ resource "google_compute_instance" "www" {
|
|||
private_key = "${file("${var.private_key_path}")}"
|
||||
agent = false
|
||||
}
|
||||
|
||||
inline = [
|
||||
"chmod +x ${var.install_script_dest_path}",
|
||||
"sudo ${var.install_script_dest_path} ${count.index}"
|
||||
"sudo ${var.install_script_dest_path} ${count.index}",
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -30,18 +30,21 @@ resource "openstack_networking_router_interface_v2" "terraform" {
|
|||
resource "openstack_compute_secgroup_v2" "terraform" {
|
||||
name = "terraform"
|
||||
description = "Security group for the Terraform example instances"
|
||||
|
||||
rule {
|
||||
from_port = 22
|
||||
to_port = 22
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
|
||||
rule {
|
||||
from_port = 80
|
||||
to_port = 80
|
||||
ip_protocol = "tcp"
|
||||
cidr = "0.0.0.0/0"
|
||||
}
|
||||
|
||||
rule {
|
||||
from_port = -1
|
||||
to_port = -1
|
||||
|
@ -62,18 +65,21 @@ resource "openstack_compute_instance_v2" "terraform" {
|
|||
key_pair = "${openstack_compute_keypair_v2.terraform.name}"
|
||||
security_groups = ["${openstack_compute_secgroup_v2.terraform.name}"]
|
||||
floating_ip = "${openstack_compute_floatingip_v2.terraform.address}"
|
||||
|
||||
network {
|
||||
uuid = "${openstack_networking_network_v2.terraform.id}"
|
||||
}
|
||||
|
||||
provisioner "remote-exec" {
|
||||
connection {
|
||||
user = "${var.ssh_user_name}"
|
||||
key_file = "${var.ssh_key_file}"
|
||||
}
|
||||
|
||||
inline = [
|
||||
"sudo apt-get -y update",
|
||||
"sudo apt-get -y install nginx",
|
||||
"sudo service nginx start"
|
||||
"sudo service nginx start",
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,8 +14,7 @@ variable "ssh_user_name" {
|
|||
default = "ubuntu"
|
||||
}
|
||||
|
||||
variable "external_gateway" {
|
||||
}
|
||||
variable "external_gateway" {}
|
||||
|
||||
variable "pool" {
|
||||
default = "public"
|
||||
|
|
Loading…
Reference in New Issue