Skip to content

Commit f668c7a

Browse files
authored
Merge pull request #41 from hazelops/core-438-core-439
[CORE-438 CORE-439] added test examples
2 parents 285f5b6 + 5118bb6 commit f668c7a

File tree

25 files changed

+771
-205
lines changed

25 files changed

+771
-205
lines changed

examples/complete-tcp-app/main.tf

Lines changed: 147 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,147 @@
1+
# Versions
2+
terraform {
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
}
7+
}
8+
required_version = ">= 1.0"
9+
}
10+
11+
# Data
12+
data "aws_route53_zone" "root" {
13+
name = "${var.root_domain_name}."
14+
private_zone = false
15+
}
16+
17+
# Main
18+
module "vpc" {
19+
source = "registry.terraform.io/terraform-aws-modules/vpc/aws"
20+
version = "~> 3.0"
21+
22+
name = "${var.env}-vpc"
23+
cidr = "10.0.0.0/16"
24+
25+
azs = [
26+
"${var.aws_region}a",
27+
"${var.aws_region}b"
28+
]
29+
public_subnets = [
30+
"10.0.10.0/23",
31+
"10.0.12.0/23"
32+
]
33+
34+
private_subnets = [
35+
"10.0.20.0/23"
36+
]
37+
manage_default_network_acl = true
38+
default_network_acl_name = "${var.env}-${var.namespace}"
39+
}
40+
resource "aws_security_group" "default_permissive" {
41+
name = "${var.env}-default-permissive"
42+
vpc_id = module.vpc.vpc_id
43+
44+
ingress {
45+
protocol = -1
46+
from_port = 0
47+
to_port = 0
48+
cidr_blocks = [
49+
"0.0.0.0/0"
50+
]
51+
}
52+
53+
egress {
54+
protocol = -1
55+
from_port = 0
56+
to_port = 0
57+
cidr_blocks = [
58+
"0.0.0.0/0"
59+
]
60+
}
61+
62+
}
63+
64+
resource "aws_route53_record" "env_ns_record" {
65+
zone_id = data.aws_route53_zone.root.id
66+
name = "${var.env}.${var.root_domain_name}"
67+
type = "NS"
68+
ttl = "60"
69+
records = aws_route53_zone.env_domain.name_servers
70+
}
71+
72+
resource "aws_route53_zone" "env_domain" {
73+
name = "${var.env}.${var.root_domain_name}"
74+
}
75+
76+
module "env_acm" {
77+
source = "registry.terraform.io/terraform-aws-modules/acm/aws"
78+
version = "~> 4.0"
79+
80+
domain_name = "${var.env}.${var.root_domain_name}"
81+
82+
subject_alternative_names = [
83+
"*.${var.env}.${var.root_domain_name}"
84+
]
85+
86+
zone_id = aws_route53_zone.env_domain.id
87+
88+
tags = {
89+
Name = "${var.env}.${var.root_domain_name}"
90+
}
91+
}
92+
93+
module "ecs" {
94+
source = "registry.terraform.io/terraform-aws-modules/ecs/aws"
95+
version = "~> 4.0"
96+
cluster_name = "${var.env}-${var.namespace}"
97+
}
98+
99+
module "tcp_app" {
100+
source = "../.."
101+
102+
name = "tcpapp"
103+
app_type = "tcp-app"
104+
env = var.env
105+
namespace = var.namespace
106+
107+
# Containers
108+
ecs_cluster_name = module.ecs.cluster_name
109+
docker_registry = var.docker_registry
110+
docker_image_tag = var.docker_image_tag
111+
112+
# Load Balancer
113+
public = true
114+
https_enabled = true
115+
tls_cert_arn = local.tls_cert_arn
116+
117+
port_mappings = [
118+
{
119+
container_port = 4442
120+
host_port = 4442
121+
},
122+
{
123+
container_port = 4443
124+
host_port = 4443
125+
},
126+
{
127+
container_port = 4444
128+
host_port = 4444
129+
tls = true
130+
}
131+
]
132+
133+
# Network
134+
vpc_id = module.vpc.vpc_id
135+
public_subnets = module.vpc.public_subnets
136+
private_subnets = module.vpc.private_subnets
137+
security_groups = [aws_security_group.default_permissive.id]
138+
root_domain_name = var.root_domain_name
139+
zone_id = aws_route53_zone.env_domain.id
140+
141+
# Environment variables
142+
app_secrets = [
143+
]
144+
environment = {
145+
}
146+
}
147+

examples/complete-tcp-app/output.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
output "vpc_cidr" {
2+
value = module.vpc.vpc_cidr_block
3+
}
4+
5+
output "private_subnet_cidrs" {
6+
value = module.vpc.private_subnets_cidr_blocks
7+
}
8+
9+
output "cloudwatch_log_group" {
10+
value = module.tcp_app.cloudwatch_log_group
11+
}
12+
13+
output "ecs_cluster_name" {
14+
value = module.ecs.cluster_name
15+
}
16+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
locals {
2+
tls_cert_arn = length(module.env_acm.acm_certificate_arn) > 0 ? module.env_acm.acm_certificate_arn : null
3+
}
4+
5+
variable "env" {}
6+
variable "namespace" {}
7+
variable "aws_profile" {}
8+
variable "aws_region" {}
9+
variable "docker_registry" {}
10+
variable "docker_image_tag" {}
11+
variable "root_domain_name" {}

examples/complete-web-windows/main-windows.tf

Lines changed: 0 additions & 43 deletions
This file was deleted.

examples/complete-web-windows/main.tf

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
# Versions
2+
terraform {
3+
required_providers {
4+
aws = {
5+
source = "hashicorp/aws"
6+
}
7+
}
8+
required_version = ">= 1.0"
9+
}
10+
11+
# Data
12+
data "aws_route53_zone" "root" {
13+
name = "${var.root_domain_name}."
14+
private_zone = false
15+
}
16+
17+
# Main
18+
module "vpc" {
19+
source = "registry.terraform.io/terraform-aws-modules/vpc/aws"
20+
version = "~> 3.0"
21+
22+
name = "${var.env}-vpc"
23+
cidr = "10.0.0.0/16"
24+
25+
azs = [
26+
"${var.aws_region}a",
27+
"${var.aws_region}b"
28+
]
29+
public_subnets = [
30+
"10.0.10.0/23",
31+
"10.0.12.0/23"
32+
]
33+
34+
private_subnets = [
35+
"10.0.20.0/23"
36+
]
37+
manage_default_network_acl = true
38+
default_network_acl_name = "${var.env}-${var.namespace}"
39+
}
40+
resource "aws_security_group" "default_permissive" {
41+
name = "${var.env}-default-permissive"
42+
vpc_id = module.vpc.vpc_id
43+
44+
ingress {
45+
protocol = -1
46+
from_port = 0
47+
to_port = 0
48+
cidr_blocks = [
49+
"0.0.0.0/0"
50+
]
51+
}
52+
53+
egress {
54+
protocol = -1
55+
from_port = 0
56+
to_port = 0
57+
cidr_blocks = [
58+
"0.0.0.0/0"
59+
]
60+
}
61+
62+
}
63+
64+
resource "aws_route53_record" "env_ns_record" {
65+
zone_id = data.aws_route53_zone.root.id
66+
name = "${var.env}.${var.root_domain_name}"
67+
type = "NS"
68+
ttl = "60"
69+
records = aws_route53_zone.env_domain.name_servers
70+
}
71+
72+
resource "aws_route53_zone" "env_domain" {
73+
name = "${var.env}.${var.root_domain_name}"
74+
}
75+
76+
module "ecs" {
77+
source = "registry.terraform.io/terraform-aws-modules/ecs/aws"
78+
version = "~> 4.0"
79+
cluster_name = "${var.env}-${var.namespace}"
80+
}
81+
82+
module "web_complete" {
83+
source = "../.."
84+
85+
name = "app"
86+
app_type = "web"
87+
env = var.env
88+
namespace = var.namespace
89+
90+
# Containers
91+
cpu = 1024
92+
memory = 2048
93+
operating_system_family = "WINDOWS_SERVER_2019_CORE"
94+
ecs_cluster_name = module.ecs.cluster_name
95+
docker_registry = var.docker_registry
96+
docker_image_tag = var.docker_image_tag
97+
98+
# Load Balancer
99+
public = true
100+
https_enabled = false
101+
alb_health_check_path = "/"
102+
alb_security_groups = [aws_security_group.default_permissive.id]
103+
104+
# EFS settings
105+
efs_enabled = false
106+
efs_mount_point = "/mnt/efs"
107+
efs_root_directory = "/"
108+
109+
# Network
110+
vpc_id = module.vpc.vpc_id
111+
public_subnets = module.vpc.public_subnets
112+
private_subnets = module.vpc.private_subnets
113+
security_groups = [aws_security_group.default_permissive.id]
114+
root_domain_name = var.root_domain_name
115+
zone_id = aws_route53_zone.env_domain.id
116+
117+
# Environment variables
118+
app_secrets = [
119+
]
120+
environment = {
121+
}
122+
}
123+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
output "vpc_cidr" {
2+
value = module.vpc.vpc_cidr_block
3+
}
4+
5+
output "private_subnet_cidrs" {
6+
value = module.vpc.private_subnets_cidr_blocks
7+
}
8+
9+
output "cloudwatch_log_group" {
10+
value = module.web_complete.cloudwatch_log_group
11+
}
12+
13+
output "ecs_cluster_name" {
14+
value = module.ecs.cluster_name
15+
}
16+
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
variable "env" {}
2+
variable "namespace" {}
3+
variable "aws_profile" {}
4+
variable "aws_region" {}
5+
variable "docker_registry" {}
6+
variable "docker_image_tag" {}
7+
variable "root_domain_name" {}

examples/complete-web/data.tf

Lines changed: 0 additions & 7 deletions
This file was deleted.

0 commit comments

Comments
 (0)