Skip to content

Commit c6f8d25

Browse files
authored
service/s3: Adds Support for S3 AccessPoints (#476)
1 parent 9503cfa commit c6f8d25

File tree

120 files changed

+3524
-243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+3524
-243
lines changed

CHANGELOG_PENDING.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ SDK Features
1919
---
2020
* `aws`: `PartitionID` has been added to `aws.Endpoint` structure, and is used by the endpoint resolver to indicate which AWS partition an endpoint was resolved for ([#473](https://github.com/aws/aws-sdk-go-v2/pull/473))
2121
* `aws/endpoints`: Updated resolvers to populate `PartitionID` for a resolved `aws.Endpoint` ([#473](https://github.com/aws/aws-sdk-go-v2/pull/473))
22+
* `service/s3`: Add support for Access Point resources
23+
* Adds support for using Access Point resource with Amazon S3 API operation calls. The Access Point resource are identified by an Amazon Resource Name (ARN).
24+
* To make operation calls to an S3 Access Point instead of a S3 Bucket, provide the Access Point ARN string as the value of the Bucket parameter. You can create an Access Point for your bucket with the Amazon S3 Control API. The Access Point ARN can be obtained from the S3 Control API. You should avoid building the ARN directly.
2225

2326
SDK Enhancements
2427
---

aws/arn/arn.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,12 @@ func Parse(arn string) (ARN, error) {
7575
}, nil
7676
}
7777

78+
// IsARN returns whether the given string is an arn
79+
// by looking for whether the string starts with arn:
80+
func IsARN(arn string) bool {
81+
return strings.HasPrefix(arn, arnPrefix) && strings.Count(arn, ":") >= arnSections-1
82+
}
83+
7884
// String returns the canonical representation of the ARN
7985
func (arn ARN) String() string {
8086
return arnPrefix +

aws/arn/arn_test.go

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,44 @@ func TestParseARN(t *testing.T) {
8686
})
8787
}
8888
}
89+
90+
func TestIsARN(t *testing.T) {
91+
92+
cases := map[string]struct {
93+
In string
94+
Expect bool
95+
// Params
96+
}{
97+
"valid ARN slash resource": {
98+
In: "arn:aws:service:us-west-2:123456789012:restype/resvalue",
99+
Expect: true,
100+
},
101+
"valid ARN colon resource": {
102+
In: "arn:aws:service:us-west-2:123456789012:restype:resvalue",
103+
Expect: true,
104+
},
105+
"valid ARN resource": {
106+
In: "arn:aws:service:us-west-2:123456789012:*",
107+
Expect: true,
108+
},
109+
"empty sections": {
110+
In: "arn:::::",
111+
Expect: true,
112+
},
113+
"invalid ARN": {
114+
In: "some random string",
115+
},
116+
"invalid ARN missing resource": {
117+
In: "arn:aws:service:us-west-2:123456789012",
118+
},
119+
}
120+
121+
for name, c := range cases {
122+
t.Run(name, func(t *testing.T) {
123+
actual := IsARN(c.In)
124+
if e, a := c.Expect, actual; e != a {
125+
t.Errorf("expect %s valid %v, got %v", c.In, e, a)
126+
}
127+
})
128+
}
129+
}

0 commit comments

Comments
 (0)