Permalink
Cannot retrieve contributors at this time
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
57 lines (48 sloc)
1.28 KB
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
provider "aws" { | |
region = "us-west-2" | |
} | |
variable "ip_address" { | |
description = "External IP address" | |
} | |
variable "proxy_port" { | |
description = "Proxy port for incoming requests" | |
default = 8888 | |
} | |
output "proxy_ip_address" { | |
value = aws_instance.tinyproxy-terraform.public_ip | |
description = "Public IP address of the proxy server" | |
} | |
output "proxy_port" { | |
value = var.proxy_port | |
description = "Port of the proxy server" | |
} | |
resource "aws_instance" "tinyproxy-terraform" { | |
ami = "ami-0d1cd67c26f5fca19" | |
instance_type = "t2.micro" | |
vpc_security_group_ids = [aws_security_group.instance.id] | |
user_data = <<-EOF | |
#!/bin/bash | |
sudo apt update | |
sudo apt-get install tinyproxy -y | |
sudo echo "Allow ${var.ip_address}" >> /etc/tinyproxy/tinyproxy.conf | |
sudo systemctl restart tinyproxy | |
EOF | |
tags = { | |
Name = "tinyproxy" | |
} | |
} | |
resource "aws_security_group" "instance" { | |
name = "tinyproxy-terraform-instance" | |
ingress { | |
from_port = var.proxy_port | |
to_port = var.proxy_port | |
protocol = "tcp" | |
cidr_blocks = ["${var.ip_address}/32"] | |
} | |
egress { | |
from_port = 0 | |
to_port = 0 | |
protocol = "-1" | |
cidr_blocks = ["0.0.0.0/0"] | |
} | |
} |