Hi,
We are using Terraform 1.7.5 with local private providers and modules.
We first apply the following configurations:
...
provider "cis" {
region = local.automation_context.subaccount_region
alias = "as-ga-admin"
# Set credentials from the cloud-automation-client secret
cis_central_client_id = local.automation_context.client_id
cis_central_client_secret = local.automation_context.client_secret
cis_central_oauth_url = local.automation_context.oauth_url
cis_central_domain = local.automation_context.domain
}
provider "cis" {
alias = "as-sa-admin"
region = local.automation_context.subaccount_region
cis_local_credentials = module.subaccount.cis_local_credentials
}
provider "sm" {
region = local.subaccount_region
client_id = module.subaccount.cis_service_management_binding.client_id
client_secret = module.subaccount.cis_service_management_binding.client_secret
url = module.subaccount.cis_service_management_binding.url
sm_url = module.subaccount.cis_service_management_binding.sm_url
}
provider "xsuaa" {
region = local.automation_context.subaccount_region
domain = local.cis_local_domain
cis_local_client_id = local.cis_local_binding.clientid
cis_local_client_secret = local.cis_local_binding.clientsecret
cis_local_oauth_url = local.cis_local_binding.url
}
module "subaccount" {
automation_context = "${local.automation_context}"
customer_id = "${var.tenantContext.details.customer.id}"
source = "http://api.cloud-automation-registry/modules/sap-managed-cis-subaccount"
subaccount_admins = "${local.subaccount_admins}"
subaccount_display_name = "${local.subaccount_display_name}"
}
module "assignment-1" {
source = "http://api.cloud-automation-registry/modules/sap-managed-entitlements"
providers = {
cis = cis.as-ga-admin
}
service_name = "auditlog-viewer"
service_plan_name = "free"
subaccount_guid = "${module.subaccount.subaccount_guid}"
automation_context = "${local.automation_context}"
}
module "subscription-auditlog-viewer" {
automation_context = "${local.automation_context}"
providers = {
cis = cis.as-sa-admin
}
saas_app_name = "auditlog-viewer"
saas_plan_name = "free"
source = "http://api.cloud-automation-registry/modules/sap-managed-subscription"
subaccount_credentials = "${local.subaccount_credentials}"
depends_on = [module.assignment-1]
}
As you can see there is an explicit dependency between the subscription-auditlog-viewer module and the assignment-1 module.
On first apply the order is correct. Terraform creates the subsciprion after the assignment.
We are using S3 backend for managing the state. and i can see that in the state file the dependency was persisted successfully.
From the state file:
"resources": [
{
"module": "module.assignment-1",
"mode": "managed",
"type": "cis_entitlements",
"name": "entitlements",
"provider": "provider[\"api.cloud-automation-registry/providers/cis\"].as-ga-admin",
"instances": [
{
"index_key": 0,
"schema_version": 0,
"attributes": {
...
"dependencies": [
"module.subaccount.cis_subaccount.cis_subaccount"
]
}
]
},
....
{
"module": "module.subscription-auditlog-viewer",
"mode": "managed",
"type": "cis_saas_subscription",
"name": "saas_subscription",
"provider": "provider[\"api.cloud-automation-registry/providers/cis\"].as-sa-admin",
"instances": [
{
...
"dependencies": [
"module.assignment-1.cis_entitlements.entitlements",
...
]
}
]
After that we would like to remove both the subscription and the assignment and re apply the configurations.
...
provider "cis" {
region = local.automation_context.subaccount_region
alias = "as-ga-admin"
# Set credentials from the cloud-automation-client secret
cis_central_client_id = local.automation_context.client_id
cis_central_client_secret = local.automation_context.client_secret
cis_central_oauth_url = local.automation_context.oauth_url
cis_central_domain = local.automation_context.domain
}
provider "cis" {
alias = "as-sa-admin"
region = local.automation_context.subaccount_region
cis_local_credentials = module.subaccount.cis_local_credentials
}
provider "sm" {
region = local.subaccount_region
client_id = module.subaccount.cis_service_management_binding.client_id
client_secret = module.subaccount.cis_service_management_binding.client_secret
url = module.subaccount.cis_service_management_binding.url
sm_url = module.subaccount.cis_service_management_binding.sm_url
}
provider "xsuaa" {
region = local.automation_context.subaccount_region
domain = local.cis_local_domain
cis_local_client_id = local.cis_local_binding.clientid
cis_local_client_secret = local.cis_local_binding.clientsecret
cis_local_oauth_url = local.cis_local_binding.url
}
module "subaccount" {
automation_context = "${local.automation_context}"
customer_id = "${var.tenantContext.details.customer.id}"
source = "http://api.cloud-automation-registry/modules/sap-managed-cis-subaccount"
subaccount_admins = "${local.subaccount_admins}"
subaccount_display_name = "${local.subaccount_display_name}"
}
Now the graph looks like:
And as can be seen from the graph there is missing edge in the dependencies. It was expected to delete the assignment and the subscription in the reverse order, means first the subscription and then the assignment. But it actually first trying to delete the assignment and then the subscription and therefore it fails.
It seems to me like a bug in the behavior but i would like to understand if i’m missing something before opening a bug.
Thanks,
Nimrod Oron