@@ -211,24 +211,14 @@ private IamPolicy policyString(
211211 Map <String , IamStatement .Builder > bucketGetLocationStatementBuilder = new HashMap <>();
212212
213213 String arnPrefix = arnPrefixForPartition (awsPartition );
214- boolean isEcsPartition = "ecs" .equals (awsPartition );
215214 Stream .concat (readLocations .stream (), writeLocations .stream ())
216215 .distinct ()
217216 .forEach (
218217 location -> {
219218 URI uri = URI .create (location );
220- // Some on-prem S3/STSc implementations (for example ECS) do not accept object ARNs
221- // that include the path portion (bucket/key/*). For those, scope object permissions
222- // to
223- // the whole bucket (bucket/*) and rely on s3:prefix conditions for finer granularity.
224- if (isEcsPartition ) {
225- allowGetObjectStatementBuilder .addResource (
226- IamResource .create (arnPrefix + StorageUtil .getBucket (uri ) + "/*" ));
227- } else {
228- allowGetObjectStatementBuilder .addResource (
229- IamResource .create (
230- arnPrefix + StorageUtil .concatFilePrefixes (parseS3Path (uri ), "*" , "/" )));
231- }
219+ allowGetObjectStatementBuilder .addResource (
220+ IamResource .create (
221+ arnPrefix + StorageUtil .concatFilePrefixes (parseS3Path (uri ), "*" , "/" )));
232222 final var bucket = arnPrefix + StorageUtil .getBucket (uri );
233223 if (allowList ) {
234224 bucketListStatementBuilder
@@ -262,14 +252,9 @@ private IamPolicy policyString(
262252 writeLocations .forEach (
263253 location -> {
264254 URI uri = URI .create (location );
265- if (isEcsPartition ) {
266- allowPutObjectStatementBuilder .addResource (
267- IamResource .create (arnPrefix + StorageUtil .getBucket (uri ) + "/*" ));
268- } else {
269- allowPutObjectStatementBuilder .addResource (
270- IamResource .create (
271- arnPrefix + StorageUtil .concatFilePrefixes (parseS3Path (uri ), "*" , "/" )));
272- }
255+ allowPutObjectStatementBuilder .addResource (
256+ IamResource .create (
257+ arnPrefix + StorageUtil .concatFilePrefixes (parseS3Path (uri ), "*" , "/" )));
273258 });
274259 policyBuilder .addStatement (allowPutObjectStatementBuilder .build ());
275260 }
@@ -290,13 +275,7 @@ private IamPolicy policyString(
290275 }
291276
292277 private static String arnPrefixForPartition (String awsPartition ) {
293- // Some on-prem S3 compatible systems (e.g. ECS) use a non-standard partition value
294- // but expect S3 resource ARNs to use the 'aws' partition form (arn:aws:s3:::bucket).
295- String partition = awsPartition != null ? awsPartition : "aws" ;
296- if ("ecs" .equals (partition )) {
297- partition = "aws" ;
298- }
299- return String .format ("arn:%s:s3:::" , partition );
278+ return String .format ("arn:%s:s3:::" , awsPartition != null ? awsPartition : "aws" );
300279 }
301280
302281 private static @ Nonnull String parseS3Path (URI uri ) {
0 commit comments