0

我正在尝试使用 Amazon AWS SDK 来开发 Eucalyptus,但我总是被拒绝访问:public class App {

public static  AmazonEC2 ec2;
public static AmazonS3 s3;
public static  AmazonIdentityManagement identityManagement;
private static String ACCESS_KEY;
private static String SECRET_KEY;
private static String IDENTITY_END_POINT;

public static void init(){
    ACCESS_KEY="myaccesskey";
        SECRET_KEY="mysecretkey";
    IDENTITY_END_POINT="http://192.168.1.101:8773/services/Euare";
    AWSCredentials myCredential = new BasicAWSCredentials(ACCESS_KEY,SECRET_KEY);
    //ec2 = new AmazonEC2Client(myCredential);
   s3 = new AmazonS3Client(myCredential);
   //ec2.setEndpoint(EC2_END_POINT);    
   s3.setEndpoint(Walrus_END_POINT);
    identityManagement=new AmazonIdentityManagementClient(myCredential);
    identityManagement.setEndpoint(IDENTITY_END_POINT);  
  }
public static void main(String[] args) {
    // TODO Auto-generated method stub

    init();

     List<Bucket> buckets = s3.listBuckets();

        System.out.println("List of all buckets in your cloud:\n");
        for (Bucket bucket : buckets) {
            System.out.println(bucket.getName()+"\n");
   }

       CreateUserRequest createUserRequest=new        CreateUserRequest().withPath("/").withUserName("summer");
CreateUserResult createUserResult=identityManagement.createUser(createUserRequest); 

这是我得到的错误:

线程“主”状态代码中的异常:404,AWS 服务:AmazonIdentityManagement,AWS 请求 ID:null,AWS 错误代码:null,AWS 错误消息:com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:614) 处为 null在 com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:312) 在 com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:165) 在 com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient.invoke(AmazonIdentityManagementClient.java :3130) com.amazonaws.services.identitymanagement.AmazonIdentityManagementClient.getUser(AmazonIdentityManagementClient.java:1201) com.test2.Group.main(Group.java:107)

4

1 回答 1

0

我不确定使用 IAM API 时会导致 404 的原因,您发布的代码似乎与发布的异常不匹配。

您没有说明您使用的是哪个版本的 Eucalyptus 和 AWS Java 开发工具包,但对于某些版本,需要在终端节点 URL 中添加 / 以便 AWS Java 开发工具包正确计算签名,例如对于 IAM:

“http://$EXALE:8773/services/Euare/”

但是,我认为这不会导致 404 问题。

您可以在此处找到有关将 AWS Java 开发工具包与 Eucalyptus 结合使用的详细信息:

https://github.com/eucalyptus/eucalyptus/wiki/HOWTO-Use-AWS-Java-SDK-with-Eucalyptus

使用 Eucalyptus 对 AWS Java 开发工具包进行单元测试:

https://github.com/eucalyptus/eutester/tree/testing/eutester4j/com/eucalyptus/tests/awssdk

这包括 IAM/STS 服务的一些覆盖范围。

于 2013-07-26T17:19:28.507 回答