diff --git a/.gitignore b/.gitignore index 4c23bf5..109565f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ vars.yaml -*.versatiles \ No newline at end of file +*.versatiles +.terraform/ +*.tfvars +ToDo.md \ No newline at end of file diff --git a/README.md b/README.md index 4aeb700..41c7c6d 100644 --- a/README.md +++ b/README.md @@ -51,3 +51,17 @@ Push the app: `CF_DOCKER_PASSWORD= cf push --vars-file `. diff --git a/terraform/.tfvars.example b/terraform/.tfvars.example new file mode 100644 index 0000000..b3a24a2 --- /dev/null +++ b/terraform/.tfvars.example @@ -0,0 +1,11 @@ +project_id = "" +service_account_key_path = "" +cf_user = "" +cf_password = "" +tiles_url = ".object.storage.eu01.onstackit.cloud/osm.versatiles>" +docker_image = "" +docker_username = "" +docker_password = "" +cf_app_name = "" +cf_org_name = "" +cf_space_name = "" \ No newline at end of file diff --git a/terraform/main.tf b/terraform/main.tf new file mode 100644 index 0000000..b7a8957 --- /dev/null +++ b/terraform/main.tf @@ -0,0 +1,27 @@ +data "cloudfoundry_org" "org" { + name = var.cf_org_name +} + +data "cloudfoundry_space" "space" { + name = var.cf_space_name + org = data.cloudfoundry_org.org.id +} + +resource "cloudfoundry_app" "versatiles" { + name = var.cf_app_name + space_name = data.cloudfoundry_space.space.name + org_name = data.cloudfoundry_org.org.name + memory = "2G" + disk_quota = "2G" + instances = 1 + command = "versatiles serve -p $PORT -s frontend-dev.br.tar ${var.tiles_url}" + health_check_type = "http" + health_check_http_endpoint = "/" + docker_image = var.docker_image + random_route = true + strategy = "rolling" + docker_credentials = { + username = var.docker_username + password = var.docker_password + } +} diff --git a/terraform/outputs.tf b/terraform/outputs.tf new file mode 100644 index 0000000..94d3c0d --- /dev/null +++ b/terraform/outputs.tf @@ -0,0 +1,3 @@ +output "app_url" { + value = cloudfoundry_app.versatiles.routes +} \ No newline at end of file diff --git a/terraform/provider.tf b/terraform/provider.tf new file mode 100644 index 0000000..4241340 --- /dev/null +++ b/terraform/provider.tf @@ -0,0 +1,22 @@ +terraform { + required_providers { + stackit = { + source = "stackitcloud/stackit" + version = ">= 0.62.0" + } + cloudfoundry = { + source = "cloudfoundry/cloudfoundry" + version = ">= 1.8.0" + } + } +} + +provider "stackit" { + service_account_key_path = var.service_account_key_path +} + +provider "cloudfoundry" { + api_url = "https://api.system.01.cf.eu01.stackit.cloud" + user = var.cf_user + password = var.cf_password +} \ No newline at end of file diff --git a/terraform/variables.tf b/terraform/variables.tf new file mode 100644 index 0000000..43c1ec5 --- /dev/null +++ b/terraform/variables.tf @@ -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." +}