Rename ec2 to aws

This commit is contained in:
Prateep Bandharangshi
2019-06-26 14:19:04 +01:00
parent cca0a065c7
commit 0c1257b863
5 changed files with 2 additions and 2 deletions

View File

@ -0,0 +1,65 @@
provider "aws" {
region = var.ec2_region
}
resource "aws_security_group" "tpot" {
name = "T-Pot"
description = "T-Pot Honeypot"
vpc_id = var.ec2_vpc_id
ingress {
from_port = 0
to_port = 64000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 0
to_port = 64000
protocol = "udp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 64294
to_port = 64294
protocol = "tcp"
cidr_blocks = var.admin_ip
}
ingress {
from_port = 64295
to_port = 64295
protocol = "tcp"
cidr_blocks = var.admin_ip
}
ingress {
from_port = 64297
to_port = 64297
protocol = "tcp"
cidr_blocks = var.admin_ip
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = {
Name = "T-Pot"
}
}
resource "aws_instance" "tpot" {
ami = var.ec2_ami[var.ec2_region]
instance_type = var.ec2_instance_type
key_name = var.ec2_ssh_key_name
subnet_id = var.ec2_subnet_id
tags = {
Name = "T-Pot Honeypot"
}
root_block_device {
volume_type = "gp2"
volume_size = 128
delete_on_termination = true
}
user_data = "${file("../cloud-init.yaml")} content: ${base64encode(file("../tpot.conf"))}"
vpc_security_group_ids = [aws_security_group.tpot.id]
}

View File

@ -0,0 +1,12 @@
output "Admin_UI" {
value = "https://${aws_instance.tpot.public_dns}:64294/"
}
output "SSH_Access" {
value = "ssh -i {private_key_file} -p 64295 admin@${aws_instance.tpot.public_dns}"
}
output "Web_UI" {
value = "https://${aws_instance.tpot.public_dns}:64297/"
}

View File

@ -0,0 +1,53 @@
variable "admin_ip" {
default = ["127.0.0.1/32"]
description = "admin IP addresses in CIDR format"
}
variable "ec2_vpc_id" {
description = "ID of AWS VPC"
default = "vpc-XXX"
}
variable "ec2_subnet_id" {
description = "ID of AWS VPC subnet"
default = "subnet-YYY"
}
variable "ec2_region" {
description = "AWS region to launch servers"
default = "eu-west-1"
}
variable "ec2_ssh_key_name" {
default = "default"
}
# https://aws.amazon.com/ec2/instance-types/
# t3.large = 2 vCPU, 8 GiB RAM
variable "ec2_instance_type" {
default = "t3.large"
}
# Refer to https://wiki.debian.org/Cloud/AmazonEC2Image/Stretch
variable "ec2_ami" {
type = map(string)
default = {
"ap-northeast-1" = "ami-09fbcd30452841cb9"
"ap-northeast-2" = "ami-08363ccce96df1fff"
"ap-south-1" = "ami-0dc98cbb0d0e49162"
"ap-southeast-1" = "ami-0555b1a5444087dd4"
"ap-southeast-2" = "ami-029c54f988446691a"
"ca-central-1" = "ami-04413a263a7d94982"
"eu-central-1" = "ami-01fb3b7bab31acac5"
"eu-north-1" = "ami-050f04ca573daa1fb"
"eu-west-1" = "ami-0968f6a31fc6cffc0"
"eu-west-2" = "ami-0faa9c9b5399088fd"
"eu-west-3" = "ami-0cd23820af84edc85"
"sa-east-1" = "ami-030580e61468e54bd"
"us-east-1" = "ami-0357081a1383dc76b"
"us-east-2" = "ami-09c10a66337c79669"
"us-west-1" = "ami-0adbaf2e0ce044437"
"us-west-2" = "ami-05a3ef6744aa96514"
}
}

View File

@ -0,0 +1,3 @@
terraform {
required_version = ">= 0.12"
}