From 04cb3c8ad56247e2ef186a2a785fba5b096a2849 Mon Sep 17 00:00:00 2001 From: Karl Cardenas <29551334+karl-cardenas-coding@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:54:58 -0700 Subject: [PATCH] fix: updated hello-universe-tutorial for PDE (#45) * fix: updated hello-universe-tutorial for PDE * chore: remove tfvars --- .gitignore | 1 + terraform/hello-universe-tf/README.md | 70 +++++++++---------- terraform/hello-universe-tf/application.tf | 12 ++-- terraform/hello-universe-tf/data.tf | 6 +- terraform/hello-universe-tf/inputs.tf | 9 ++- terraform/hello-universe-tf/provider.tf | 4 +- .../hello-universe-tf/virutal-clusters.tf | 6 +- 7 files changed, 55 insertions(+), 53 deletions(-) diff --git a/.gitignore b/.gitignore index 9235d96..db0ecd1 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ *.tfstate *.tfstate.* *.terraform.lock.hcl +*.terraform.tfvars # Node Modules diff --git a/terraform/hello-universe-tf/README.md b/terraform/hello-universe-tf/README.md index 90e34aa..039c19c 100644 --- a/terraform/hello-universe-tf/README.md +++ b/terraform/hello-universe-tf/README.md @@ -5,15 +5,15 @@ The code is intended to be used with the tutorial and as a result may not execut ## Requirements -| Name | Version | -|------|---------| -| [spectrocloud](#requirement\_spectrocloud) | >= 0.11.1 | +| Name | Version | +| --------------------------------------------------------------------------------- | --------- | +| [spectrocloud](#requirement_spectrocloud) | >= 0.21.6 | ## Providers -| Name | Version | -|------|---------| -| [spectrocloud](#provider\_spectrocloud) | 0.11.1 | +| Name | Version | +| --------------------------------------------------------------------------- | ------- | +| [spectrocloud](#provider_spectrocloud) | 0.21.6 | ## Modules @@ -21,38 +21,38 @@ No modules. ## Resources -| Name | Type | -|------|------| -| [spectrocloud_application.scenario-1](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application) | resource | -| [spectrocloud_application.scenario-2](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application) | resource | -| [spectrocloud_application_profile.hello-universe-complete](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application_profile) | resource | -| [spectrocloud_application_profile.hello-universe-ui](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application_profile) | resource | -| [spectrocloud_virtual_cluster.cluster-1](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/virtual_cluster) | resource | -| [spectrocloud_virtual_cluster.cluster-2](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/virtual_cluster) | resource | -| [spectrocloud_cluster_group.beehive](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster_group) | data source | -| [spectrocloud_pack_simple.container_pack](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack_simple) | data source | -| [spectrocloud_pack_simple.postgres_service](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack_simple) | data source | -| [spectrocloud_registry.public_registry](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/registry) | data source | +| Name | Type | +| ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------- | +| [spectrocloud_application.scenario-1](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application) | resource | +| [spectrocloud_application.scenario-2](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application) | resource | +| [spectrocloud_application_profile.hello-universe-complete](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application_profile) | resource | +| [spectrocloud_application_profile.hello-universe-ui](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/application_profile) | resource | +| [spectrocloud_virtual_cluster.cluster-1](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/virtual_cluster) | resource | +| [spectrocloud_virtual_cluster.cluster-2](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/resources/virtual_cluster) | resource | +| [spectrocloud_cluster_group.cluster-group](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/cluster_group) | data source | +| [spectrocloud_pack_simple.container_pack](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack_simple) | data source | +| [spectrocloud_pack_simple.postgres_service](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/pack_simple) | data source | +| [spectrocloud_registry.public_registry](https://registry.terraform.io/providers/spectrocloud/spectrocloud/latest/docs/data-sources/registry) | data source | ## Inputs -| Name | Description | Type | Default | Required | -|------|-------------|------|---------|:--------:| -| [cluster-group-name](#input\_cluster-group-name) | The name of the cluster group to use for the virtual cluster | `string` | `"beehive"` | no | -| [database-name](#input\_database-name) | The name of the database | `string` | `"counter"` | no | -| [database-ssl-mode](#input\_database-ssl-mode) | The SSL mode to use for the database | `string` | `"require"` | no | -| [database-user](#input\_database-user) | The name of the database user | `string` | `"pguser"` | no | -| [database-version](#input\_database-version) | The version of Postgres to use | `string` | `"14"` | no | -| [enable-second-scenario](#input\_enable-second-scenario) | Whether to enable the second scenario | `bool` | `false` | no | -| [multiple\_container\_images](#input\_multiple\_container\_images) | The name of the container images to use for the virtual cluster in a multiple scenario | `map(string)` |
{
"api": "ghcr.io/spectrocloud/hello-universe-api:1.0.8",
"ui": "ghcr.io/spectrocloud/hello-universe:1.0.12"
}
| no | -| [scenario-one-cluster-name](#input\_scenario-one-cluster-name) | The name of the cluster to use for the virtual cluster | `string` | `"cluster-1"` | no | -| [scenario-two-cluster-name](#input\_scenario-two-cluster-name) | The name of the cluster to use for the virtual cluster in the second scenario | `string` | `"cluster-2"` | no | -| [single-container-image](#input\_single-container-image) | The name of the container image to use for the virtual cluster in a single scenario | `string` | `"ghcr.io/spectrocloud/hello-universe:1.0.12"` | no | -| [tags](#input\_tags) | The default tags to apply to Palette resources | `list(string)` |
[
"spectro-cloud-education",
"app:hello-universe",
"repository:spectrocloud/tutorials/",
"terraform_managed:true"
]
| no | -| [token](#input\_token) | The anonymous token to use for the Spectro Cloud API | `string` | `null` | no | +| Name | Description | Type | Default | Required | +| ------------------------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------- | -------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :------: | +| [cluster-group-name](#input_cluster-group-name) | The name of the cluster group to use for the virtual cluster | `string` | n/a | yes | +| [database-name](#input_database-name) | The name of the database | `string` | `"counter"` | no | +| [database-ssl-mode](#input_database-ssl-mode) | The SSL mode to use for the database | `string` | `"require"` | no | +| [database-user](#input_database-user) | The name of the database user | `string` | `"pguser"` | no | +| [database-version](#input_database-version) | The version of Postgres to use | `string` | `"14"` | no | +| [enable-second-scenario](#input_enable-second-scenario) | Whether to enable the second scenario | `bool` | `false` | no | +| [multiple_container_images](#input_multiple_container_images) | The name of the container images to use for the virtual cluster in a multiple scenario | `map(string)` |
{
"api": "ghcr.io/spectrocloud/hello-universe-api:1.0.8",
"ui": "ghcr.io/spectrocloud/hello-universe:1.0.12"
}
| no | +| [scenario-one-cluster-name](#input_scenario-one-cluster-name) | The name of the cluster to use for the virtual cluster | `string` | `"cluster-1"` | no | +| [scenario-two-cluster-name](#input_scenario-two-cluster-name) | The name of the cluster to use for the virtual cluster in the second scenario | `string` | `"cluster-2"` | no | +| [single-container-image](#input_single-container-image) | The name of the container image to use for the virtual cluster in a single scenario | `string` | `"ghcr.io/spectrocloud/hello-universe:1.0.12"` | no | +| [tags](#input_tags) | The default tags to apply to Palette resources | `list(string)` |
[
"spectro-cloud-education",
"app:hello-universe",
"repository:spectrocloud/tutorials/",
"terraform_managed:true",
"tutorial:hello-universe-tf"
]
| no | +| [token](#input_token) | The anonymous token to use for the Spectro Cloud API | `string` | `"931A3B02-8DCC-543F-A1B2-69423D1A0B94"` | no | ## Outputs -| Name | Description | -|------|-------------| -| [Advisory](#output\_Advisory) | n/a | +| Name | Description | +| ----------------------------------------------------------- | ----------- | +| [Advisory](#output_Advisory) | n/a | diff --git a/terraform/hello-universe-tf/application.tf b/terraform/hello-universe-tf/application.tf index 1d2e873..2afc84e 100644 --- a/terraform/hello-universe-tf/application.tf +++ b/terraform/hello-universe-tf/application.tf @@ -9,8 +9,9 @@ resource "spectrocloud_application" "scenario-1" { application_profile_uid = spectrocloud_application_profile.hello-universe-ui.id config { - cluster_name = spectrocloud_virtual_cluster.cluster-1.name - cluster_uid = spectrocloud_virtual_cluster.cluster-1.id + cluster_name = spectrocloud_virtual_cluster.cluster-1.name + cluster_uid = spectrocloud_virtual_cluster.cluster-1.id + cluster_context = "project" } tags = concat(var.tags, ["scenario-1"]) @@ -30,8 +31,9 @@ resource "spectrocloud_application" "scenario-2" { application_profile_uid = spectrocloud_application_profile.hello-universe-complete[0].id config { - cluster_name = spectrocloud_virtual_cluster.cluster-2[0].name - cluster_uid = spectrocloud_virtual_cluster.cluster-2[0].id + cluster_name = spectrocloud_virtual_cluster.cluster-2[0].name + cluster_uid = spectrocloud_virtual_cluster.cluster-2[0].id + cluster_context = "project" } tags = concat(var.tags, ["scenario-2"]) @@ -39,4 +41,4 @@ resource "spectrocloud_application" "scenario-2" { create = "10m" update = "10m" } -} \ No newline at end of file +} diff --git a/terraform/hello-universe-tf/data.tf b/terraform/hello-universe-tf/data.tf index 7732089..772f053 100644 --- a/terraform/hello-universe-tf/data.tf +++ b/terraform/hello-universe-tf/data.tf @@ -1,9 +1,9 @@ # Copyright (c) Spectro Cloud # SPDX-License-Identifier: Apache-2.0 -data "spectrocloud_cluster_group" "beehive" { +data "spectrocloud_cluster_group" "cluster-group" { name = var.cluster-group-name - context = "system" + context = "project" } data "spectrocloud_registry" "public_registry" { @@ -22,4 +22,4 @@ data "spectrocloud_pack_simple" "postgres_service" { type = "operator-instance" version = "1.8.2" registry_uid = data.spectrocloud_registry.public_registry.id -} \ No newline at end of file +} diff --git a/terraform/hello-universe-tf/inputs.tf b/terraform/hello-universe-tf/inputs.tf index d27240d..440adc5 100644 --- a/terraform/hello-universe-tf/inputs.tf +++ b/terraform/hello-universe-tf/inputs.tf @@ -3,7 +3,6 @@ variable "cluster-group-name" { type = string - default = "beehive" description = "The name of the cluster group to use for the virtual cluster" } @@ -22,15 +21,15 @@ variable "scenario-two-cluster-name" { variable "single-container-image" { type = string description = "The name of the container image to use for the virtual cluster in a single scenario" - default = "ghcr.io/spectrocloud/hello-universe:1.0.12" + default = "ghcr.io/spectrocloud/hello-universe:1.1.3" } variable "multiple_container_images" { type = map(string) description = "The name of the container images to use for the virtual cluster in a multiple scenario" default = { - ui = "ghcr.io/spectrocloud/hello-universe:1.0.12" - api = "ghcr.io/spectrocloud/hello-universe-api:1.0.8" + ui = "ghcr.io/spectrocloud/hello-universe:1.1.3" + api = "ghcr.io/spectrocloud/hello-universe-api:1.0.12" } } @@ -80,4 +79,4 @@ variable "tags" { "terraform_managed:true", "tutorial:hello-universe-tf" ] -} \ No newline at end of file +} diff --git a/terraform/hello-universe-tf/provider.tf b/terraform/hello-universe-tf/provider.tf index d334221..70a41c4 100644 --- a/terraform/hello-universe-tf/provider.tf +++ b/terraform/hello-universe-tf/provider.tf @@ -4,7 +4,7 @@ terraform { required_providers { spectrocloud = { - version = ">= 0.11.1" + version = ">= 0.21.6" source = "spectrocloud/spectrocloud" } } @@ -13,4 +13,4 @@ terraform { provider "spectrocloud" { // API key set though the environment variable SPECTROCLOUD_APIKEY project_name = "Default" -} \ No newline at end of file +} diff --git a/terraform/hello-universe-tf/virutal-clusters.tf b/terraform/hello-universe-tf/virutal-clusters.tf index 888ead1..b8f1f34 100644 --- a/terraform/hello-universe-tf/virutal-clusters.tf +++ b/terraform/hello-universe-tf/virutal-clusters.tf @@ -6,7 +6,7 @@ # ########################################## resource "spectrocloud_virtual_cluster" "cluster-1" { name = var.scenario-one-cluster-name - cluster_group_uid = data.spectrocloud_cluster_group.beehive.id + cluster_group_uid = data.spectrocloud_cluster_group.cluster-group.id resources { max_cpu = 4 @@ -33,7 +33,7 @@ resource "spectrocloud_virtual_cluster" "cluster-2" { count = var.enable-second-scenario == true ? 1 : 0 name = var.scenario-two-cluster-name - cluster_group_uid = data.spectrocloud_cluster_group.beehive.id + cluster_group_uid = data.spectrocloud_cluster_group.cluster-group.id resources { max_cpu = 8 @@ -50,4 +50,4 @@ resource "spectrocloud_virtual_cluster" "cluster-2" { create = "15m" delete = "15m" } -} \ No newline at end of file +}