1+ resource "aws_apprunner_vpc_connector" "this" {
2+ vpc_connector_name = var. name
3+ subnets = var. subnet_list
4+ security_groups = [aws_security_group . allow_elasicache . id ]
5+ }
6+
7+ resource "aws_apprunner_auto_scaling_configuration_version" "this" {
8+ auto_scaling_configuration_name = var. name
9+
10+ max_concurrency = var. max_concurrency
11+ max_size = var. max_size
12+ min_size = var. min_size
13+
14+ tags = {
15+ Name = var.name
16+ }
17+ }
18+
19+ resource "aws_apprunner_service" "this" {
20+ service_name = var. name
21+
22+ source_configuration {
23+ auto_deployments_enabled = var. auto_deployments_enabled
24+ authentication_configuration {
25+ access_role_arn = aws_iam_role. this . arn
26+ }
27+ image_repository {
28+ image_configuration {
29+ port = var. app_port
30+ runtime_environment_variables = {
31+ " REDIS_HOST" : aws_elasticache_replication_group.this.primary_endpoint_address
32+ " REDIS_PORT" : var.elasticache_port
33+ }
34+ }
35+ image_identifier = " ${ aws_ecr_repository . this . repository_url } :${ var . app_docker_tag } "
36+ image_repository_type = var. image_repository_type
37+ }
38+ }
39+
40+ instance_configuration {
41+ cpu = var. cpu
42+ memory = var. memory
43+ }
44+
45+ health_check_configuration {
46+ healthy_threshold = var. healthy_threshold
47+ interval = var. healthcheck_interval
48+ path = var. healthcheck_path
49+ protocol = var. healthcheck_protocol
50+ timeout = var. healthcheck_timeout
51+ unhealthy_threshold = var. unhealthy_threshold
52+ }
53+
54+ network_configuration {
55+ egress_configuration {
56+ egress_type = " VPC"
57+ vpc_connector_arn = aws_apprunner_vpc_connector. this . arn
58+ }
59+ }
60+
61+ depends_on = [
62+ aws_elasticache_replication_group . this ,
63+ null_resource. this
64+ ]
65+ }
0 commit comments