From c9a04266c79e5baadef102385a23ea306f852f7b Mon Sep 17 00:00:00 2001 From: "Kwiatosz, Krzysztof" Date: Fri, 4 Oct 2024 13:33:27 +0200 Subject: [PATCH 1/7] Document module usage --- README.md | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 109 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0577cf3..6483797 100644 --- a/README.md +++ b/README.md @@ -43,8 +43,115 @@ Terraform module for Kyma uses the following terraform [providers](provider.tf), | cluster_id | cluster ID of the created Kyma environment | | domain | domain of the created Kyma environment | -## Running `terraform-sap-kyma-on-btp` module + +## How to use terraform module for kyma + +Please refer to the included usage [examples](./examples/). + +In order to use the module you need to create a dedicated folder in your project repository (for example `tf`). You will need to create a main terraform file (`main.tf`) and `.tfvars` file. This will become the so called root terraform module where the module for kyma can be used as a child module. + +>> INFO: Read more about terraform modules in the [documentation form hasicorp](https://developer.hashicorp.com/terraform/language/modules) + +``` +. ++-- tf +| +-- main.tf +| +-- .tfvars +``` + +In the `.tfvars` file you will need to ensure [input parameters](#input-variables-tf-vars). Please refer to the [template](examples/kyma-on-btp-new-sa/.tfvars-template) + +For example: +```tf +BTP_BOT_USER = "..." +BTP_BOT_PASSWORD = "..." +BTP_GLOBAL_ACCOUNT = "..." +BTP_BACKEND_URL = "https://cpcli.cf.sap.hana.ondemand.com" +BTP_CUSTOM_IAS_TENANT = "my-tenant" +BTP_CUSTOM_IAS_DOMAIN = "accounts400.ondemand.com" +BTP_NEW_SUBACCOUNT_NAME = "kyma-runtime-subaccount" +BTP_NEW_SUBACCOUNT_REGION = "eu21" +BTP_KYMA_PLAN = "azure" +BTP_KYMA_REGION = "westeurope" +``` + +In the `main.tf` file you need to ensure the [required providers](#required-providers) and include the kyma module as a child module. + +```tf + +provider "jq" {} +provider "http" {} +provider "btp" { + globalaccount = var.BTP_GLOBAL_ACCOUNT + cli_server_url = var.BTP_BACKEND_URL + idp = var.BTP_CUSTOM_IAS_TENANT + username = var.BTP_BOT_USER + password = var.BTP_BOT_PASSWORD +} + +module "kyma" { + source = "git::https://github.com/kyma-project/terraform-module.git?ref=v0.2.0" + BTP_KYMA_PLAN = var.BTP_KYMA_PLAN + BTP_NEW_SUBACCOUNT_NAME = var.BTP_NEW_SUBACCOUNT_NAME + BTP_CUSTOM_IAS_TENANT = var.BTP_CUSTOM_IAS_TENANT + BTP_CUSTOM_IAS_DOMAIN = var.BTP_CUSTOM_IAS_DOMAIN + BTP_KYMA_REGION = var.BTP_KYMA_REGION + BTP_BOT_USER = var.BTP_BOT_USER + BTP_BOT_PASSWORD = var.BTP_BOT_PASSWORD + BTP_NEW_SUBACCOUNT_REGION = var.BTP_NEW_SUBACCOUNT_REGION +} + +//Use the outputs of kyma module as you wish.. +//Here it is simply forwarded as outputs of the root module +output "subaccount_id" { + value = module.kyma.subaccount_id +} + +output "service_instance_id" { + value = module.kyma.service_instance_id +} + +output "cluster_id" { + value = module.kyma.cluster_id +} + +output "domain" { + value = module.kyma.domain +} + +//Use the kubeconfig output if you want to create/read k8s resources via [kubernetes terraform provider](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs) + + + +``` + +Now you are ready to run the terraform CLI in your root module's folder + +```bash +cd tf +terraform init +terraform apply -var-file=.tfvars -auto-approve +``` + +Once terraform is finished, there will be a new `kubeconfig.yaml` file in the root module folder, providing you the access to the newly created Kyma runtime. + +``` +. ++-- tf +| +-- main.tf +| +-- .tfvars +| +-- kubeconfig.yaml +``` + +In order to destroy all resources you need to call the destroy command + +```bash +terraform destroy -var-file=.tfvars -auto-approve +``` -The module should be included as a child module, and provided with a configured `sap/btp` terraform provider. The root module must define the values for the input variables. Go to the included [examples](./examples/). From a96e6a8b0908a39da99b85bd3b8c558a8d704ee4 Mon Sep 17 00:00:00 2001 From: "Kwiatosz, Krzysztof" Date: Fri, 4 Oct 2024 13:39:12 +0200 Subject: [PATCH 2/7] Document module usage --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 6483797..2cbd764 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,12 @@ Once terraform is finished, there will be a new `kubeconfig.yaml` file in the ro | +-- kubeconfig.yaml ``` +Use the `terraform output` command if you wish to read the output value, for example: + +```bash +terraform output -raw cluster_id +``` + In order to destroy all resources you need to call the destroy command ```bash From 472ee892260ec1750856523eee37382b6d44d25b Mon Sep 17 00:00:00 2001 From: Grzegorz Karaluch Date: Thu, 10 Oct 2024 09:57:04 +0200 Subject: [PATCH 3/7] Apply suggestions from code review --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 2cbd764..73f2685 100644 --- a/README.md +++ b/README.md @@ -44,13 +44,15 @@ Terraform module for Kyma uses the following terraform [providers](provider.tf), | domain | domain of the created Kyma environment | -## How to use terraform module for kyma +## How to Use the Terraform Module for Kyma -Please refer to the included usage [examples](./examples/). +> [!NOTE] +> See the included [usage examples](./examples/). In order to use the module you need to create a dedicated folder in your project repository (for example `tf`). You will need to create a main terraform file (`main.tf`) and `.tfvars` file. This will become the so called root terraform module where the module for kyma can be used as a child module. ->> INFO: Read more about terraform modules in the [documentation form hasicorp](https://developer.hashicorp.com/terraform/language/modules) +> [!NOTE] +> To learn more about Terraform modules, see [Modules](https://developer.hashicorp.com/terraform/language/modules) ``` . @@ -101,8 +103,8 @@ module "kyma" { BTP_NEW_SUBACCOUNT_REGION = var.BTP_NEW_SUBACCOUNT_REGION } -//Use the outputs of kyma module as you wish.. -//Here it is simply forwarded as outputs of the root module +//Use the outputs of the Kyma module as you wish. +//Here it is forwarded as outputs of the root module. output "subaccount_id" { value = module.kyma.subaccount_id } @@ -129,7 +131,7 @@ output "domain" { ``` -Now you are ready to run the terraform CLI in your root module's folder +Now you are ready to run the Terraform CLI in your root module's folder. ```bash cd tf @@ -137,7 +139,7 @@ terraform init terraform apply -var-file=.tfvars -auto-approve ``` -Once terraform is finished, there will be a new `kubeconfig.yaml` file in the root module folder, providing you the access to the newly created Kyma runtime. +Once Terraform is finished, there will be a new `kubeconfig.yaml` file in the root module folder, providing you access to the newly created Kyma runtime. ``` . @@ -147,13 +149,13 @@ Once terraform is finished, there will be a new `kubeconfig.yaml` file in the ro | +-- kubeconfig.yaml ``` -Use the `terraform output` command if you wish to read the output value, for example: +* To read the output value, use the `terraform output` command, for example: ```bash terraform output -raw cluster_id ``` -In order to destroy all resources you need to call the destroy command +To destroy all resources, call the destroy command: ```bash terraform destroy -var-file=.tfvars -auto-approve From 36828045219d8ad74ddc5b7e303460deaa03871d Mon Sep 17 00:00:00 2001 From: Grzegorz Karaluch Date: Thu, 10 Oct 2024 09:57:32 +0200 Subject: [PATCH 4/7] Apply suggestions from code review --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 73f2685..8de62ef 100644 --- a/README.md +++ b/README.md @@ -61,7 +61,7 @@ In order to use the module you need to create a dedicated folder in your project | +-- .tfvars ``` -In the `.tfvars` file you will need to ensure [input parameters](#input-variables-tf-vars). Please refer to the [template](examples/kyma-on-btp-new-sa/.tfvars-template) +2. In the `.tfvars` file, provide [input parameters](#input-variables-tf-vars). Refer to the [template](examples/kyma-on-btp-new-sa/.tfvars-template) file. For example: ```tf @@ -77,7 +77,7 @@ BTP_KYMA_PLAN = "azure" BTP_KYMA_REGION = "westeurope" ``` -In the `main.tf` file you need to ensure the [required providers](#required-providers) and include the kyma module as a child module. +3. In the `main.tf`, provide the [required providers](#required-providers) and include the Kyma module as a child module. ```tf From f85bdd801fffd417d1acfb60d11688edab39c00b Mon Sep 17 00:00:00 2001 From: Grzegorz Karaluch Date: Thu, 10 Oct 2024 10:12:57 +0200 Subject: [PATCH 5/7] Apply suggestions from code review --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8de62ef..04aa4ab 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ Terraform module for Kyma uses the following terraform [providers](provider.tf), > [!NOTE] > See the included [usage examples](./examples/). -In order to use the module you need to create a dedicated folder in your project repository (for example `tf`). You will need to create a main terraform file (`main.tf`) and `.tfvars` file. This will become the so called root terraform module where the module for kyma can be used as a child module. +1. To use the module, create a dedicated folder in your project repository (for example, `tf`), a main Terraform (`main.tf`) file, and `.tfvars` files. This will become the so-called root Terraform module, where the module for Kyma can be used as a child module. > [!NOTE] > To learn more about Terraform modules, see [Modules](https://developer.hashicorp.com/terraform/language/modules) @@ -131,7 +131,7 @@ output "domain" { ``` -Now you are ready to run the Terraform CLI in your root module's folder. +4. Run the Terraform CLI in your root module's folder. ```bash cd tf From 3529d05c3634496c965c432b07c989d5868b6076 Mon Sep 17 00:00:00 2001 From: Grzegorz Karaluch Date: Thu, 10 Oct 2024 10:13:44 +0200 Subject: [PATCH 6/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 04aa4ab..54376cb 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ terraform init terraform apply -var-file=.tfvars -auto-approve ``` -Once Terraform is finished, there will be a new `kubeconfig.yaml` file in the root module folder, providing you access to the newly created Kyma runtime. +You should see a new `kubeconfig.yaml` file in the root module folder, providing you access to the newly created Kyma runtime. ``` . From 947d5c0d28961d621fa7df8e0406e033ccb7bf28 Mon Sep 17 00:00:00 2001 From: Grzegorz Karaluch Date: Wed, 16 Oct 2024 10:58:03 +0200 Subject: [PATCH 7/7] Update README.md Co-authored-by: Krzysztof Kwiatosz --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 54376cb..2a708a0 100644 --- a/README.md +++ b/README.md @@ -77,7 +77,7 @@ BTP_KYMA_PLAN = "azure" BTP_KYMA_REGION = "westeurope" ``` -3. In the `main.tf`, provide the [required providers](#required-providers) and include the Kyma module as a child module. +3. In the `main.tf`, ensure the [required providers](#required-providers) and include the Kyma module as a child module. ```tf