Question

Using JClouds, up to version 1.6.x it was possible to access to the native EC2 provider API by using the following idiom:

AWSEC2Client ec2Client = AWSEC2Client.class.cast(context.getProviderSpecificContext().getApi());

Actually, I copied from the documentation page: http://jclouds.apache.org/guides/aws/

It turns out that in the latest release this method has been removed. Is there an alternative method/way to access to the provider specific features (security groups, key-pairs, etc)?

Was it helpful?

Solution

Unwrapping the API from the ComputeServiceContext

ComputeServiceContext context = ContextBuilder.newBuilder("aws-ec2")
    .credentials("accessKey", "secretAccessKey")
    .buildView(ComputeServiceContext.class);
ComputeService computeService = context.getComputeService();
AWSEC2Api ec2Api = context.unwrapApi(AWSEC2Api.class);

Building the API directly

AWSEC2Api ec2Api = ContextBuilder.newBuilder("aws-ec2")
    .credentials("accessKey", "secretAccessKey")
    .buildApi(AWSEC2Api.class);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top