You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There was a discussion i saw on CFML Slack Channel where one of the Guys' named @simone has shared some details that the Creating of Buckets is not working, I replicated the cases he mentioned and noticed something, the Buckets do get Created with an error, but the Permissions are set to block access all.
Here is the Code he used for Creating Buckets
He Modified the code as below:
boolean 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;
}
so in the above I see he added some conditions in the constraintXML which makes the code to check which region it has to choose and create
Thanks
The text was updated successfully, but these errors were encountered:
My feedback here is pretty much the same as it was on Slack. If someone knows the correct code to work, please send a pull request. But ideally, we'd use some code a bit more generic and not a big if statement with nearly identical XML blocks for each region.
There was a discussion i saw on CFML Slack Channel where one of the Guys' named @simone has shared some details that the Creating of Buckets is not working, I replicated the cases he mentioned and noticed something, the Buckets do get Created with an error, but the Permissions are set to block access all.
Here is the Code he used for Creating Buckets
He Modified the code as below:
so in the above I see he added some conditions in the constraintXML which makes the code to check which region it has to choose and create
Thanks
The text was updated successfully, but these errors were encountered: