Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@paulcdejean
Created December 27, 2019 18:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulcdejean/1dbfc91b362760a9008c6143818a719e to your computer and use it in GitHub Desktop.
Save paulcdejean/1dbfc91b362760a9008c6143818a719e to your computer and use it in GitHub Desktop.
resource "aws_eip" "nateip" {
vpc = true
}
resource "aws_nat_gateway" "gw" {
allocation_id = aws_eip.nateip.id
subnet_id = aws_subnet.nat.id
tags = {
Name = "oauthexample_natgw"
}
}
resource "aws_route_table" "private" {
vpc_id = aws_vpc.vpc.id
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = aws_nat_gateway.gw.id
}
tags = {
Name = "oauthexample_private"
}
}
resource "aws_route_table_association" "prometheus" {
subnet_id = aws_subnet.prom.id
route_table_id = aws_route_table.private.id
}
resource "aws_security_group" "prom" {
name = "oauthexample-prometheus"
description = "oauthexample prometheus sg"
vpc_id = aws_vpc.vpc.id
}
resource "aws_security_group_rule" "prom" {
security_group_id = aws_security_group.prom.id
type = "egress"
cidr_blocks = ["0.0.0.0/0"]
protocol = "all"
from_port = 0
to_port = 0
}
resource "aws_security_group_rule" "prom-1" {
security_group_id = aws_security_group.prom.id
type = "ingress"
cidr_blocks = ["0.0.0.0/0"]
protocol = "tcp"
from_port = 80
to_port = 80
}
resource "aws_security_group_rule" "prom-2" {
security_group_id = aws_security_group.prom.id
type = "ingress"
source_security_group_id = aws_security_group.bastion.id
protocol = "tcp"
from_port = 22
to_port = 22
}
resource "aws_security_group_rule" "prom-3" {
security_group_id = aws_security_group.prom.id
type = "ingress"
source_security_group_id = aws_security_group.bastion.id
protocol = "tcp"
from_port = 9090
to_port = 9090
}
resource "aws_instance" "prom" {
ami = "ami-0c830793775595d4b"
instance_type = "t2.medium"
subnet_id = aws_subnet.prom.id
associate_public_ip_address = false
vpc_security_group_ids = [aws_security_group.prom.id]
key_name = "oauthexample"
root_block_device {
volume_size = 30
volume_type = "gp2"
}
tags = {
Name = "oauthexample prometheus server"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment