mirror of
https://github.com/opentofu/opentofu.git
synced 2025-02-20 11:48:24 -06:00
Previously the db_event_subscription import would only work if there was a single db_event_subscription resource. This fixes the import, allowing it to work as expected. Also fixes the acceptance test for the resource to reflect this. ``` $ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSDBEventSubscription_importBasic' ==> Checking that code complies with gofmt requirements... go generate $(go list ./... | grep -v /terraform/vendor/) 2017/02/07 10:38:10 Generated command/internal_plugin_list.go TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSDBEventSubscription_importBasic -timeout 120m === RUN TestAccAWSDBEventSubscription_importBasic --- PASS: TestAccAWSDBEventSubscription_importBasic (633.33s) PASS ok github.com/hashicorp/terraform/builtin/providers/aws 633.353s ```
18 lines
654 B
Go
18 lines
654 B
Go
package aws
|
|
|
|
import "github.com/hashicorp/terraform/helper/schema"
|
|
|
|
func resourceAwsDbEventSubscriptionImport(
|
|
d *schema.ResourceData,
|
|
meta interface{}) ([]*schema.ResourceData, error) {
|
|
|
|
// The db event subscription Read function only needs the "name" of the event subscription
|
|
// in order to populate the necessary values. This takes the "id" from the supplied StateFunc
|
|
// and sets it as the "name" attribute, as described in the import documentation. This allows
|
|
// the Read function to actually succeed and set the ID of the resource
|
|
results := make([]*schema.ResourceData, 1, 1)
|
|
d.Set("name", d.Id())
|
|
results[0] = d
|
|
return results, nil
|
|
}
|