Class: Serverspec::Type::AWS::EC2::InternetGateway

Inherits:
Base
  • Object
show all
Defined in:
lib/resources/ec2/internet_gateway.rb

Overview

The InternetGateway class exposes the EC2::InternetGateway resources

Instance Method Summary collapse

Constructor Details

#initialize(igw_id, instance = nil) ⇒ InternetGateway

AWS SDK for Ruby v2 Aws::EC2::Client wrapper for initializing an InternetGateway resource

Parameters:

  • igw_id (String)

    The ID of the InternetGateway

  • instance (Class) (defaults to: nil)

    Aws::EC2::Client instance

Raises:

  • (RuntimeError)

    if igws.nil?

  • (RuntimeError)

    if igws.length == 0

  • (RuntimeError)

    if igws.length > 1



15
16
17
18
19
20
# File 'lib/resources/ec2/internet_gateway.rb', line 15

def initialize(igw_id, instance = nil)
  check_init_arg 'igw_id', 'EC2::InternetGateway', igw_id
  @igw_id = igw_id
  @aws = instance.nil? ? Aws::EC2::Client.new : instance
  get_igw igw_id
end

Instance Method Details

#attachmentsArray(Hash)

Any VPCs attached to the InternetGateway

Returns:

  • (Array(Hash))


41
42
43
44
45
46
# File 'lib/resources/ec2/internet_gateway.rb', line 41

def attachments
  # usually you shouldn't use this as attachments is returned as
  # Array, but at least the AWS console doesn't allow more than one
  # VPC per InternetGateway
  @igw.attachments
end

#available?Boolean

Returns whether the state of the attachment is available

Returns:

  • (Boolean)


29
30
31
# File 'lib/resources/ec2/internet_gateway.rb', line 29

def available?
  @igw.attachments[0].state == 'available'
end

#tagsArray(Hash)

Any tags assigned to the InternetGateway

Returns:

  • (Array(Hash))


50
51
52
# File 'lib/resources/ec2/internet_gateway.rb', line 50

def tags
  @igw.tags
end

#to_sString

Returns the string representation of EC2::InternetGateway

Returns:

  • (String)


24
25
26
# File 'lib/resources/ec2/internet_gateway.rb', line 24

def to_s
  "EC2 InternetGateway: #{@igw_id}"
end

#vpc_idString

The ID of the VPC attached to the InternetGateway

Returns:

  • (String)


35
36
37
# File 'lib/resources/ec2/internet_gateway.rb', line 35

def vpc_id
  @igw.attachments[0].vpc_id
end