Simone
07/27/2023, 12:52 AMRodney
07/27/2023, 12:56 AMSimone
07/27/2023, 1:18 PMjclausen
07/27/2023, 1:27 PMs3sdk v5.7.0+91 it should resolve your issue. That version adds the correct headers to deal with the changes noted in the link above.Simone
07/27/2023, 2:05 PMSimone
07/27/2023, 2:08 PMSimone
07/27/2023, 2:19 PMboolean function putBucket(
required string bucketName = variables.defaultBucketName,
string acl = variables.defaultACL,
string location = "",
string objectOwnership = variables.defaultObjectOwnership,
boolean BlockPublicAcls = false,
boolean IgnorePublicAcls = false,
boolean BlockPublicPolicy = false,
boolean RestrictPublicBuckets = false
){
requireBucketName( arguments.bucketName );
if(arguments.location == "EU") {
var constraintXML = "<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>"
} else if(arguments.location == 'ca-central-1') {
var constraintXML = "<CreateBucketConfiguration><LocationConstraint>ca-central-1</LocationConstraint></CreateBucketConfiguration>"
} else if(arguments.location == 'ap-southeast-2') {
var constraintXML = "<CreateBucketConfiguration><LocationConstraint>ap-southeast-2</LocationConstraint></CreateBucketConfiguration>"
} else {
var constraintXML = "";
}
var headers = { "content-type" : "text/xml" };
if ( len( arguments.objectOwnership ) ) {
if (
!listFindNoCase(
"BucketOwnerPreferred,ObjectWriter,BucketOwnerEnforced",
arguments.objectOwnership
)
) {
throw(
message = "Invalid value [#arguments.objectOwnership#] for [objectOwnership] when creating bucket.",
detail = "Valid options are: [BucketOwnerPreferred, ObjectWriter, BucketOwnerEnforced]"
);
}
headers[ "x-amz-object-ownership" ] = arguments.objectOwnership;
}
var results = s3Request(
method = "PUT",
resource = arguments.bucketName,
body = constraintXML,
headers = headers
);
// s3 does not provide a way to set this when creating the bucket
putBucketPublicAccess(
arguments.bucketName,
arguments.BlockPublicAcls,
arguments.IgnorePublicAcls,
arguments.BlockPublicPolicy,
arguments.RestrictPublicBuckets
);
// Must set ACL in second step in case public access settings above would prevent the ACL from being saved.
putBucketACL( arguments.bucketName, arguments.acl );
return results.responseheader.status_code == 200;
}Simone
07/27/2023, 5:13 PMSimone
07/27/2023, 5:13 PMbdw429s
07/27/2023, 5:22 PMThe bucket you are attempting to access must be addressed using the specified endpointSounds like you have the wrong region set in the SDK
bdw429s
07/27/2023, 5:23 PMseandaniels
07/27/2023, 5:24 PMgsr
07/27/2023, 6:48 PMbdw429s
07/27/2023, 7:00 PMbdw429s
07/27/2023, 7:00 PMSimone
07/27/2023, 7:00 PMSimone
07/27/2023, 7:01 PMbdw429s
07/27/2023, 7:01 PMLocationConstraint node dynamicSimone
07/27/2023, 7:01 PMbdw429s
07/27/2023, 7:02 PMvar constraintXML = "<CreateBucketConfiguration><LocationConstraint>#XMLFormat( arguments.location )#</LocationConstraint></CreateBucketConfiguration>";
and not be messing with the if statementsSimone
07/27/2023, 7:02 PMif(arguments.location == "EU") {
var constraintXML = "<CreateBucketConfiguration><LocationConstraint>EU</LocationConstraint></CreateBucketConfiguration>"
} else if(arguments.location == 'ca-central-1') {
var constraintXML = "<CreateBucketConfiguration><LocationConstraint>ca-central-1</LocationConstraint></CreateBucketConfiguration>"
} else if(arguments.location == 'ap-southeast-2') {
var constraintXML = "<CreateBucketConfiguration><LocationConstraint>ap-southeast-2</LocationConstraint></CreateBucketConfiguration>"
} else {
var constraintXML = "";
}bdw429s
07/27/2023, 7:03 PMbdw429s
07/27/2023, 7:03 PMbdw429s
07/27/2023, 7:03 PMSimone
07/27/2023, 7:03 PMSimone
07/27/2023, 7:04 PMSimone
07/27/2023, 7:06 PMSimone
07/27/2023, 7:18 PMSimone
07/27/2023, 7:19 PM// s3 does not provide a way to set this when creating the bucket
putBucketPublicAccess(
arguments.bucketName,
arguments.BlockPublicAcls,
arguments.IgnorePublicAcls,
arguments.BlockPublicPolicy,
arguments.RestrictPublicBuckets
);
// Must set ACL in second step in case public access settings above would prevent the ACL from being saved.
putBucketACL( arguments.bucketName, arguments.acl );Simone
07/28/2023, 1:05 PMbdw429s
07/28/2023, 3:45 PMbdw429s
07/28/2023, 3:46 PM