When attempting to import `anypoint_private_space_config` resources for private spaces created in sub-organizations (business groups) or `anypoint_private_space_association` resources using the Anypoint Terraform provider, you may encounter errors.
For `anypoint_private_space_config` in sub-organizations, the import operation may fail, indicating the resource cannot be found or imported, or it may not complete successfully.
For `anypoint_private_space_association`, you may observe the following error:
```
? Error: Missing Configuration for Required Attribute
?
? with anypoint_private_space_association.my-ps-association,
? on generated.tf line 1:
? (source code not available)
```
CAUSE
These issues are due to defects in earlier versions of the Anypoint Terraform provider.
* Versions prior to 1.0.3 had a defect preventing the successful import of `anypoint_private_space_config` resources when the private space was provisioned within a sub-organization (business group).
* Versions prior to 1.0.5 had a defect preventing the successful import of `anypoint_private_space_association` resources, leading to a "Missing Configuration for Required Attribute" error.
SOLUTION
To resolve these import issues, upgrade your Anypoint Terraform provider to version 1.0.5 or later. Additionally, ensure you use the correct import syntax for `anypoint_private_space_config` when dealing with private spaces in sub-organizations.
1. **Update your Terraform provider configuration:**
Modify your `terraform` block to specify Anypoint provider version `1.0.5` or a later compatible version.
```terraform
terraform {
required_providers {
anypoint = {
source = "mulesoft/anypoint"
version = "1.0.5" # Or a later compatible version
}
}
}
provider "anypoint" {
client_id = var.anypoint_client_id
client_secret = var.anypoint_client_secret
}
```
2. **Initialize Terraform:**
Run `terraform init` to download and install the updated provider.
```bash
terraform init
```
3. **Import `anypoint_private_space_config` (for private spaces in sub-organizations):**
When importing a private space configuration that belongs to a sub-organization, the `id` for the import block must include both the organization ID (of the business group owning the private space) and the private space ID, separated by a slash.
```terraform
locals {
org_id = "your-business-group-org-id" # The ID of the business group that owns the private space
private_space_id = "your-private-space-id"
}
import {
to = anypoint_private_space_config.my-private-space-config
id = "${local.org_id}/${local.private_space_id}"
}
resource "anypoint_private_space_config" "my-private-space-config" {
name = "your-private-space-name"
# Other private space configuration attributes, e.g., region, cidr_block
}
```
Replace `your-business-group-org-id`, `your-private-space-id`, and `your-private-space-name` with your specific values.
4. **Import `anypoint_private_space_association`:**
After updating the provider to 1.0.5 or later, you can import `anypoint_private_space_association` resources using the standard import syntax, providing the `private_space_id` as the import `id`.
```terraform
locals {
private_space_id = "your-private-space-id"
}
import {
to = anypoint_private_space_association.my-private-space-association
id = local.private_space_id
}
resource "anypoint_private_space_association" "my-private-space-association" {
private_space_id = local.private_space_id
# Other association attributes, e.g., environment_ids
}
```
Replace `your-private-space-id` with your specific value.
APPLIES TO
* MuleSoft Anypoint Terraform Provider versions prior to 1.0.5
* Terraform CLI
005386565

We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.