Class: Ufo::Stack::Builder::Resources::SecurityGroup::Ecs

Inherits:
Base
  • Object
show all
Defined in:
lib/ufo/stack/builder/resources/security_group/ecs.rb

Instance Method Summary collapse

Methods inherited from Base

build, #copy_instance_variables, #initialize, #managed_security_group, #managed_security_groups?, #security_groups

Methods included from Ufo::Settings

#cfn, #network, #settings

Constructor Details

This class inherits a constructor from Ufo::Stack::Builder::Base

Instance Method Details

#buildObject



3
4
5
6
7
8
9
10
# File 'lib/ufo/stack/builder/resources/security_group/ecs.rb', line 3

def build
  return unless managed_security_groups?

  {
    Type: "AWS::EC2::SecurityGroup",
    Properties: properties
  }
end

#propertiesObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/ufo/stack/builder/resources/security_group/ecs.rb', line 12

def properties
  props = {
    GroupDescription: "Allow http to client host",
    VpcId: {Ref: "Vpc"},
    SecurityGroupEgress: [
      {
        IpProtocol: "-1",
        CidrIp: "0.0.0.0/0",
        Description: "outbound traffic"
      }
    ],
    Tags: [
      {
        Key: "Name",
        Value: @stack_name,
      }
    ]
  }

  if @elb_type == "network"
    props[:SecurityGroupIngress] = {
      IpProtocol: "tcp",
      FromPort: @container[:port],
      ToPort: @container[:port],
      CidrIp: "0.0.0.0/0",
      Description: "docker ephemeral port range for network elb",
    }
  end

  props
end