Merge pull request #7896 from hashicorp/import-aws-redshiftsg

provider/aws: Support Import of `aws_redshift_security_group`
This commit is contained in:
James Nugent 2016-08-01 19:43:27 -05:00 committed by GitHub
commit acb6fb5422
3 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,33 @@
package aws
import (
"os"
"testing"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAWSRedshiftSecurityGroup_importBasic(t *testing.T) {
oldvar := os.Getenv("AWS_DEFAULT_REGION")
os.Setenv("AWS_DEFAULT_REGION", "us-east-1")
defer os.Setenv("AWS_DEFAULT_REGION", oldvar)
resourceName := "aws_redshift_security_group.bar"
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSRedshiftSecurityGroupDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSRedshiftSecurityGroupConfig_ingressCidr,
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
},
},
})
}

View File

@ -22,6 +22,9 @@ func resourceAwsRedshiftSecurityGroup() *schema.Resource {
Read: resourceAwsRedshiftSecurityGroupRead,
Update: resourceAwsRedshiftSecurityGroupUpdate,
Delete: resourceAwsRedshiftSecurityGroupDelete,
Importer: &schema.ResourceImporter{
State: resourceAwsRedshiftClusterImport,
},
Schema: map[string]*schema.Schema{
"name": &schema.Schema{

View File

@ -43,3 +43,10 @@ The following attributes are exported:
* `id` - The Redshift security group ID.
## Import
Redshift security groups can be imported using the `name`, e.g.
```
$ terraform import aws_redshift_security_group.testgroup1 redshift_test_group
```