Skip to content

Commit

Permalink
Merge pull request #563 from upbound/backport-561-to-release-0.37
Browse files Browse the repository at this point in the history
[Backport release-0.37] [management]: Fix import of ManagementGroupSubscriptionAssociation
  • Loading branch information
turkenf committed Oct 2, 2023
2 parents 2f0bdda + d96d980 commit 2f5455a
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions config/externalname.go
Original file line number Diff line number Diff line change
Expand Up @@ -1989,13 +1989,14 @@ func managementGroupSubscriptionAssociation() config.ExternalName {
w := strings.Split(id.(string), "/")
return fmt.Sprintf("%s/%s", w[len(w)-3], w[len(w)-1]), nil
}
// if we construct id according to the full path above, the underlying
// terraform non-deterministically fails with
// "could not read properties for Management Group "example-sub""
// just populate the id with empty string solves it. Same happens in
// isolated test with terraform cli
e.GetIDFn = func(_ context.Context, externalName string, parameters map[string]interface{}, _ map[string]interface{}) (string, error) {
return "", nil
if len(externalName) == 0 || len(strings.Split(externalName, "/")) < 2 {
return "", nil
}
w := strings.Split(externalName, "/")
managementGroupName := w[0]
subscriptionId := w[1]
return fmt.Sprintf("/managementGroup/%s/subscription/%s", managementGroupName, subscriptionId), nil
}
return e
}
Expand Down

0 comments on commit 2f5455a

Please sign in to comment.