-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathmain.tf
155 lines (147 loc) · 3.6 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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
terraform {
required_providers {
qovery = {
source = "qovery/qovery"
}
}
}
provider "qovery" {
token = var.qovery_access_token
}
resource "qovery_aws_credentials" "my_aws_creds" {
organization_id = var.qovery_organization_id
name = "My AWS Creds"
access_key_id = var.aws_access_key_id
secret_access_key = var.aws_secret_access_key
}
resource "qovery_cluster" "my_cluster" {
organization_id = var.qovery_organization_id
credentials_id = qovery_aws_credentials.my_aws_creds.id
name = "Demo cluster"
description = "Terraform demo cluster"
cloud_provider = "AWS"
region = "us-east-2"
instance_type = "t3a.medium"
min_running_nodes = 3
max_running_nodes = 4
}
resource "qovery_project" "my_project" {
organization_id = var.qovery_organization_id
name = "Strapi V4"
depends_on = [
qovery_cluster.my_cluster
]
}
resource "qovery_environment" "production" {
project_id = qovery_project.my_project.id
name = "production"
mode = "PRODUCTION"
cluster_id = qovery_cluster.my_cluster.id
}
resource "qovery_database" "my_psql_database" {
environment_id = qovery_environment.production.id
name = "strapi db"
type = "POSTGRESQL"
version = "13"
mode = "MANAGED" # Use AWS RDS for PostgreSQL (backup and PITR automatically configured by Qovery)
storage = 10 # 10GB of storage
accessibility = "PRIVATE" # do not make it publicly accessible
}
resource "qovery_application" "strapi_app" {
environment_id = qovery_environment.production.id
name = "strapi app"
cpu = 1000
memory = 512
git_repository = {
url = "https://github.com/evoxmusic/strapi-v4.git"
branch = "main"
root_path = "/"
}
build_mode = "DOCKER"
dockerfile_path = "Dockerfile"
min_running_instances = 1
max_running_instances = 1
ports = [
{
internal_port = 1337
external_port = 443
protocol = "HTTP"
publicly_accessible = true
is_default = true
}
]
environment_variables = [
{
key = "PORT"
value = "1337"
},
{
key = "HOST"
value = "0.0.0.0"
},
{
key = "DATABASE_HOST"
value = qovery_database.my_psql_database.internal_host
},
{
key = "DATABASE_PORT"
value = qovery_database.my_psql_database.port
},
{
key = "DATABASE_USERNAME"
value = qovery_database.my_psql_database.login
},
{
key = "DATABASE_NAME"
value = "postgres"
},
]
secrets = [
{
key = "ADMIN_JWT_SECRET"
value = var.strapi_admin_jwt_secret
},
{
key = "API_TOKEN_SALT"
value = var.strapi_api_token_salt
},
{
key = "APP_KEYS"
value = var.strapi_app_keys
},
{
key = "DATABASE_PASSWORD"
value = qovery_database.my_psql_database.password
}
]
healthchecks = {
readiness_probe = {
type = {
http = {
scheme = "HTTP"
port = 1337
path = "/"
}
}
initial_delay_seconds = 30
period_seconds = 10
timeout_seconds = 10
success_threshold = 1
failure_threshold = 3
}
liveness_probe = {
type = {
http = {
scheme = "HTTP"
port = 1337
path = "/"
}
}
initial_delay_seconds = 30
period_seconds = 10
timeout_seconds = 10
success_threshold = 1
failure_threshold = 3
}
}
}