Example usage for com.amazonaws.services.ec2.model InternetGatewayAttachment getVpcId

List of usage examples for com.amazonaws.services.ec2.model InternetGatewayAttachment getVpcId

Introduction

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

Prototype


public String getVpcId() 

Source Link

Document

The ID of the VPC.

Usage

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

License:Apache License

public boolean verify() {
    // will return false if the id is null
    boolean result = false;
    if (gatewayId != null) {
        if (ec2Client == null) {
            ec2Client = context.fetchEC2Client();
        }/*  w w  w.j a v a2s  . co  m*/

        List<String> id = new ArrayList<String>();
        id.add(gatewayId);

        List<InternetGateway> gateways = helper.getInternetGateways(id, ec2Client);
        if (gateways != null && !gateways.isEmpty()) {
            for (InternetGateway gateway : gateways) {
                List<InternetGatewayAttachment> attachments = gateway.getAttachments();
                if (attachments != null && !attachments.isEmpty()) {
                    for (InternetGatewayAttachment attachment : attachments) {
                        String attachedVpc = attachment.getVpcId();
                        if (vpcId.equals(attachedVpc)) {
                            result = true;
                        }
                    }
                }
            }
        }
    }
    return result;
}