Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a computed ARN for the S3 Bucket as per #3666 #3685

Merged
merged 1 commit into from
Oct 29, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions builtin/providers/aws/resource_aws_s3_bucket.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ func resourceAwsS3Bucket() *schema.Resource {
ForceNew: true,
},

"arn": &schema.Schema{
Type: schema.TypeString,
Optional: true,
Computed: true,
},

"acl": &schema.Schema{
Type: schema.TypeString,
Default: "private",
Expand Down Expand Up @@ -376,6 +382,8 @@ func resourceAwsS3BucketRead(d *schema.ResourceData, meta interface{}) error {
return err
}

d.Set("arn", fmt.Sprint("arn:aws:s3:::", d.Id()))

return nil
}

Expand Down
7 changes: 7 additions & 0 deletions builtin/providers/aws/resource_aws_s3_bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"math/rand"
"reflect"
"regexp"
"strconv"
"testing"
"time"
Expand All @@ -17,6 +18,10 @@ import (
)

func TestAccAWSS3Bucket_basic(t *testing.T) {

arnRegexp := regexp.MustCompile(
"^arn:aws:s3:::")

resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
Expand All @@ -32,6 +37,8 @@ func TestAccAWSS3Bucket_basic(t *testing.T) {
"aws_s3_bucket.bucket", "region", "us-west-2"),
resource.TestCheckResourceAttr(
"aws_s3_bucket.bucket", "website_endpoint", ""),
resource.TestMatchResourceAttr(
"aws_s3_bucket.bucket", "arn", arnRegexp),
),
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ The versioning supports the following:
The following attributes are exported:

* `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.
* `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.
Expand Down