Skip to content

[BUG] Export Hana Cloud Service with "other Environment", Terraform tries to "modify" #668

Closed

Description

@TimK200

Is there an existing issue for this?

  • I have searched the existing issues

What version of the Terraform exporter are you using?

2.0.0

What version of the Terraform CLI CLI are you using?

1.17.2

What type of issue are you facing

bug report

Describe the bug

We have two subaccount-level, multi-environment SAP Hana Cloud instances running in one Subaccount. Since they were created using the multi-environment model they show "other environment" in the BTP Cockpit. When the exporter encounters those services it tries to "modify" them, which the associated user is not allowed to do. Since i am not able to reproduce the issue on a trial subaccount or another subaccount i cannot estimate the impact those modification would have. So i want to ask whether that is an intended behavior and the impact the modification has.
This is an excerpt from terraform plan for one of those services, i have manually redacted values:

  # btp_subaccount_service_instance.serviceinstance_16 will be updated in-place
  # (will be imported first)
  ~ resource "btp_subaccount_service_instance" "serviceinstance_16" {
      ~ context                = jsonencode(
            {
              - crm_customer_id   = "<redacted>"
              - env_type          = "sapcp"
              - global_account_id = "<redacted>"
              - instance_name     = "<redacted>"
              - license_type      = "CUSTOMER"
              - origin            = "sapcp"
              - platform          = "sapcp"
              - region            = "cf-eu10"
              - subaccount_id     = "<redacted>"
              - subdomain         = "<redacted>"
              - zone_id           = "<redacted>"
            }
        ) -> (known after apply)
      ~ created_date           = "2023-10-15T10:30:31Z" -> (known after apply)
      ~ dashboard_url          = "<redacted>.prod-eu10.hanacloud.ondemand.com" -> (known after apply)
        id                     = "<redacted>"
      ~ labels                 = {} -> (known after apply)
      ~ last_modified          = "2026-11-15T03:00:08Z" -> (known after apply)
        name                   = "<redacted>"
      - parameters             = (sensitive value) -> null
      ~ platform_id            = "service-manager" -> (known after apply)
      ~ ready                  = true -> (known after apply)
      ~ referenced_instance_id = null -> (known after apply)
        serviceplan_id         = "<redacted>"
        shared                 = false
      ~ state                  = "succeeded" -> (known after apply)
        subaccount_id          = "<redacted>"
      ~ usable                 = true -> (known after apply)
    }
    }

There are things that concern me. For example -parameters =(sensitive value)-> null

Expected Behavior

No response

Steps To Reproduce

  1. create multi-environment SAP HANA Cloud Instance
  2. run btptf export
  3. run bptf plan -> will show service instance change

User's Role Collections

No response

Add screenshots to help explain your problem

No response

Additional context

No response

Activity

  1. added
    bug
    needs-triage
    on Nov 18, 2026
  2. lechnerc77 commented on Nov 18, 2026

    @lechnerc77
    Member

    @TimK200 Does this import impact services with parameters only? From you plan the change is triggered due to the missing parameters:

    - parameters             = (sensitive value) -> null

    If yes, this is a known gap in the Terraform provider (see https://github.com/SAP/terraform-provider-btp/blob/main/guides/IMPORT.md), as we cannot consistently fetch the parameters from the platform. Can you check?

  3. added
    needs-author-feedback
    on Nov 18, 2026
  4. TimK200 commented on Nov 19, 2026

    @TimK200
    Author

    Every resource where terraform plan fails (in our testing cf environments) has a parameter "status" that terraform wants to set to "ACTIVE". Looking at the import block shows the parameter present and set to ACTIVE. BTP Cockpit also shows that parameter set.

    The documentation states:
    "Service instances with parameters: The import of service instances configured via parameters only works if the corresponding service offering supports parameter retrieval (instances_retrievable set to true). If parameters are not retrievable from the backend API, ensure you declare parameters in your resource block matching the existing state to prevent unintended configuration drift during terraform plan."

    If that is the issue how come the exporter can retrieve the parameters correctly but the provider fails?

  5. lechnerc77 commented on Nov 19, 2026

    @lechnerc77
    Member

    @TimK200 I am noit sure if I understand the additional information:

    • in our testing cf environments -> We are talking about resources living in BTP (environment other) or on CF or on both?
    • parameter "status" -> the atrtribute state is a computed field of the resource. The change in the original code you shared is due to the change of the parameters
    • parameters -> The attribute parameters (= the JSON string with service specific configuration parameters) is the one that causes the in-place update during the import: this is the information taht we cannot fetch from the backend at least not consistently for all services. The provider does not read that field from the backend due that inconsistency.

    I will reprodue your setup and provide more details on the flow and its issues here.

  6. TimK200 commented on Nov 19, 2026

    @TimK200
    Author

    okay maybe i should have added the context properly. In other cases, not the one provided in the initial description, we ran into the issue when terraform plan tried to modify the btp_subaccount_environment_instance (in our case a cloudfoundry env). The resource was, from what we can tell, correctly exported and written in a resource block (with the parameter status="ACTIVE").
    From btp_resources.tf:

    ###
    # Resource: BTP_SUBACCOUNT_ENVIRONMENT_INSTANCE
    ###
    resource "btp_subaccount_environment_instance" "subaccount_environment_instance_0" {
      provider         = btp
      environment_type = "cloudfoundry"
      landscape_label  = "cf-eu10"
      name             = "<redacted>"
      parameters = jsonencode({
        instance_name = "<redacted>"
        status        = "ACTIVE"
        users = [{
          email = "<redacted>"
          id    = "<redacted>"
        }]
      })
      plan_name     = "standard"
      service_name  = "cloudfoundry"
      subaccount_id = btp_subaccount.subaccount_3.id
    }
    

    Terraform plan then wants to modify it, trying to add the parameter. Which you described is the issue with unreliable retrieval.

    
     # btp_subaccount_environment_instance.subaccount_environment_instance_0 will be updated in-place
      # (will be imported first)
      ~ resource "btp_subaccount_environment_instance" "subaccount_environment_instance_0" {
          ~ broker_id        = "<redacted>" -> (known after apply)
          ~ created_date     = "2020-02-03T14:45:43Z" -> (known after apply)
          ~ custom_labels    = {} -> (known after apply)
          ~ dashboard_url    = null -> (known after apply)
          ~ description      = null -> (known after apply)
            environment_type = "cloudfoundry"
            id               = "<redacted>"
            labels           = jsonencode(
                {
                    "API Endpoint:"    = "https://api.cf.eu10.hana.ondemand.com"
                    "Org ID"           = "<redacted>"
                    "Org Memory Limit" = "204,800MB"
                    "Org Name"         = "<redacted>"
                }
            )
            landscape_label  = "cf-eu10"
          ~ last_modified    = "2026-11-13T11:55:55Z" -> (known after apply)
            name             = "<redacted>"
          ~ operation        = "provision" -> (known after apply)
          ~ parameters       = jsonencode(
              ~ {
                    instance_name = "<redacted>"
                  + status        = "ACTIVE"
                    users         = [
                        {
                            email = "<redacted>"
                            id    = "<redacted>"
                        },
                    ]
                }
            )
          ~ plan_id          = "<redacted>" -> (known after apply)
            plan_name        = "standard"
            platform_id      = "<redacted>"
          ~ service_id       = "<redacted>" -> (known after apply)
            service_name     = "cloudfoundry"
          ~ state            = "OK" -> (known after apply)
            subaccount_id    = "<redacted>"
          ~ tenant_id        = "<redacted>" -> (known after apply)
          ~ type             = "Provision" -> (known after apply)
        }
    

    How would we go about working around that issue?
    The documentation talks about strictly matching the parameters in the resource-block with the live backend config. Since the resource-block after the export has the correct parameters i assume this is "valid" according to the doc? I am looking at the documentation you posted for the service_instance even though this is a different resource. The documentation for subaccount_environmental_instance has no mention for these kind of issues.
    Fyi: A older versions of Terraform(1.15.8) that we had in use had no issue with the environment_instances but with the initial issue with the services.

  7. removed
    needs-author-feedback
    on Nov 19, 2026
  8. lechnerc77 commented on Nov 19, 2026

    @lechnerc77
    Member

    @TimK200 Thanks for the clarification, I will investigate in scenarios and come back to you

  9. added
    btp
    wontfix
    and removed
    bug
    needs-triage
    on Nov 19, 2026
  10. lechnerc77 commented on Nov 19, 2026

    @lechnerc77
    Member

    @TimK200 as promised the update:

    The clean-up of the environment instance parameters is implemented in #669 and will be part of the next release. For the time beeing you can just remove the line status = "ACTIVE" from your Terraform configuration.

    The behavior of the service instance is caused by the reason already discussed. The main issue is the attribute parameters of the resource btp_service_instance (https://registry.terraform.io/providers/SAP/btp/latest/docs/resources/subaccount_service_instance#parameters-1). Two main cases need to be distinguished:

    1. Service that do not have parameters that are required or optional during service instancer creation: These services can be imported and there is no risk of side effects as no parameters will be overwritten
    2. Services that do have optional parameters (with default values) that you might have set during creation in the SAP BTP cockpit like the destination service or services that have required parameters for the service instance creation: These parameters cannot be fetched from the platform and hence, they do not appear in the generated configuration. This needs to be manually considered when importing the service instance and can lead to an in-place update. For a consistent management of the instance you ned to add the parameters manually. This will not prevent the in-place update, but ensures consistency with the original setup. However, you must test this before as the in-place update might have side effects depending on the service.

    The gap of scenario 2 is known and cannot be fixed by the exporter or the Terraform provider. This is an issue with the platform and must be fixed by the services.

    Bottom-line: when importing service instances you must carefully check for the in-place updates and test the import process when providing the parameters. There is no better approach as of today and as staed nothing we can fix from the Terraform team side.

    As we cannot provide a solutin for this gap I will close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    btpimprovementwontfix

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions