-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EC2 Dry-Runs #76
Comments
Bump. I think it should be a common feature of the SDK applicable to all requests. Otherwise it is difficult to check if we have all the required permissions to execute some task before actually starting the whole process. |
After merging above PR , we can get the dry run status as below Sync Client // Lets consider we want to find the dryRun Status for describeRegions API
boolean dryRunComplete = isDryRunComplete(() -> ec2Client.describeRegions(r -> r.regionNames(Region.US_EAST_1.id()).dryRun(true)));
// Write a generic Private API that takes in any EC2 Operation , make sure dryRun flag is set and extract the Error response
private boolean isDryRunComplete(Supplier<Ec2Response> dryRunOp) {
Ec2Response ec2Response = null;
try {
ec2Response = dryRunOp.get();
} catch (Ec2Exception exception) {
AwsErrorDetails awsErrorDetails = exception.awsErrorDetails();
if ("AuthFailure".equals(awsErrorDetails.errorCode())) {
return false;
}
if ("DryRunOperation".equals(awsErrorDetails.errorCode())) {
return true;
}
throw exception;
}
throw new IllegalStateException("Unable to get dryRun status for ec2Response: " + ec2Response);
}
Async Client Boolean isDryRunComplete = asyncClient.describeRegions(r -> r.regionNames(Region.US_EAST_1.id())
.dryRun(true))
.handle((resp, e) -> isDryRunCompleted(e))
.join();
// Write a generic Private API that gets the DryRun status from the exception
private static Boolean isDryRunCompleted(Throwable exceptionCaught) {
if(exceptionCaught.getCause() instanceof Ec2Exception){
Ec2Exception exception = (Ec2Exception) exceptionCaught.getCause();
AwsErrorDetails awsErrorDetails = exception.awsErrorDetails();
if ("AuthFailure".equals(awsErrorDetails.errorCode())) {
return false;
}
if ("DryRunOperation".equals(awsErrorDetails.errorCode())) {
return true;
}
}
throw new IllegalStateException(exceptionCaught.getCause());
} |
|
In 1.11.x, customers can execute certain EC2 requests as a "dry-run" request. This adds a special header to tell EC2 to not actually execute the request.
Support for this feature should be added in 2.0.
The text was updated successfully, but these errors were encountered: