Example usage for com.amazonaws.services.ec2.model RouteTableAssociation getRouteTableAssociationId

List of usage examples for com.amazonaws.services.ec2.model RouteTableAssociation getRouteTableAssociationId

Introduction

In this page you can find the example usage for com.amazonaws.services.ec2.model RouteTableAssociation getRouteTableAssociationId.

Prototype


public String getRouteTableAssociationId() 

Source Link

Document

The ID of the association between a route table and a subnet.

Usage

From source file:com.infinitechaos.vpcviewer.web.rest.dto.RouteTableAssociationDTO.java

License:Open Source License

public RouteTableAssociationDTO(final RouteTableAssociation rta) {
    this.routeTableAssociationId = rta.getRouteTableAssociationId();
    this.routeTableId = rta.getRouteTableId();
    this.subnetId = rta.getSubnetId();
    this.main = rta.getMain();
}

From source file:com.urbancode.terraform.tasks.aws.RouteTableTask.java

License:Apache License

@Override
public void destroy() throws EnvironmentDestructionException {
    if (ec2Client == null) {
        ec2Client = context.fetchEC2Client();
    }/*from w ww .j a  v a 2  s .c om*/
    log.info("Destroying RouteTable...");

    try {
        // We need to check to see if the route table is associated with anything before disassociating
        String subnetId = ((EnvironmentTaskAWS) context.getEnvironment()).getVpc().findSubnetForName(subnetName)
                .getId();
        List<String> id = new ArrayList<String>();
        id.add(routeTableId);
        List<RouteTable> table = helper.getRouteTables(id, ec2Client);
        List<RouteTableAssociation> asses = table.get(0).getAssociations();
        if (asses != null && !asses.isEmpty()) {
            for (RouteTableAssociation ass : asses) {
                if (subnetId.equals(ass.getSubnetId())) {
                    if (ass.getRouteTableAssociationId() != null
                            && !ass.getRouteTableAssociationId().equals("")) {
                        helper.disassociateRouteTableFromSubnet(assId, ec2Client);
                    }
                }
            }
        }

        if (!isMainTable) {
            helper.deleteRouteTable(routeTableId, ec2Client);
        }

        setAssocId(null);
        setId(null);
    } catch (Exception e) {
        log.error("Unable to destroy RouteTable completely", e);
        throw new EnvironmentDestructionException("Could not destroy RouteTable", e);
    } finally {
        ec2Client = null;
    }
}