Skip to content

Instantly share code, notes, and snippets.

@afcastano
Created August 19, 2019 11:00
Show Gist options
  • Save afcastano/c3748373dc777ee8a637d60fd9a8522f to your computer and use it in GitHub Desktop.
Save afcastano/c3748373dc777ee8a637d60fd9a8522f to your computer and use it in GitHub Desktop.
AWS WP Tier
#provision wordpress subnet
resource "aws_subnet" "wp_subnet" {
vpc_id = "${aws_vpc.app_vpc.id}"
cidr_block = "${var.aws_wp_subnet_cidr}"
tags {
Name = "WordPress subnet"
}
availability_zone = "${data.aws_availability_zones.available.names[0]}"
}
# WP subnet routes for NAT
resource "aws_route_table" "wp-subnet-routes" {
vpc_id = "${aws_vpc.app_vpc.id}"
route {
cidr_block = "0.0.0.0/0"
nat_gateway_id = "${aws_nat_gateway.nat-gw.id}"
}
tags {
Name = "web-subnet-routes-1"
}
}
resource "aws_route_table_association" "wp-subnet-routes" {
subnet_id = "${aws_subnet.wp_subnet.id}"
route_table_id = "${aws_route_table.wp-subnet-routes.id}"
}
### SECURITY GROUPS #########################
#Private access for WP subnet
resource "aws_security_group" "wp" {
name = "wp-secgroup"
vpc_id = "${aws_vpc.app_vpc.id}"
# ssh access from bastion
ingress {
from_port = 22
to_port = 22
protocol = "TCP"
cidr_blocks = ["${var.aws_pub_subnet_1_cidr}"]
}
# http access from load balancer
ingress {
from_port = 80
to_port = 80
protocol = "TCP"
cidr_blocks = ["${var.aws_pub_subnet_1_cidr}"]
}
egress {
protocol = "-1"
from_port = 0
to_port = 0
cidr_blocks = ["0.0.0.0/0"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment