Merge pull request #11744 from hashicorp/b-fix-db-event-import
provider/aws: Fix aws_db_event_subscription import
This commit is contained in:
commit
28b9f3f8fb
|
@ -0,0 +1,17 @@
|
|||
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
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package aws
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/hashicorp/terraform/helper/acctest"
|
||||
|
@ -10,6 +11,7 @@ import (
|
|||
func TestAccAWSDBEventSubscription_importBasic(t *testing.T) {
|
||||
resourceName := "aws_db_event_subscription.bar"
|
||||
rInt := acctest.RandInt()
|
||||
subscriptionName := fmt.Sprintf("tf-acc-test-rds-event-subs-%d", rInt)
|
||||
|
||||
resource.Test(t, resource.TestCase{
|
||||
PreCheck: func() { testAccPreCheck(t) },
|
||||
|
@ -24,6 +26,7 @@ func TestAccAWSDBEventSubscription_importBasic(t *testing.T) {
|
|||
ResourceName: resourceName,
|
||||
ImportState: true,
|
||||
ImportStateVerify: true,
|
||||
ImportStateId: subscriptionName,
|
||||
},
|
||||
},
|
||||
})
|
||||
|
|
|
@ -19,26 +19,26 @@ func resourceAwsDbEventSubscription() *schema.Resource {
|
|||
Update: resourceAwsDbEventSubscriptionUpdate,
|
||||
Delete: resourceAwsDbEventSubscriptionDelete,
|
||||
Importer: &schema.ResourceImporter{
|
||||
State: schema.ImportStatePassthrough,
|
||||
State: resourceAwsDbEventSubscriptionImport,
|
||||
},
|
||||
Schema: map[string]*schema.Schema{
|
||||
"name": &schema.Schema{
|
||||
"name": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
ForceNew: true,
|
||||
ValidateFunc: validateDbEventSubscriptionName,
|
||||
},
|
||||
"sns_topic": &schema.Schema{
|
||||
"sns_topic": {
|
||||
Type: schema.TypeString,
|
||||
Required: true,
|
||||
},
|
||||
"event_categories": &schema.Schema{
|
||||
"event_categories": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
Set: schema.HashString,
|
||||
},
|
||||
"source_ids": &schema.Schema{
|
||||
"source_ids": {
|
||||
Type: schema.TypeSet,
|
||||
Optional: true,
|
||||
Elem: &schema.Schema{Type: schema.TypeString},
|
||||
|
@ -46,16 +46,16 @@ func resourceAwsDbEventSubscription() *schema.Resource {
|
|||
// ValidateFunc: validateDbEventSubscriptionSourceIds,
|
||||
// requires source_type to be set, does not seem to be a way to validate this
|
||||
},
|
||||
"source_type": &schema.Schema{
|
||||
"source_type": {
|
||||
Type: schema.TypeString,
|
||||
Optional: true,
|
||||
},
|
||||
"enabled": &schema.Schema{
|
||||
"enabled": {
|
||||
Type: schema.TypeBool,
|
||||
Optional: true,
|
||||
Default: true,
|
||||
},
|
||||
"customer_aws_id": &schema.Schema{
|
||||
"customer_aws_id": {
|
||||
Type: schema.TypeString,
|
||||
Computed: true,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue