-
-
Save catsby/d1cf21e8e00eaba1adf461a0fddc7c4d to your computer and use it in GitHub Desktop.
MSSQL TZ tests
This file contains 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
provider "aws" { | |
region = "us-west-2" | |
} | |
variable "tzs" { | |
default = ["Eastern Standard Time", "US Eastern Standard Time", "Alaskan Standard Time"] | |
} | |
resource "aws_db_instance" "mssql" { | |
identifier = "test-mssql-tz-${count.index}" | |
count = "${length(var.tzs)}" | |
instance_class = "db.t2.micro" | |
allocated_storage = 20 | |
engine = "sqlserver-ex" | |
backup_retention_period = 7 | |
publicly_accessible = true | |
vpc_security_group_ids = ["${aws_security_group.rds-mssql.id}"] | |
password = "insecurebydesign" | |
username = "insecurebydesign" | |
timezone = "${element(var.tzs, count.index)}" | |
db_subnet_group_name = "${aws_db_subnet_group.rds_one.name}" | |
} | |
resource "aws_vpc" "rds_test_vpc" { | |
cidr_block = "10.1.0.0/16" | |
enable_dns_hostnames = true | |
tags { | |
Name = "rds_tz_test" | |
} | |
} | |
resource "aws_internet_gateway" "gw" { | |
vpc_id = "${aws_vpc.rds_test_vpc.id}" | |
tags { | |
Name = "main" | |
} | |
} | |
resource "aws_route_table" "r" { | |
vpc_id = "${aws_vpc.rds_test_vpc.id}" | |
route { | |
cidr_block = "0.0.0.0/0" | |
gateway_id = "${aws_internet_gateway.gw.id}" | |
} | |
tags { | |
Name = "aws_route_table" | |
} | |
} | |
resource "aws_route_table_association" "a" { | |
subnet_id = "${aws_subnet.main_west.id}" | |
route_table_id = "${aws_route_table.r.id}" | |
} | |
resource "aws_route_table_association" "ab" { | |
subnet_id = "${aws_subnet.other_west.id}" | |
route_table_id = "${aws_route_table.r.id}" | |
} | |
resource "aws_db_subnet_group" "rds_one" { | |
name = "rds_one_db" | |
description = "db subnets for rds_one" | |
subnet_ids = ["${aws_subnet.main_west.id}", | |
"${aws_subnet.other_west.id}", | |
] | |
} | |
resource "aws_subnet" "main_west" { | |
vpc_id = "${aws_vpc.rds_test_vpc.id}" | |
availability_zone = "us-west-2a" | |
cidr_block = "10.1.1.0/24" | |
} | |
resource "aws_subnet" "other_west" { | |
vpc_id = "${aws_vpc.rds_test_vpc.id}" | |
availability_zone = "us-west-2b" | |
cidr_block = "10.1.2.0/24" | |
} | |
resource "aws_security_group" "rds-mssql" { | |
name = "rds-launch-wizard" | |
description = "Created from the RDS Management Console" | |
vpc_id = "${aws_vpc.rds_test_vpc.id}" | |
} | |
resource "aws_security_group_rule" "rds-mssql" { | |
type = "ingress" | |
from_port = 1433 | |
to_port = 1433 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
security_group_id = "${aws_security_group.rds-mssql.id}" | |
} | |
resource "aws_security_group_rule" "rds-mssql-1" { | |
type = "egress" | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] | |
security_group_id = "${aws_security_group.rds-mssql.id}" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment