terraform-provider-btp: [BUG] Existing CloudFoundry environment cannot be imported
Is there an existing issue for this?
- I have searched the existing issues
What version of Terraform are you using?
1.5.6
What type of issue are you facing
bug report
Describe the bug
I am attempting to capture an existing SAP BTP Environment setup for a CloudFoundry runtime for an ABAP environment. As far as I can tell, this lives outside of CloudFoundry and should be handled via the btp_subaccount_environment_instance resource.
(Please let me know if I’m wrong above, since that could be the root of my issue.)
I define the resource based on the doc example:
resource "btp_subaccount_environment_instance" "cloudfoundry_abap" {
subaccount_id = btp_subaccount.abap.id
name = "SCT_Software_abapsystem"
environment_type = "cloudfoundry"
service_name = "cloudfoundry"
plan_name = "standard"
}
I then import the existing resource via: the command line:
terraform import -var-file="env_dev.tfvars" module.product_environment.module.product_environment_btp.btp_subaccount_environment_instance.cloudfoundry_abap REDACTED_SUBACCOUNT_GUID,REDACTED_INSTANCE_ID
The import completes successfully.
However, when I next run terraform plan, I see:
# module.product_environment.module.product_environment_btp.btp_subaccount_environment_instance.cloudfoundry_abap will be updated in-place
~ resource "btp_subaccount_environment_instance" "cloudfoundry_abap" {
~ broker_id = "REDACTED_GUID" -> (known after apply)
~ created_date = "2023-01-01T19:56:27Z" -> (known after apply)
~ custom_labels = {} -> (known after apply)
+ dashboard_url = (known after apply)
+ description = (known after apply)
id = "REDACTED_GUID"
~ labels = jsonencode(
{
- "API Endpoint" = "https://api.cf.us10.hana.ondemand.com"
- "Org ID" = "REDACTED_GUID"
- "Org Memory Limit" = "204,800MB"
- "Org Name" = "SCT_Software_abapsystem"
}
) -> (known after apply)
~ last_modified = "2023-09-04T12:28:28Z" -> (known after apply)
name = "SCT_Software_abapsystem"
~ operation = "provision" -> (known after apply)
~ parameters = jsonencode(
~ {
- users = [
- {
- email = "REDACTED_EMAIL"
},
]
# (2 unchanged attributes hidden)
}
)
~ plan_id = "REDACTED_GUID" -> (known after apply)
~ platform_id = "REDACTED_GUID" -> (known after apply)
~ service_id = "REDACTED_GUID" -> (known after apply)
~ state = "OK" -> (known after apply)
~ tenant_id = "REDACTED_GUID" -> (known after apply)
~ type = "Provision" -> (known after apply)
I figured I might need to do some reconciliation, so as a first pass, I attempt to modify the labels field to match the changes that are being suggested. When I attempt that, I see:
Cannot set value for this attribute as the provider has marked it as read-only. Remove the configuration line setting the value.
Refer to the provider documentation or contact the provider developers for additional information about configurable and read-only attributes that are supported.
It seems that the import captures a great deal of information into TF state, which it then cannot reconcile with my Terraform, and where I can’t update my script to bring it in line with the expectations due to the inability to set some fields.
Expected Behavior
No response
Steps To Reproduce
No response
Add screenshots to help explain your problem
No response
Additional context
No response
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (16 by maintainers)
terraform applyafter the import catches them, as they are dependent on your configuration.Some things that are good to know, but that do not explain the CF behavior that is not 1:1 reproducible atm
Hi @lechnerc77, my Terraform file looks like you describe. I’ll reach out to schedule a call. Thanks!
@lechnerc77 OK, so the exact repro:
After making these changes, when I run
terraform planagain, I see:The concerns I have are that:
As a side note, thanks for teaching me about import blocks, which I’d completely missed somehow and which seem much nicer than the CLI for our situation!