In a provider that uses the old SDK we had a test that triggered a side-effect outside of Terraform by doing this…
// testAccAddACLEntries doesn't technically check for anything despite returning a TestCheckFunc. Instead it is used for
// its side effect of adding an ACL Entry
func testAccAddACLEntries(acl *gofastly.ACL) resource.TestCheckFunc {
return func(_ *terraform.State) error {
conn := testAccProvider.Meta().(*APIClient).conn
_, err := conn.CreateACLEntry(&gofastly.CreateACLEntryInput{
ServiceID: acl.ServiceID,
ACLID: acl.ID,
IP: gofastly.String("192.168.0.1"),
})
if err != nil {
return fmt.Errorf("error adding entry to ACL (%s) on service (%s): %w", acl.ID, acl.ServiceID, err)
}
return nil
}
}
I’m wondering how to achieve the same using the new plugin framework?
I’m currently at this stage…
Check: resource.ComposeAggregateTestCheckFunc(
func(_ *terraform.State) error {
// this is the old way we got to the API client...
// conn := testAccProvider.Meta().(*APIClient).conn
if f, ok := provider.TestAccProtoV6ProviderFactories["fastly"]; ok {
ps, err := f()
if err != nil {
return fmt.Errorf("failed to access test provider: %w", err)
}
fmt.Printf(">>> %#v\n", ps.) // << doesn't look like I can get at metadata to convert to an API client here
}
return nil
},
),
Anyone have any ideas?
Thanks.