1

我有一個與Amazon SimpleDB進行通信的應用程序。在本地主機上運行時,一切正常,我將此webapp部署到Tomcat實例。無法從Elastic Beanstalk連接到Amazon SimpleDB

我在我的本地Tomcat以及部署應用程序的Elastic Beanstalk上指定了AWS憑據作爲環境變量。

然而,在彈性魔豆,我得到一個自動裝配異常(這是一個春天啓動的應用程序),這是由以下原因造成的:

Caused by: com.amazonaws.AmazonServiceException: User (arn:aws:sts::295923482971:assumed-role/aws-elasticbeanstalk-ec2-role/i-b35eef66) does not have permission to perform (sdb:ListDomains) on resource (arn:aws:sdb:us-east-1:295923482971:domain/). Contact account owner. (Service: AmazonSimpleDB; Status Code: 403; Error Code: AuthorizationFailure; Request ID: a20f4ed9-a54d-ec13-2886-b5d31cce3778) 
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1088) 
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:735) 
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:461) 
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:296) 
    at com.amazonaws.services.simpledb.AmazonSimpleDBClient.invoke(AmazonSimpleDBClient.java:1021) 
    at com.amazonaws.services.simpledb.AmazonSimpleDBClient.listDomains(AmazonSimpleDBClient.java:708) 
    at com.amazonaws.services.simpledb.AmazonSimpleDBClient.listDomains(AmazonSimpleDBClient.java:974) 
    at com.berrycloud.paypal.service.impl.SimpleDBServiceImpl.init(SimpleDBServiceImpl.java:53) 
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) 
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 
    at java.lang.reflect.Method.invoke(Method.java:497) 
    at 

這種情況出現,我自動裝配類的啓動過程中下面的代碼:

@PostConstruct 
    private void init() { 
    log.debug("Setting database client endpoint: {}", endpoint); 
    client.setEndpoint(endpoint); 

    // check if the domain exists 
    log.debug("Listing existing domains..."); 

    final List<String> tableNames = client.listDomains().getDomainNames(); 
    if (!tableNames.contains(domain)) { 
     // if not, create it 
     log.debug("Creating domain {}", domain); 
     client.createDomain(new CreateDomainRequest(domain)); 
    } 
    } 

我使用的是相同的AWS憑據在本地和彈性魔豆,所以我不明白爲什麼它在第一種情況下工作,但在其他失敗。有人可以幫我嗎?

回答

1

你有任何用戶的政策?通常,這意味着IAM政策是不夠好,你可以閱讀更多here

你可以嘗試添加:

{ 
    "Version": "2015-09-14", 
    "Statement":[{ 
     "Effect":"Allow", 
     "Action":"sdb:ListDomains", 
     "Resource":"arn:aws:sdb:us-east-1:295923482971:domain/<youraccount>" 
     } 
    ] 
} 
+0

但如果用戶與我正在使用的憑據相關的不具備此策略,那麼首先它不會在本地主機上正常工作?因爲我能夠從我的本地機器使用這些憑據連接到SimpleDB ... – Smajl

+0

正確的,我看到..我不知道,我沒有安裝重現,但也許內部aws服務,還有其他檢查 –

0

甚至有弄清楚的政策缺什麼簡單的方式通過使用

PolicySimulator from AWS

  • 選擇服務要模擬爲
  • 選擇操作有關該服務
  • 既可以使用現有的策略,或創建一個新的臨時政策來試試吧

enter image description here

相關問題