Class: AWS::Vpccreate
- Inherits:
-
Object
- Object
- AWS::Vpccreate
- Defined in:
- lib/aws-vpccreate.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#vpc ⇒ Object
readonly
Returns the value of attribute vpc.
Instance Method Summary collapse
- #create_ig ⇒ Object
- #create_rt(options = {}) ⇒ Object
- #create_sg(name, options = {}) ⇒ Object
- #create_subnet(cidr_block, options = {}) ⇒ Object
- #create_vpc(cidr_block, options = {}) ⇒ Object
-
#initialize(ec2) ⇒ Vpccreate
constructor
A new instance of Vpccreate.
Constructor Details
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
29 30 31 |
# File 'lib/aws-vpccreate.rb', line 29 def logger @logger end |
#vpc ⇒ Object (readonly)
Returns the value of attribute vpc.
29 30 31 |
# File 'lib/aws-vpccreate.rb', line 29 def vpc @vpc end |
Instance Method Details
#create_ig ⇒ Object
57 58 59 60 61 62 63 |
# File 'lib/aws-vpccreate.rb', line 57 def create_ig raise "no vpc instance" if @vpc == nil ig = @ec2.internet_gateways.create ig.attach @vpc ig end |
#create_rt(options = {}) ⇒ Object
76 77 78 79 80 81 |
# File 'lib/aws-vpccreate.rb', line 76 def create_rt = {} raise "no vpc instance" if @vpc == nil [:vpc] = @vpc @ec2.route_tables.create() end |
#create_sg(name, options = {}) ⇒ Object
65 66 67 68 69 70 71 72 73 74 |
# File 'lib/aws-vpccreate.rb', line 65 def create_sg name, = {} raise "no vpc instance" if @vpc == nil @logger.put({ :key => :security_group, :value => { :name => name, :description => [:description]}}) [:vpc] = @vpc @ec2.security_groups.create(name, ) end |
#create_subnet(cidr_block, options = {}) ⇒ Object
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/aws-vpccreate.rb', line 46 def create_subnet cidr_block, = {} raise "no vpc instance" if @vpc == nil @logger.put({:key => :subnets, :value => {:subnet_addr => cidr_block, :availability_zone => [:availability_zone]}}) [:vpc] = @vpc @ec2.subnets.create(cidr_block, ) end |
#create_vpc(cidr_block, options = {}) ⇒ Object
37 38 39 40 41 42 43 44 |
# File 'lib/aws-vpccreate.rb', line 37 def create_vpc cidr_block, = {} @vpc = @ec2.vpcs.create(cidr_block, ) @logger.put({:key => :vpc_subnet, :value => cidr_block}) @logger.put({:key => :vpc_id, :value => @vpc.id}) @vpc end |