Closed iitsDelbruegger closed 3 years ago
Example how to create a project and then utilize it within a second provider, so that resources can be created within that project:
provider "opentelekomcloud" {
alias = "superproject"
auth_url = "https://iam.eu-de.otc.t-systems.com/v3"
domain_name = local.otc_domain_name
tenant_name = "eu-de"
}
# Create a sub-project
resource opentelekomcloud_identity_project_v3 "otc_stage_project" {
name = local.otc_tenant_name
provider = opentelekomcloud.superproject
}
# Create a resource within project
resource "opentelekomcloud_compute_keypair_v2" "keyPairTerraform" {
name = "keypair-${local.stage_name}"
region = local.region
public_key = tls_private_key.keypair.public_key_openssh
provider = opentelekomcloud.subproject
}
I had a mistake in my thoughts: we can already do this by specifying the "providers" block in the module. Therefore I remove this issue.
module "vpc" {
source = "iits-consulting/project-factory/opentelekomcloud//modules/vpc"
version = "1.0.1"
vpc_cidr = local.vpc_cidr
vpc_name = "vpc-otc-custtest"
stage_name = local.stage_name
vpc_subnet_cidr = local.vpc_cidr
vpc_subnet_gateway_ip = local.vpc_subnet_gateway_ip
region = local.region
providers = {
opentelekomcloud = opentelekomcloud.subproject
}
}
All modules should support specifying which OTC provider to utilize, so that different resources can be created in different OTC projects or by different accounts.