Giter Site home page Giter Site logo

Comments (1)

stevenjack avatar stevenjack commented on July 20, 2024

@yumpy I'd say that's a pretty good way of extending cfndsl for your needs, there's only a ref optimisations you could make such as:

  EC2_SecurityGroupEgress("#{name}Egress") {
      GroupId Ref(source)
      IpProtocol protocol
      FromPort port
      ToPort port
      DestinationSecurityGroupId destination
  }

  EC2_SecurityGroupIngress("#{name}Ingress") {
      GroupId destination
      IpProtocol protocol
      FromPort port
      ToPort port
      SourceSecurityGroupId Ref(source)
      SourceSecurityGroupOwnerId SG_OWNER_ID
    } 

Under the GroupId property do the reference there so when you pass in the names you don't have to wrap each one in a ref:

 EC2_SecurityGroupPermission("WebToDB1443", :sgWeb, :sgDB, "tcp", "1443")

Also, if you're creating a lot of security groups then you could DRY it up a little bit by doing the following:

sg_names = %w{sgWeb, sgDB}

sg_names.each do |sg_name|
  EC2_SecurityGroup(sg_name.to_sym) {
    GroupDescription sg_name
    VpcId VPC
    SecurityGroupIngress []
    SecurityGroupEgress []
  }
end

To loop through the the names in sg_names and create the groups.

from cfndsl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.