provider/aws: Support import of `aws_s3_bucket` (#8262)

This commit is contained in:
KOJIMA Kazunori 2016-08-19 00:01:20 +09:00 committed by Paul Stack
parent 1c67295f76
commit 23d2ae3740
3 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,32 @@
package aws
import (
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
)
func TestAccAWSS3Bucket_importBasic(t *testing.T) {
resourceName := "aws_s3_bucket.bucket"
rInt := acctest.RandInt()
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testAccCheckAWSS3BucketDestroy,
Steps: []resource.TestStep{
resource.TestStep{
Config: testAccAWSS3BucketConfig(rInt),
},
resource.TestStep{
ResourceName: resourceName,
ImportState: true,
ImportStateVerify: true,
ImportStateVerifyIgnore: []string{
"force_destroy", "acl"},
},
},
})
}

View File

@ -23,6 +23,9 @@ func resourceAwsS3Bucket() *schema.Resource {
Read: resourceAwsS3BucketRead,
Update: resourceAwsS3BucketUpdate,
Delete: resourceAwsS3BucketDelete,
Importer: &schema.ResourceImporter{
State: schema.ImportStatePassthrough,
},
Schema: map[string]*schema.Schema{
"bucket": &schema.Schema{

View File

@ -249,3 +249,11 @@ The following attributes are exported:
* `region` - The AWS region this bucket resides in.
* `website_endpoint` - The website endpoint, if the bucket is configured with a website. If not, this will be an empty string.
* `website_domain` - The domain of the website endpoint, if the bucket is configured with a website. If not, this will be an empty string. This is used to create Route 53 alias records.
## Import
S3 bucket can be imported using the `bucket`, e.g.
```
$ terraform import aws_s3_bucket.bucket bucket-name
```