aws-sdk-java icon indicating copy to clipboard operation
aws-sdk-java copied to clipboard

Provide a securityGroupExists(String name) method similar to the S3 bucketExists() one

Open axelfontaine opened this issue 13 years ago • 1 comments

Currently checking if a security group exists, one must catch an Exception:

try {
    amazonEC2.describeSecurityGroups(new DescribeSecurityGroupsRequest().withGroupNames(ec2SecurityGroup));
    return; //Success, it already exists.
} catch (AmazonServiceException e) {
    //The security group doesn't exist.
}

Having a dedicated method would make this much better.

axelfontaine avatar Jul 20 '13 08:07 axelfontaine

Since the ec2 client is code generated (s3 client is not though), we in general prefer to create separate utility classes for any high-level logic that does not directly map to an existing service API. The pull-request linked above looks promising. I will close this issue for now and work on getting that change merged asap.

hanshuo-aws avatar Apr 17 '15 18:04 hanshuo-aws