Sha256: 8a614841770ed3b71b54c6a4ffecbd35a9193cc2734bc65f66b0b66d8c11064f

Contents?: true

Size: 1.44 KB

Versions: 1

Compression:

Stored size: 1.44 KB

Contents

require_relative '../resource'

module Convection
  module Model
    class Template
      class Resource
        ##
        # AWS::EC2::Instance
        ##
        class EC2Instance < Resource
          include Model::Mixin::Taggable

          def initialize(*args)
            super

            type 'AWS::EC2::Instance'
            @properties['SecurityGroupIds'] = []
          end

          def availability_zone(value)
            property('AvailabilityZone', value)
          end

          def image_id(value)
            property('ImageId', value)
          end

          def instance_type(value)
            property('InstanceType', value)
          end

          def key_name(value)
            property('KeyName', value)
          end

          def security_group(value)
            @properties['SecurityGroupIds'] << value
          end

          def subnet(value)
            property('SubnetId', value)
          end

          def user_data(value)
            property('UserData', value)
          end

          def render(*args)
            super.tap do |resource|
              render_tags(resource)
            end
          end
        end
      end
    end
  end

  module DSL
    ## Add DSL method to template namespace
    module Template
      def ec2_instance(name, &block)
        r = Model::Template::Resource::EC2Instance.new(name, self)

        r.instance_exec(&block) if block
        resources[name] = r
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
convection-0.0.1 lib/convection/model/template/resource/aws_ec2_instance.rb