Merge pull request #3685 from stack72/f-aws-s3bucket-arn
Adding a computed ARN for the S3 Bucket as per #3666
This commit is contained in:
commit
cc0b941ba2
|
@ -28,6 +28,12 @@ func resourceAwsS3Bucket() *schema.Resource {
|
||||||
ForceNew: true,
|
ForceNew: true,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"arn": &schema.Schema{
|
||||||
|
Type: schema.TypeString,
|
||||||
|
Optional: true,
|
||||||
|
Computed: true,
|
||||||
|
},
|
||||||
|
|
||||||
"acl": &schema.Schema{
|
"acl": &schema.Schema{
|
||||||
Type: schema.TypeString,
|
Type: schema.TypeString,
|
||||||
Default: "private",
|
Default: "private",
|
||||||
|
@ -376,6 +382,8 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
d.Set("arn", fmt.Sprint("arn:aws:s3:::", d.Id()))
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"reflect"
|
"reflect"
|
||||||
|
"regexp"
|
||||||
"strconv"
|
"strconv"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -17,6 +18,10 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestAccAWSS3Bucket_basic(t *testing.T) {
|
func TestAccAWSS3Bucket_basic(t *testing.T) {
|
||||||
|
|
||||||
|
arnRegexp := regexp.MustCompile(
|
||||||
|
"^arn:aws:s3:::")
|
||||||
|
|
||||||
resource.Test(t, resource.TestCase{
|
resource.Test(t, resource.TestCase{
|
||||||
PreCheck: func() { testAccPreCheck(t) },
|
PreCheck: func() { testAccPreCheck(t) },
|
||||||
Providers: testAccProviders,
|
Providers: testAccProviders,
|
||||||
|
@ -32,6 +37,8 @@ func TestAccAWSS3Bucket_basic(t *testing.T) {
|
||||||
"aws_s3_bucket.bucket", "region", "us-west-2"),
|
"aws_s3_bucket.bucket", "region", "us-west-2"),
|
||||||
resource.TestCheckResourceAttr(
|
resource.TestCheckResourceAttr(
|
||||||
"aws_s3_bucket.bucket", "website_endpoint", ""),
|
"aws_s3_bucket.bucket", "website_endpoint", ""),
|
||||||
|
resource.TestMatchResourceAttr(
|
||||||
|
"aws_s3_bucket.bucket", "arn", arnRegexp),
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
@ -107,6 +107,7 @@ The versioning supports the following:
|
||||||
The following attributes are exported:
|
The following attributes are exported:
|
||||||
|
|
||||||
* `id` - The name of the bucket.
|
* `id` - The name of the bucket.
|
||||||
|
* `arn` - The ARN of the bucket. Will be of format `arn:aws:s3:::bucketname`
|
||||||
* `hosted_zone_id` - The [Route 53 Hosted Zone ID](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints) for this bucket's region.
|
* `hosted_zone_id` - The [Route 53 Hosted Zone ID](http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_website_region_endpoints) for this bucket's region.
|
||||||
* `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.
|
||||||
|
|
Loading…
Reference in New Issue