Skip to content

Commit

Permalink
Merge pull request scpwiki#45 from scpwiki/unix-newlines
Browse files Browse the repository at this point in the history
Convert to UNIX newlines
  • Loading branch information
Ammon Smith authored Nov 12, 2020
2 parents 10ad58b + 1c76c2a commit 80e1052
Show file tree
Hide file tree
Showing 1,351 changed files with 147,961 additions and 147,961 deletions.
6 changes: 3 additions & 3 deletions infra/terraform/prod/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# wikijump-deploy
Terraform files for deployment of Wikijump cloud environments.

# wikijump-deploy
Terraform files for deployment of Wikijump cloud environments.

24 changes: 12 additions & 12 deletions infra/terraform/prod/acm.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
resource "aws_acm_certificate" "cf_wildcard_cert" {
domain_name = var.web_domain
subject_alternative_names = [
var.files_domain,
"*.${var.web_domain}",
"*.${var.files_domain}"
]
validation_method = "DNS"

lifecycle {
create_before_destroy = true
}
resource "aws_acm_certificate" "cf_wildcard_cert" {
domain_name = var.web_domain
subject_alternative_names = [
var.files_domain,
"*.${var.web_domain}",
"*.${var.files_domain}"
]
validation_method = "DNS"

lifecycle {
create_before_destroy = true
}
}
90 changes: 45 additions & 45 deletions infra/terraform/prod/cloudfront.tf
Original file line number Diff line number Diff line change
@@ -1,46 +1,46 @@
resource "aws_cloudfront_distribution" "wikijump_cf_distro" {
enabled = true
is_ipv6_enabled = true
default_root_object = "index.php"

aliases = [var.web_domain, var.files_domain]

origin {
domain_name = aws_lb.wikijump_elb.dns_name
origin_id = "wikijump_elb"
custom_header {
name = "X-CLOUDFRONT-WIKIJUMP-AUTH"
value = var.cf_auth_token
}
}

restrictions {
geo_restriction {
restriction_type = "none"
}
}

default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "wikijump_elb"

forwarded_values {
query_string = true

cookies {
forward = "all"
}
}

viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 60
compress = true
max_ttl = 60
}

viewer_certificate {
acm_certificate_arn = aws_acm_certificate.cf_wildcard_cert.arn
}
resource "aws_cloudfront_distribution" "wikijump_cf_distro" {
enabled = true
is_ipv6_enabled = true
default_root_object = "index.php"

aliases = [var.web_domain, var.files_domain]

origin {
domain_name = aws_lb.wikijump_elb.dns_name
origin_id = "wikijump_elb"
custom_header {
name = "X-CLOUDFRONT-WIKIJUMP-AUTH"
value = var.cf_auth_token
}
}

restrictions {
geo_restriction {
restriction_type = "none"
}
}

default_cache_behavior {
allowed_methods = ["DELETE", "GET", "HEAD", "OPTIONS", "PATCH", "POST", "PUT"]
cached_methods = ["GET", "HEAD"]
target_origin_id = "wikijump_elb"

forwarded_values {
query_string = true

cookies {
forward = "all"
}
}

viewer_protocol_policy = "redirect-to-https"
min_ttl = 0
default_ttl = 60
compress = true
max_ttl = 60
}

viewer_certificate {
acm_certificate_arn = aws_acm_certificate.cf_wildcard_cert.arn
}
}
212 changes: 106 additions & 106 deletions infra/terraform/prod/elb.tf
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
# ELB

resource "aws_lb" "wikijump_elb" {
name = "wikijump-public-elb-${var.environment}"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.elb_sg.id]
subnet_mapping {
subnet_id = aws_subnet.elb_subnet.id
allocation_id = aws_eip.elb_eip.id
}

# Enable this once stable.
enable_deletion_protection = false

access_logs {
bucket = aws_s3_bucket.elb_logs.bucket
prefix = var.environment
# Logging is currently OFF
enabled = false
}
}

resource "aws_lb_target_group" "elb_target_group" {
name = "wikijump-tg-80-${var.environment}"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.wikijump_vpc.id
health_check {
enabled = false
path = "/heartbeat.php"
matcher = "200"
}
}

