SAP / terraform-provider-btp

Terraform provider for SAP BTP
https://registry.terraform.io/providers/SAP/btp/latest
Apache License 2.0
89 stars 18 forks source link

feat: add dashboard URL to service instance #865

Closed lechnerc77 closed 3 months ago

lechnerc77 commented 4 months ago

Purpose

Does this introduce a breaking change?

[ ] Yes
[X] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[X] Feature
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

go test ./...
Regression test with provider version 1.4.0  

What to Check

Verify that the following are valid:

Other Information

n/a

Checklist for reviewer

The following organizational tasks must be completed before merging this PR:

lechnerc77 commented 4 months ago

Regression test done with HANA Cloud that exposes the dashboard URL- due to computed field, change has no impact on existing states.

Customers can fetch the additional computed field via terraform refresh which will update the state without any impact on the provided resources on SAP BTP

Here is the sample configuration used to validate the setup:

provider.tf

terraform {
  required_providers {
    btp = {
      source  = "SAP/btp"
      version = "~>1.4.0"
    }
  }
}

# Configure the BTP Provider
provider "btp" {
  globalaccount  = var.globalaccount
  cli_server_url = var.cli_server_url
}

main.tf

resource "btp_subaccount" "sa_retest_hana_cloud" {
  name      = "retest-hana-cloud"
  subdomain = "retest-hana-cloud"
  region    = var.region
}

resource "btp_subaccount_entitlement" "se_hana-cloud" {
  subaccount_id = resource.btp_subaccount.sa_retest_hana_cloud.id
  service_name  = "hana-cloud"
  plan_name     = "hana"
}

data "btp_subaccount_service_plan" "sp_hana_cloud__hana" {
  subaccount_id = resource.btp_subaccount.sa_retest_hana_cloud.id
  offering_name = "hana-cloud"
  name          = "hana"
  depends_on    = [btp_subaccount_entitlement.se_hana-cloud]
}

resource "btp_subaccount_service_instance" "hana_cloud_hana_instance" {
  subaccount_id  = resource.btp_subaccount.sa_retest_hana_cloud.id
  serviceplan_id = data.btp_subaccount_service_plan.sp_hana_cloud__hana.id
  name           = "hana-cloud-test-tf"
  parameters = jsonencode({
    "data" = {
      "memory"                 = 32
      "generateSystemPassword" = true
      "edition"                = "cloud"
    }
  })
  timeouts = {
    create = "25m"
    update = "15m"
    delete = "15m"
  }
}

variables.tf

variable "globalaccount" {
  description = "The global account name"
  type        = string
  default     = <YOUR GLOBAL ACCOUNT SUBDOMAIN>
}

variable "cli_server_url" {
  description = "The BTP CLI server URL"
  type        = string
  default     = "https://cli.btp.cloud.sap"

}

variable "region" {
  description = "The region where the subaccount should be created"
  type        = string
  default     = "us10"
}
lechnerc77 commented 4 months ago
lechnerc77 commented 4 months ago

@vipinvkmenon @CHERIANS: when doing the review, please also validate the regression e.g. via the sample configuration provided above.

vipinvkmenon commented 3 months ago

Verified