Repository navigation
|
I’m trying to understand how to structure a Terraform configuration that assigns a service entitlement to a BTP subaccount and then creates a service instance using that plan. |
Replies: 1 comment
|
Put the dependency on the plan data source. Referencing the same subaccount ID in both blocks only makes them depend on the subaccount; it doesn't order the entitlement assignment before the plan lookup. For the # Assumes btp_subaccount_entitlement.service is declared elsewhere.
data "btp_subaccount_service_plan" "service" {
subaccount_id = var.subaccount_id
offering_name = var.service_offering_name
name = var.service_plan_name
depends_on = [btp_subaccount_entitlement.service]
}
resource "btp_subaccount_service_instance" "service" {
subaccount_id = var.subaccount_id
name = var.instance_name
serviceplan_id = data.btp_subaccount_service_plan.service.id
# Add the service-specific parameters here, if required.
}The If the entitlement is being created or changed, Terraform can defer the data-source read until apply; seeing There is also a newer option: provider 1.22.0 introduced For the delay question, |
Put the dependency on the plan data source. Referencing the same subaccount ID in both blocks only makes them depend on the subaccount; it doesn't order the entitlement assignment before the plan lookup.
For the
serviceplan_idapproach, the relevant part is: