2016-06-20 5 views
0

Warum AWS RDS eine Ausnahme zeigt - Statuscode: 400; Fehlercode: InvalidParameterValue

-Code -

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."); 
    } 

Es ist für einige der Anrufe, obwohl db Fällen Fehler zu werfen ist da. Fehlerdetail -

 
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) 

Können Sie mir bitte sagen, was ich hier vermisse?

Fehler Bedeutungen

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

aktualisieren 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"); 

Antwort

0

Scheint wie eine Region verwandtes Problem - Ist Ihr RDS-Instanz in der Region US-EAST-1 liegt (das ist die Standardregion von Amazon SDK)

Melden Sie sich bei der Amazon Webkonsole an und bestätigen Sie die Region. Stellen Sie die richtige Region ein und versuchen Sie es erneut.

Referenz: AWS Region Selection

Verwandte Themen