resource "aws_lb_listener" "elb_listener" {
load_balancer_arn = aws_lb.wikijump_elb.arn
port = 80
default_action {
type = "forward"
forward {
target_group {
arn = aws_lb_target_group.elb_target_group.arn
}
}
}
}

resource "aws_lb_listener_rule" "cloudfront_header_check" {
listener_arn = aws_lb_listener.elb_listener.arn
priority = 100

action {
type = "forward"
target_group_arn = aws_lb_target_group.elb_target_group.arn
}

condition {
http_header {
http_header_name = "X-CLOUDFRONT-WIKIJUMP-AUTH"
values = [var.cf_auth_token]
}
}
}

resource "aws_lb_listener_rule" "fallback" {
listener_arn = aws_lb_listener.elb_listener.arn
priority = 999

action {
type = "fixed-response"
fixed_response {
content_type = "text/plain"
message_body = "CloudFront Token Missing"
status_code = "400"
}
}

condition {
path_pattern {
values = ["*"]
}
}
}

# Security Group

resource "aws_security_group" "elb_sg" {
name = "elb_sg_${var.environment}"
description = "Allow 80 inbound"

ingress {
description = "HTTP"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Note we will add a header to invalidate requests from other than behind cloudfront.
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
# ELB

resource "aws_lb" "wikijump_elb" {
name = "wikijump-public-elb-${var.environment}"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.elb_sg.id]
subnet_mapping {
subnet_id = aws_subnet.elb_subnet.id
allocation_id = aws_eip.elb_eip.id
}

# Enable this once stable.
enable_deletion_protection = false

access_logs {
bucket = aws_s3_bucket.elb_logs.bucket
prefix = var.environment
# Logging is currently OFF
enabled = false
}
}

resource "aws_lb_target_group" "elb_target_group" {
name = "wikijump-tg-80-${var.environment}"
port = 80
protocol = "HTTP"
vpc_id = aws_vpc.wikijump_vpc.id
health_check {
enabled = false
path = "/heartbeat.php"
matcher = "200"
}
}

resource "aws_lb_listener" "elb_listener" {
load_balancer_arn = aws_lb.wikijump_elb.arn
port = 80
default_action {
type = "forward"
forward {
target_group {
arn = aws_lb_target_group.elb_target_group.arn
}
}
}
}

resource "aws_lb_listener_rule" "cloudfront_header_check" {
listener_arn = aws_lb_listener.elb_listener.arn
priority = 100

action {
type = "forward"
target_group_arn = aws_lb_target_group.elb_target_group.arn
}

condition {
http_header {
http_header_name = "X-CLOUDFRONT-WIKIJUMP-AUTH"
values = [var.cf_auth_token]
}
}
}

resource "aws_lb_listener_rule" "fallback" {
listener_arn = aws_lb_listener.elb_listener.arn
priority = 999

action {
type = "fixed-response"
fixed_response {
content_type = "text/plain"
message_body = "CloudFront Token Missing"
status_code = "400"
}
}

condition {
path_pattern {
values = ["*"]
}
}
}

# Security Group

resource "aws_security_group" "elb_sg" {
name = "elb_sg_${var.environment}"
description = "Allow 80 inbound"

ingress {
description = "HTTP"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"] # Note we will add a header to invalidate requests from other than behind cloudfront.
}

egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
24 changes: 12 additions & 12 deletions infra/terraform/prod/master.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}

# Configure the AWS Provider
provider "aws" {
region = "us-west-2"
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 3.0"
}
}
}

# Configure the AWS Provider
provider "aws" {
region = "us-west-2"
}
6 changes: 3 additions & 3 deletions infra/terraform/prod/s3.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resource "aws_s3_bucket" "elb_logs" {
bucket = "wikijump_elb_logs"
acl = "log-delivery-write"
resource "aws_s3_bucket" "elb_logs" {
bucket = "wikijump_elb_logs"
acl = "log-delivery-write"
}
Loading

0 comments on commit 80e1052

Please sign in to comment.