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

[BUG] btp_subaccount_service_plan (Data Source) resulted in BadRequest #945

Closed miyasuta closed 2 weeks ago

miyasuta commented 2 weeks ago

Is there an existing issue for this?

What version of the Terraform provider are you using?

1.8.0

What version of the Terraform CLI are you using?

1.8.0

What type of issue are you facing

bug report

Describe the bug

Executing the data "btp_subaccount_service_plan" command failed with "BadRequest" error.

Command

resource "btp_subaccount_entitlement" "xsuaa" {
  subaccount_id = var.subaccount_id
  service_name  = "xsuaa"
  plan_name     = "apiaccess"
}

data "btp_subaccount_service_plan" "xsuaa_apiaccess" {
  subaccount_id = var.subaccount_id
  offering_name = "xsuaa"
  name          = "apiaccess"
  depends_on    = [btp_subaccount_entitlement.xsuaa]
}

Error

│ Error: API Error Reading Resource Service Plan (Subaccount)
│ 
│   with data.btp_subaccount_service_plan.xsuaa_apiaccess,
│   on main.tf line 18, in data "btp_subaccount_service_plan" "xsuaa_apiaccess":
│   18: data "btp_subaccount_service_plan" "xsuaa_apiaccess" {
│ 
│ BadRequest

Expected Behavior

Service plan details should be retrieved.

Steps To Reproduce

  1. Execute a terraform init
  2. Execute a terrafom apply with the following configuration

main.tf

resource "btp_subaccount_entitlement" "xsuaa" {
  subaccount_id = var.subaccount_id
  service_name  = "xsuaa"
  plan_name     = "apiaccess"
}

data "btp_subaccount_service_plan" "xsuaa_apiaccess" {
  subaccount_id = var.subaccount_id
  offering_name = "xsuaa"
  name          = "apiaccess"
  depends_on    = [btp_subaccount_entitlement.xsuaa]
}

provider.tf

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

provider "btp" {
  globalaccount = var.globalaccount
}

User's Role Collections

Add screenshots to help explain your problem

image

Additional context

The entitlement for xsuaa service with plan apiaccess has been added to the subaccount.

lechnerc77 commented 2 weeks ago
lechnerc77 commented 2 weeks ago

Update: The service where the plan should be fetched via the Terraform provider for SAP BTP is a service plan that is coupled to a runtime (in the case of xsuaa and apiaccess to the cloud foundry runtime) Consequently the information cannot be fetched via the Terraform provider for SAP BTP as this provider can only fetch information about services that are runtime-agnostic (environment "other" when trying to instantiate them in the cockpit). So, the behavior is correct.

@miyasuta in order to fetch these plans you must use the Cloud Foundry provider to get the plan (and the CF environment must be up and running)

miyasuta commented 2 weeks ago

@lechnerc77 Thank you for the explanation. I will use Cloud Foundry provider.