Closed mike-guy closed 2 years ago
I've looked into this a little. The "name" attribute is not exposed in the GUI - so in existing environments will often be unset. When this is imported it ends up as a blank string.
Even if this is not set (for example, using an if statement so skip d.Set("name"...), the Terraform plugin SDK seems to set it to "{}", hence after import a change is detected as needing to be made. I suspect two things will need to be implemented to resolve.
Assigning a value of "Default: nil" to the schema. e.g.
"name": &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringLenBetween(1, 1000),
Defau
Adjusting the import code to include an if statement. Something along the lines of...
if name := models.StripQuotes(subnetsCont.S("name").String()); name != "{}" {
d.Set("name", name)
}
Just as I was about to test, my dCloud lab finished, so for now - I'm off for a beer. I'll take a look tomorrow if I can!
I also notice the the Default value is not used elsewhere in the Schema's - there may be reasons I'm unaware of as to why this is the case. I guess an alternative approach would be to handle the blank name value in the mso-go-client.
If you have a preference, let me know and I'm happy to code, do some smoke testing and issue a PR!
Community Note
Terraform Version
terraform version Terraform v1.1.4 on windows_amd64
provider registry.terraform.io/ciscodevnet/mso v0.4.1
MSO version
Nexus Dashboard Version 2.0(2g)
Multi-Site Orchestrator Version: 3.3(1e)
dCloud Cisco Nexus Dashboard Orchestrator for ACI Lab v1
APIC version and APIC Platform for Site Level Resources
N/A
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
Manually created configuration should not include the value jsonencode({}) for an attribute that is not exposed in the MSO GUI.
Whilst this is a minor issue that has no serious impact, the value should be returned as "null" or the value omitted from terraform configuration altogether.
Actual Behavior
If an existing external epg has been created in the MSO GUI, importing it causes the name value to be jsonencode({}). This can then not be omitted in the Terraform configuration. It must either be specified exactly as jsonencode({}) or replaced with an alternative value.
This name attribute is not exposed in the GUI.
Steps to Reproduce
Important Factoids
GUI Configuration
Import command and output
Terraform state after import
Apply of configuration with matches the GUI (except for the non-existent name attribute)