Last active
May 21, 2019 23:10
-
-
Save cabrinha/c8434a77e3598dff8086b43a14c92cd6 to your computer and use it in GitHub Desktop.
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
data "aws_ami" "ubuntu" { | |
most_recent = true | |
filter { | |
name = "name" | |
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"] | |
} | |
filter { | |
name = "virtualization-type" | |
values = ["hvm"] | |
} | |
owners = ["099720109477"] # Canonical | |
} | |
module "vpc" { | |
source = "terraform-aws-modules/vpc/aws" | |
version = "1.46.0" | |
name = "splunk" | |
cidr = "10.32.0.0/16" | |
azs = ["us-west-1a", "us-west-1b", "us-west-1c"] | |
private_subnets = ["10.0.1.0/24", "10.0.2.0/24", "10.0.3.0/24"] | |
public_subnets = ["10.0.101.0/24", "10.0.102.0/24", "10.0.103.0/24"] | |
enable_nat_gateway = true | |
tags = { | |
Name = "Splunk VPC" | |
App = "Splunk" | |
Owner = "Brent Weaver" | |
Purpose = "House Splunk Environment" | |
} | |
} | |
module "security-group" { | |
source = "terraform-aws-modules/security-group/aws" | |
version = "2.17.0" | |
name = "web-server" | |
description = "Security group for web-server with HTTP ports open within VPC" | |
vpc_id = "${module.vpc.vpc_id}" | |
ingress_rules = ["http-80-tcp"] | |
ingress_cidr_blocks = ["0.0.0.0/0"] | |
# Brent wants custom ports | |
ingress_with_cidr_blocks = [ | |
{ | |
from_port = 8000 | |
to_port = 8000 | |
protocol = "tcp" | |
description = "Brent's custom ports" | |
cidr_blocks = "10.132.1.0/24" | |
}, | |
{ | |
rule = "ssh-tcp" | |
cidr_blocks = "9.9.9.9/32" | |
} | |
] | |
} | |
resource "aws_instance" "vm" { | |
ami = "${data.aws_ami.ubuntu.id}" | |
instance_type = "t2.micro" | |
vpc_security_group_ids = ["${module.security-group.this_security_group_id}"] | |
tags = { | |
Name = "HelloWorld" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment