Skip to content

Commit

Permalink
[bug_fix] Fix importing for mso_schema_template_anp_epg_contract to s…
Browse files Browse the repository at this point in the history
…elect the contract with the correct type
  • Loading branch information
akinross authored and lhercot committed Oct 24, 2024
1 parent 40585d8 commit f209d3d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion mso/resource_mso_schema_template_anp_epg_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ func resourceMSOTemplateAnpEpgContractImport(d *schema.ResourceData, m interface
stateANP := get_attribute[4]
stateEPG := get_attribute[6]
stateContract := get_attribute[8]
stateRelationshipType := get_attribute[10]

for i := 0; i < count; i++ {
tempCont, err := cont.ArrayElement(i, "templates")
if err != nil {
Expand Down Expand Up @@ -145,7 +147,7 @@ func resourceMSOTemplateAnpEpgContractImport(d *schema.ResourceData, m interface
re := regexp.MustCompile("/schemas/(.*)/templates/(.*)/contracts/(.*)")
match := re.FindStringSubmatch(contractRef)
apiContract := match[3]
if apiContract == stateContract {
if apiContract == stateContract && apiRelationshipType == stateRelationshipType {
d.SetId(apiContract)
d.Set("contract_name", match[3])
d.Set("contract_schema_id", match[1])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,5 @@ No attributes are exported.
An existing MSO Schema Template Application Network Profile Endpoint Group Contract can be [imported][docs-import] into this resource via its Id/path, via the following command: [docs-import]: <https://www.terraform.io/docs/import/index.html>

```bash
terraform import mso_schema_template_anp_epg_contract.contract1 {schema_id}/template/{template_name}/anp/{anp_name}/epg/{epg_name}/contract/{contract_name}
terraform import mso_schema_template_anp_epg_contract.contract1 {schema_id}/template/{template_name}/anp/{anp_name}/epg/{epg_name}/contract/{contract_name}/relationship_type/{consumer|provider}
```

0 comments on commit f209d3d

Please sign in to comment.