123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- ###########
- # Create a VPC with an Internet gateway for everybody to play in
- resource "aws_vpc" "vpc_primary" {
- cidr_block = "10.45.0.0/16"
- enable_dns_support = true
- enable_dns_hostnames = true
- tags = {
- Name = "Splunk Standalone"
- Project = "Splunk"
- Environment = "Production"
- }
- }
- resource "aws_internet_gateway" "gw_primary" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- tags = {
- Name = "Primary Gateway"
- }
- }
- ###########
- # Create 3 Subnets, one in each AZ.
- # Note that most servers will be spread between 1 and 2, but we need
- # 3 AZs for a quorum for the SearchHead Cluster.
- data "aws_availability_zones" "available" {}
- resource "aws_subnet" "splunk_subnet_0" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- cidr_block = "10.45.0.0/24"
- availability_zone = "${data.aws_availability_zones.available.names[0]}"
- map_public_ip_on_launch = true
- tags = {
- Name = "Splunk Subnet 0"
- }
- }
- resource "aws_subnet" "splunk_subnet_1" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- cidr_block = "10.45.1.0/24"
- availability_zone = "${data.aws_availability_zones.available.names[1]}"
- map_public_ip_on_launch = true
- tags = {
- Name = "Splunk Subnet 1"
- }
- }
- resource "aws_subnet" "splunk_subnet_2" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- cidr_block = "10.45.2.0/24"
- availability_zone = "${data.aws_availability_zones.available.names[2]}"
- map_public_ip_on_launch = true
- tags = {
- Name = "Splunk Subnet 2"
- }
- }
- ###########
- # Create a route table
- resource "aws_route_table" "r" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- route {
- cidr_block = "0.0.0.0/0"
- gateway_id = "${aws_internet_gateway.gw_primary.id}"
- }
- tags = {
- Name = "Primary Route Table"
- }
- }
- ###########
- # Create an S3 endpoint
- resource "aws_vpc_endpoint" "s3" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- service_name = "com.amazonaws.us-east-2.s3"
- }
- resource "aws_vpc_endpoint_route_table_association" "s3_routing" {
- route_table_id = "${aws_route_table.r.id}"
- vpc_endpoint_id = "${aws_vpc_endpoint.s3.id}"
- }
- # Associate with VPC
- resource "aws_main_route_table_association" "rt_public_a" {
- vpc_id = "${aws_vpc.vpc_primary.id}"
- route_table_id = "${aws_route_table.r.id}"
- }
|