provider/aws: Support import of `aws_s3_bucket` (#8262)
This commit is contained in:
parent
1c67295f76
commit
23d2ae3740
|
@ -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"},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
})
|
||||||
|
}
|
|
@ -23,6 +23,9 @@ func resourceAwsS3Bucket() *schema.Resource {
|
||||||
Read: resourceAwsS3BucketRead,
|
Read: resourceAwsS3BucketRead,
|
||||||
Update: resourceAwsS3BucketUpdate,
|
Update: resourceAwsS3BucketUpdate,
|
||||||
Delete: resourceAwsS3BucketDelete,
|
Delete: resourceAwsS3BucketDelete,
|
||||||
|
Importer: &schema.ResourceImporter{
|
||||||
|
State: schema.ImportStatePassthrough,
|
||||||
|
},
|
||||||
|
|
||||||
Schema: map[string]*schema.Schema{
|
Schema: map[string]*schema.Schema{
|
||||||
"bucket": &schema.Schema{
|
"bucket": &schema.Schema{
|
||||||
|
|
|
@ -249,3 +249,11 @@ The following attributes are exported:
|
||||||
* `region` - The AWS region this bucket resides in.
|
* `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_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.
|
* `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
|
||||||
|
```
|
||||||
|
|
Loading…
Reference in New Issue