2016-06-20 2 views
0

AWS RDSが例外を表示する理由 - ステータスコード:400;エラーコード:InvalidParameterValue

はコード -

private static String getDBInstanceTag(AmazonRDS amazonRDS, String dbInstanceIdentifier, String region, String tagKey) { 

     log.info("Trying to fetch dbInstanceIdentifier - " + dbInstanceIdentifier + " in db instance region - " + region); 
     String arn = String.format("arn:aws:rds:" + region + ":%s:db:%s", 
       SyncJobConstants.AWSProperties.AWS_ACCOUNT_NUMBER, 
       dbInstanceIdentifier); 
     ListTagsForResourceResult tagsList = amazonRDS.listTagsForResource(
       new ListTagsForResourceRequest().withResourceName(arn)); 

     for(Tag tag : tagsList.getTagList()) { 
      if(tagKey.equalsIgnoreCase(tag.getKey())) { 
       return tag.getValue(); 
      } 
     } 

     throw new InternalProcessingException(tagKey + " is not present in given dbInstance - " + tagsList); 
    } 

    public static String getDBInstanceTag(String dbInstanceIdentifier, String tagKey) throws IOException { 

     AWSCredentials credentials = new PropertiesCredentials(
       RedshiftUtil.class.getClassLoader().getResourceAsStream("AWSCredentials.properties")); 
     AmazonRDS amazonRDS = new AmazonRDSClient(credentials); 

     DBInstance dbInstance = new DBInstance(); 
     dbInstance.setDBInstanceIdentifier(dbInstanceIdentifier); 

     for(String region : SyncJobConstants.AWSProperties.RDS_REGIONS) { 
      try { 
       return getDBInstanceTag(amazonRDS, dbInstanceIdentifier, region, tagKey); 
      } catch (DBInstanceNotFoundException e) { 
       log.info("dbInstanceIdentifier - " + dbInstanceIdentifier + " is not present in db instance region - " + region); 
      } catch (AmazonServiceException e) { 
       if ("AccessDenied".equals(e.getErrorCode())) { 
        log.info("dbInstanceIdentifier - " + dbInstanceIdentifier + " is not present in db instance region - " + region); 
       } else { 
        throw new InternalProcessingException("Not able to fetch dbInstance details from RDS. DBInstanceId - " + dbInstanceIdentifier, e); 
       } 
      } 
     } 

     throw new InvalidRequestException("RDS endpoint details is not correct."); 
    } 

DBインスタンスがあるにもかかわらず呼び出しのいくつかのエラーを投げています。エラーの詳細 -

 
Caused by: com.amazonaws.AmazonServiceException: The specified resource name does not match an RDS resource in this region. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterValue; Request ID: b0e01d56-36ca-11e6-8441-1968d9061f57) 
    at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:1182) 
    at com.amazonaws.http.AmazonHttpClient.executeOneRequest(AmazonHttpClient.java:770) 
    at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:489) 
    at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:310) 
    at com.amazonaws.services.rds.AmazonRDSClient.invoke(AmazonRDSClient.java:5197) 
    at com.amazonaws.services.rds.AmazonRDSClient.listTagsForResource(AmazonRDSClient.java:1997) 

あなたは私がここで行方不明です何を教えていただけますか?

エラーが

http://docs.aws.amazon.com/AWSEC2/latest/APIReference/errors-overview.html

をmeanings-アップデート2

 
public static final List RDS_REGIONS = Arrays.asList("us-east-1", 
       "us-west-1", 
       "us-west-2", 
       "eu-west-1", 
       "eu-central-1", 
       "ap-northeast-1", 
       "ap-northeast-2", 
       "ap-southeast-1", 
       "ap-southeast-2", 
       "sa-east-1"); 

答えて

0

は地域関連の問題のように思える - あなたのRDSインスタンスは地域US-EAST-1に位置していますか? (これはAmazon SDKのデフォルト領域です)

Amazon Webコンソールにログインし、地域を確認してください。正しい地域を設定して、もう一度お試しください。

参考:AWS Region Selection

関連する問題