package mytest.test.aws;
import com.google.common.collect.ImmutableSet;
import org.jclouds.ContextBuilder;
import org.jclouds.aws.domain.Region;
import org.jclouds.blobstore.BlobStore;
import org.jclouds.blobstore.BlobStoreContext;
import org.jclouds.domain.Location;
import org.jclouds.domain.LocationBuilder;
import org.jclouds.domain.LocationScope;
import org.jclouds.logging.slf4j.config.SLF4JLoggingModule;
import java.util.Properties;
import static org.jclouds.location.reference.LocationConstants.PROPERTY_REGIONS;
public class AwsTestMain {
public static void main(String[] args) {
String containername = "mybcukettest-574t8w73tqqaasd";
Properties overrides = new Properties();
overrides.setProperty(PROPERTY_REGIONS, Region.CA_CENTRAL_1);
Iterable<? extends SLF4JLoggingModule> modules = ImmutableSet.<SLF4JLoggingModule>of(new SLF4JLoggingModule());
BlobStoreContext contextBuilder = ContextBuilder.newBuilder("aws-s3")
.credentials("xxxxxxxxxxxxxxxxxxxxxxx", "xxxxxxxxxxxxxxxxxxxxxxxx")
.overrides(overrides)
.modules(modules)
.buildView(BlobStoreContext.class);
BlobStore blobStore = contextBuilder.getBlobStore();
// Create Container
Location location = new LocationBuilder().scope(LocationScope.REGION)
.id(Region.CA_CENTRAL_1)
.description("region")
.build();
blobStore.createContainerInLocation(location, containername);
contextBuilder.close();
}
}
-------------------------------------------------------
12:28:53 PM: Executing task 'AwsTestMain.main()'...
> Task :compileJava UP-TO-DATE
> Task :compileGroovy NO-SOURCE
> Task :processResources UP-TO-DATE
> Task :classes UP-TO-DATE
> Task :compileTestJava
> Task :compileTestGroovy NO-SOURCE
> Task :processTestResources UP-TO-DATE
> Task :testClasses
> Task :AwsTestMain.main()
Exception in thread "main" java.lang.IllegalArgumentException: requested location us-standard, which is not in the configured locations: {ca-central-1=Suppliers.ofInstance(
https://s3-ca-central-1.amazonaws.com)}
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:145)
at org.jclouds.location.functions.RegionToEndpointOrProviderIfNull.apply(RegionToEndpointOrProviderIfNull.java:60)
at org.jclouds.location.functions.RegionToEndpointOrProviderIfNull.apply(RegionToEndpointOrProviderIfNull.java:37)
at com.google.common.base.Suppliers$SupplierComposition.get(Suppliers.java:67)
at org.jclouds.rest.internal.RestAnnotationProcessor.getEndpointFor(RestAnnotationProcessor.java:562)
at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:204)
at org.jclouds.rest.internal.RestAnnotationProcessor.apply(RestAnnotationProcessor.java:137)
at org.jclouds.rest.internal.InvokeHttpMethod.toCommand(InvokeHttpMethod.java:189)
at org.jclouds.rest.internal.InvokeHttpMethod.invoke(InvokeHttpMethod.java:85)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:74)
at org.jclouds.rest.internal.InvokeHttpMethod.apply(InvokeHttpMethod.java:45)
at org.jclouds.rest.internal.DelegatesToInvocationFunction.handle(DelegatesToInvocationFunction.java:156)
at org.jclouds.rest.internal.DelegatesToInvocationFunction.invoke(DelegatesToInvocationFunction.java:123)
at com.sun.proxy.$Proxy46.putBucketInRegion(Unknown Source)
at org.jclouds.s3.blobstore.S3BlobStore.createContainerInLocation(S3BlobStore.java:454)
at org.jclouds.aws.s3.blobstore.AWSS3BlobStore.createContainerInLocation(AWSS3BlobStore.java:105)
at org.jclouds.s3.blobstore.S3BlobStore.createContainerInLocation(S3BlobStore.java:146)
at mytest.test.aws.AwsTestMain.main(AwsTestMain.java:41)
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':AwsTestMain.main()'.
> Process 'command 'C:/Program Files/Java/jdk-11.0.5/bin/java.exe'' finished with non-zero exit value 1
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at
https://help.gradle.org
BUILD FAILED in 6s
> Task :AwsTestMain.main() FAILED
5 actionable tasks: 2 executed, 3 up-to-date
12:29:00 PM: Task execution finished 'AwsTestMain.main()'.