Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JSON 1.76 KB | None | 0 0
  1.  
  2. resource "aws_subnet" "jbox" {
  3.     vpc_id = "${aws_vpc.vpc-mitm.id}"
  4.  
  5.     #problem was
  6.     map_public_ip_on_launch = true
  7.  
  8.  
  9.     cidr_block = "${var.public_jbox_subnet_cidr}"
  10.     availability_zone = "${var.aws_availability_zone}"
  11.  
  12.     tags {
  13.         Name = "MITM: Public Jbox Subnet"
  14.     }
  15. }
  16.  
  17.  
  18. resource "aws_route_table_association" "jbox" {
  19.     subnet_id = "${aws_subnet.jbox.id}"
  20.     route_table_id = "${aws_route_table.all_to_igw.id}"
  21. }
  22.  
  23.  
  24.  
  25. #elastic IP for JBOX
  26. resource "aws_eip" "jbox" {
  27.     vpc = true
  28. }
  29.  
  30. resource "aws_eip_association" "jbox" {
  31.   instance_id   = "${aws_instance.jbox.id}"
  32.   allocation_id = "${aws_eip.jbox.id}"
  33. }
  34.  
  35.  
  36.  
  37. #security group only for SSH connection to JBOX
  38. resource "aws_security_group" "jbox" {
  39.  
  40.   tags {
  41.     Name = "MITM: JBOX"
  42.   }
  43.  
  44.  
  45.   vpc_id = "${aws_vpc.vpc-mitm.id}"
  46.  
  47.   ingress {
  48.     from_port = 22
  49.     to_port = 22
  50.     protocol = "tcp"
  51.     cidr_blocks = ["0.0.0.0/0"]
  52.   }
  53.  
  54.   #TODO: Remove Later
  55.   egress {
  56.     protocol    = -1
  57.     from_port   = 0
  58.     to_port     = 0
  59.     cidr_blocks = ["0.0.0.0/0"]
  60.   }
  61. }
  62.  
  63. #JBOX
  64. resource "aws_instance" "jbox" {
  65.  
  66.     ami           = "${lookup(var.amis, var.aws_region)}" #ubuntu 16.04
  67.  
  68.     subnet_id     = "${aws_subnet.jbox.id}"
  69.  
  70.     vpc_security_group_ids = ["${aws_security_group.jbox.id}"]
  71.  
  72.     instance_type = "t2.micro"
  73.  
  74.     key_name      = "${aws_key_pair.aws-ssh-key.key_name}"
  75.  
  76.     tags {
  77.       Name = "MITM: JBOX"
  78.     }
  79.    
  80.    provisioner "file" {
  81.       source      = "${var.ssh_jbox_key_path}"
  82.       destination = "${var.ssh_default_ubuntu_dir_path}"
  83.      
  84.        connection {
  85.         type        = "ssh"
  86.         user        = "ubuntu"
  87.         private_key = "${file(var.ssh_jbox_key_path)}"
  88.         agent = false
  89.        }
  90.     }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement