forked from cn-terraform/terraform-aws-sonarqube
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
84 lines (80 loc) · 2.55 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
#------------------------------------------------------------------------------
# Variables
#------------------------------------------------------------------------------
locals {
sonar_postgres_sql_db_version = "11.6"
sonar_postgre_sql_port = 5432
sonar_postgre_sql_db = "sonar"
sonar_db_instance_size = "db.r4.large"
sonar_db_name = "sonar"
sonar_db_username = "sonar"
sonar_db_password = "${var.name_preffix}-sonar-pass"
}
#------------------------------------------------------------------------------
# AWS Cloudwatch Logs
#------------------------------------------------------------------------------
module aws_cw_logs {
source = "cn-terraform/cloudwatch-logs/aws"
version = "1.0.6"
# source = "../terraform-aws-cloudwatch-logs"
logs_path = "/ecs/service/${var.name_preffix}-sonar"
}
#------------------------------------------------------------------------------
# ECS Fargate Service
#------------------------------------------------------------------------------
module "ecs_fargate" {
source = "cn-terraform/ecs-fargate/aws"
version = "2.0.17"
# source = "../terraform-aws-ecs-fargate"
name_preffix = "${var.name_preffix}-sonar"
vpc_id = var.vpc_id
public_subnets_ids = var.public_subnets_ids
private_subnets_ids = var.private_subnets_ids
container_name = "${var.name_preffix}-sonar"
container_image = "sonarqube"
container_cpu = 4096
container_memory = 8192
container_memory_reservation = 4096
lb_http_ports = [9000]
lb_https_ports = []
command = [
"-Dsonar.search.javaAdditionalOpts=-Dnode.store.allow_mmapfs=false"
]
ulimits = [
{
"name" : "nofile",
"softLimit" : 65535,
"hardLimit" : 65535
}
]
port_mappings = [
{
containerPort = 9000
hostPort = 9000
protocol = "tcp"
}
]
environment = [
{
name = "SONAR_JDBC_USERNAME"
value = local.sonar_db_username
},
{
name = "SONAR_JDBC_PASSWORD"
value = local.sonar_db_password
},
{
name = "SONAR_JDBC_URL"
value = "jdbc:postgresql://${aws_db_instance.this.endpoint}/${local.sonar_db_name}"
},
]
log_configuration = {
logDriver = "awslogs"
options = {
"awslogs-region" = var.region
"awslogs-group" = "/ecs/service/${var.name_preffix}-sonar"
"awslogs-stream-prefix" = "ecs"
}
secretOptions = null
}
}