Example usage for com.amazonaws.services.ec2 AmazonEC2AsyncClient createSecurityGroup

List of usage examples for com.amazonaws.services.ec2 AmazonEC2AsyncClient createSecurityGroup

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2 AmazonEC2AsyncClient createSecurityGroup.

Prototype

CreateSecurityGroupResult createSecurityGroup(CreateSecurityGroupRequest createSecurityGroupRequest);

Source Link

Document

Creates a security group.

Usage

From source file:com.vmware.photon.controller.model.adapters.awsadapter.AWSUtils.java

License:Open Source License

public static String createSecurityGroup(AmazonEC2AsyncClient client, String name, String description,
        String vpcId) {// w w  w  . j av a  2s.co  m

    CreateSecurityGroupRequest req = new CreateSecurityGroupRequest().withDescription(description)
            .withGroupName(name);

    // set vpc for the security group if provided
    if (vpcId != null) {
        req = req.withVpcId(vpcId);
    }

    CreateSecurityGroupResult result = client.createSecurityGroup(req);

    return result.getGroupId();
}