forked from scpwiki/wikijump
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request scpwiki#45 from scpwiki/unix-newlines
Convert to UNIX newlines
- Loading branch information
Showing
1,351 changed files
with
147,961 additions
and
147,961 deletions.
There are no files selected for viewing
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
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. | ||
|
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
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 | ||
} | ||
} |
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
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 | ||
} | ||
} |
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
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"] | ||
} | ||
} |
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
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" | ||
} |
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
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" | ||
} |
Oops, something went wrong.