Last active
April 26, 2018 21:10
-
-
Save foxutech/26abd4e05e9990bfae79e0c2b8cf3506 to your computer and use it in GitHub Desktop.
This file contains hidden or 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" { | |
access_key = "xxxxxxxxxxxxxxx" | |
secret_key = "yyyyyyyyyyyyyyyyyyyyy" | |
region = "us-west-2" | |
} | |
resource "aws_iam_role" "test_role" { | |
name = "TenableIO" | |
assume_role_policy = <<EOF | |
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "ec2.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
"Sid": "" | |
} | |
] | |
} | |
EOF | |
} | |
resource "aws_vpc" "default" { | |
cidr_block = "10.0.0.0/16" | |
enable_dns_hostnames = true | |
tags { | |
Name = "terraform-aws-vpc" | |
} | |
} | |
resource "aws_internet_gateway" "default" { | |
vpc_id = "${aws_vpc.default.id}" | |
} | |
/* | |
NAT Instance | |
*/ | |
resource "aws_security_group" "tenable" { | |
name = "vpc_tenable" | |
description = "Allow traffic to pass from the private subnet to the internet" | |
ingress { | |
from_port = 80 | |
to_port = 80 | |
protocol = "tcp" | |
cidr_blocks = ["10.0.0.0/24"] | |
} | |
ingress { | |
from_port = 443 | |
to_port = 443 | |
protocol = "tcp" | |
cidr_blocks = ["10.0.1.0/24"] | |
} | |
ingress { | |
from_port = 22 | |
to_port = 22 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
ingress { | |
from_port = -1 | |
to_port = -1 | |
protocol = "icmp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
egress { | |
from_port = 80 | |
to_port = 80 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
egress { | |
from_port = 443 | |
to_port = 443 | |
protocol = "tcp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
egress { | |
from_port = 22 | |
to_port = 22 | |
protocol = "tcp" | |
cidr_blocks = ["10.0.0.0/16"] | |
} | |
egress { | |
from_port = -1 | |
to_port = -1 | |
protocol = "icmp" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
vpc_id = "${aws_vpc.default.id}" | |
tags { | |
Name = "NATSG" | |
} | |
} | |
resource "template_file" "web-userdata" { | |
filename = "user-data.web" | |
} | |
resource "aws_instance" "scanner" { | |
ami = "ami-03121663" | |
instance_type = "m4.large" | |
key_name = "foxutech" | |
security_groups = ["${aws_security_group.tenable.id}"] | |
user_data = "${template_file.web-userdata.rendered}" | |
tags { | |
Name = "tenable-scanner" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment