Closed TomChapple closed 6 months ago
Hi @TomChapple for your example, you have to use a composed id. the resource APIM is located under other resources and the URL cannot be generated with only the id of the APIM.
here's an example:
# In order for the import to work, you should provide a ID composed of the following:
# {ORG_ID}/{ENV_ID}/{API_ENV_ID}
terraform import \
-var-file params.tfvars.json \ #variables file
anypoint_apim_mule4.mule \ #resource name
aa1f55d6-213d-4f60-845c-201282484cd1/7074fcdd-9b23-4ab6-97r8-5db5f4adf17d/19218070 #resource ID
replace with your own values.
Awesome, thanks for the clarification! I was able to import it successfully using that method you described. I'm happy to close this issue.
The most recent release of this provider has me very excited and I have been experimenting with its usage for APIM Instances, but it appears that I cannot use the import command for the "anypoint_apim_mule4" resources.
Problem
It appears as though the
terraform import anypoint_apim_mule4.<resource> <id>
command generates a malformed URL for the APIM Instance in question, thereby resulting in a "NotFoundError" from Anypoint.Symptoms
For the purposes of these symptoms, I am using dummy GUIDs and IDs. Be aware that I am using (to the best of my knowledge) accurate GUIDs and IDs for the platform I am working with and that these examples will need to be modified to use other values to work on an arbitrary machine. Despite this, the symptoms described will appear with these stub values.
I have a Terraform configuration with the following content describing an APIM Instance:
Given this, when I attempt to run an import command such as
terraform import anypoint_apim_mule4.hello-world 12345678
(the12345678
can even be invalid such asabc
), I get the following response:Note that I can use the
terraform plan
command to get valid output:Theories
The output mentioning that the organisation ID be searched for is "environments", which is very odd. However, the line in the Anypoint Go Client that describes this URL template has
/environments
as the immediate next path element. My theory is that theorg_id
is somehow blanked out and so Anypoint just uses the next path element available. This looks feasible to me as the Anypoint Go Client has a function calledparameterValueToString
that contains logic to blank out the string under certain conditions.I'm not super familiar with Go or this framework, so I would take any of this analysis with a grain of salt.
Technical Information
I am using the following Terraform providers for my testing:
Anypoint Credentials are being passed in via the exported variables
ANYPOINT_CLIENT_ID
andANYPOINT_CLIENT_SECRET
and have been granted permission to the business group and environment in question.When running
terraform version
I get the following output: