Add terraform code
This commit is contained in:
parent
560cad1155
commit
e9a8c16327
4 changed files with 138 additions and 0 deletions
51
terraform/main.tf
Normal file
51
terraform/main.tf
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
# =========== STACKIT Resources ===========
|
||||
# data "stackit_dns_zone" "zone" {
|
||||
# project_id = var.project_id
|
||||
# name = trimsuffix(var.moodle_domain, ".")
|
||||
# }
|
||||
|
||||
# resource "stackit_dns_record_set" "moodle_cname" {
|
||||
# project_id = var.stackit_project_id
|
||||
# zone_id = data.stackit_dns_zone.zone.id
|
||||
# name = var.moodle_domain
|
||||
# type = "CNAME"
|
||||
# ttl = 300
|
||||
# records = ["console.apps.01.cf.eu01.stackit.cloud."]
|
||||
# }
|
||||
|
||||
# resource "stackit_object_storage_bucket" "moodle_bucket" {
|
||||
# project_id = var.stackit_project_id
|
||||
# name = var.s3_bucket_name
|
||||
# }
|
||||
|
||||
# resource "stackit_object_storage_credential" "s3_credentials" {
|
||||
# project_id = var.stackit_project_id
|
||||
# }
|
||||
|
||||
# =========== Cloud Foundry Resources ===========
|
||||
resource "cloudfoundry_org" "org" {
|
||||
name = var.cf_org_name
|
||||
}
|
||||
|
||||
resource "cloudfoundry_space" "space" {
|
||||
name = var.cf_space_name
|
||||
org = cloudfoundry_org.org.id
|
||||
}
|
||||
|
||||
resource "cloudfoundry_app" "versatiles" {
|
||||
name = var.cf_app_name
|
||||
space = cloudfoundry_space.space.id
|
||||
memory = "1G"
|
||||
disk_quota = "1G"
|
||||
instances = 1
|
||||
command = "versatiles serve -p $PORT -s frontend-dev.br.tar ${var.tiles_url}"
|
||||
timeout = 10
|
||||
health_check_type = "http"
|
||||
health_check_http_endpoint = "/"
|
||||
docker_image = var.docker_image
|
||||
docker_credentials = {
|
||||
docker_username = var.docker_username
|
||||
docker_password = var.docker_password
|
||||
}
|
||||
strategy = "rolling"
|
||||
}
|
||||
3
terraform/outputs.tf
Normal file
3
terraform/outputs.tf
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
output "app_url" {
|
||||
value = cloudfoundry_app.versatiles.routes
|
||||
}
|
||||
26
terraform/provider.tf
Normal file
26
terraform/provider.tf
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
terraform {
|
||||
required_providers {
|
||||
stackit = {
|
||||
source = "stackitcloud/stackit"
|
||||
version = ">= 0.62.0"
|
||||
}
|
||||
cloudfoundry = {
|
||||
source = "cloudfoundry-community/cloudfoundry"
|
||||
version = ">= 0.53.0"
|
||||
}
|
||||
local = {
|
||||
source = "hashicorp/local"
|
||||
version = ">= 2.4.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "stackit" {
|
||||
service_account_key_path = var.service_account_key_path
|
||||
}
|
||||
|
||||
provider "cloudfoundry" {
|
||||
api_url = "https://api.cf.eu01.stackit.cloud"
|
||||
user = var.cf_user
|
||||
password = var.cf_password
|
||||
}
|
||||
58
terraform/variables.tf
Normal file
58
terraform/variables.tf
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
variable "project_id" {
|
||||
type = string
|
||||
description = "The id of your STACKIT project."
|
||||
}
|
||||
|
||||
variable "service_account_key_path" {
|
||||
type = string
|
||||
description = "Path to your service account key."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "cf_user" {
|
||||
type = string
|
||||
description = "Username (e-mail) of Cloud Foundry user."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "cf_password" {
|
||||
type = string
|
||||
description = "Password of Cloud Foundry user."
|
||||
sensitive = true
|
||||
}
|
||||
|
||||
variable "cf_org_name" {
|
||||
type = string
|
||||
description = "Name of the Cloud Foundry organization."
|
||||
}
|
||||
|
||||
variable "cf_space_name" {
|
||||
type = string
|
||||
description = "Name of the Cloud Foundry space."
|
||||
default = "dev"
|
||||
}
|
||||
|
||||
variable "cf_app_name" {
|
||||
type = string
|
||||
default = "versatiles"
|
||||
}
|
||||
|
||||
variable "tiles_url" {
|
||||
type = string
|
||||
description = "The url of the tiles file."
|
||||
}
|
||||
|
||||
variable "docker_image" {
|
||||
type = string
|
||||
description = "Application image."
|
||||
}
|
||||
|
||||
variable "docker_username" {
|
||||
type = string
|
||||
description = "Username for private docker registry."
|
||||
}
|
||||
|
||||
variable "docker_password" {
|
||||
type = string
|
||||
description = "Password for private docker registry."
|
||||
}
|
||||
Loading…
Reference in a new issue