-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
89 lines (78 loc) · 2.28 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// Setup App Runner
module "example_app_runner" {
source = "terraform-aws-modules/app-runner/aws"
version = "~> 1.2.0"
service_name = "example_laravel_app"
auto_scaling_configurations = {
example_backend_autoscale = {
name = "example_application_autoscale"
max_concurrency = 100
max_size = 8
min_size = 1
}
}
# DNS
create_custom_domain_association = true
enable_www_subdomain = false
domain_name = "${var.app_sub_domain}.${data.aws_route53_zone.existing_route53_zone.name}"
instance_configuration = {
cpu = 1024
memory = 2048
}
source_configuration = {
authentication_configuration = {
access_role_arn = module.application_service_account.iam_role_arn
}
auto_deployments_enabled = true
image_repository = {
image_configuration = {
port = var.app_port
runtime_environment_variables = merge(
{ for env in var.app_environment_variables : env.name => env.value },
)
}
image_identifier = "${data.aws_caller_identity.current.account_id}.dkr.ecr.${data.aws_region.current.name}.amazonaws.com/${var.app_repository}:${var.app_image_tag}"
image_repository_type = "ECR"
}
}
# Network
# Connect App Runner to Private subnets and allow outbound traffic
create_vpc_connector = true
vpc_connector_subnets = data.aws_subnets.private.ids
vpc_connector_security_groups = [
aws_security_group.app_runner.id
]
network_configuration = {
ingress_configuration = {
is_publicly_accessible = true
}
egress_configuration = {
egress_type = "VPC"
}
}
# Monitoring
enable_observability_configuration = true
# IAM
create_access_iam_role = false
create_instance_iam_role = false
access_iam_role_name = module.application_service_account.iam_role_name
instance_iam_role_name = module.application_service_account.iam_role_name
# Health Check
health_check_configuration = {
protocol = "TCP"
path = "/"
healthy_threshold = 1
unhealthy_threshold = 5
interval = 10
timeout = 5
}
tags = {
ManagedBy = "Terraform"
}
depends_on = [
data.aws_subnets.private,
module.iam_policy,
module.application_service_account,
data.aws_vpc.default
]
}