diff --git a/builtin/providers/aws/import_aws_redshift_security_group_test.go b/builtin/providers/aws/import_aws_redshift_security_group_test.go new file mode 100644 index 000000000..1d304b5b6 --- /dev/null +++ b/builtin/providers/aws/import_aws_redshift_security_group_test.go @@ -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, + }, + }, + }) +} diff --git a/builtin/providers/aws/resource_aws_redshift_security_group.go b/builtin/providers/aws/resource_aws_redshift_security_group.go index 81195c164..84de59669 100644 --- a/builtin/providers/aws/resource_aws_redshift_security_group.go +++ b/builtin/providers/aws/resource_aws_redshift_security_group.go @@ -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{ diff --git a/website/source/docs/providers/aws/r/redshift_security_group.html.markdown b/website/source/docs/providers/aws/r/redshift_security_group.html.markdown index 79918c632..d3a83c4ce 100644 --- a/website/source/docs/providers/aws/r/redshift_security_group.html.markdown +++ b/website/source/docs/providers/aws/r/redshift_security_group.html.markdown @@ -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 +```