Code Monkey home page Code Monkey logo

Comments (4)

CarlInglisBJSS avatar CarlInglisBJSS commented on June 3, 2024

I implimented this for our route tables by having a little Ruby script that used the AWS SDK to count the subnets. Shouldn't be difficult to impliment using the SDK to count the SGs for your instance.

from awspec.

sveronese avatar sveronese commented on June 3, 2024

@CarlInglisBJSS thank you for your answer. I tried to implement in awspec with something like in type/ec2.rb

    def security_group_count
      resource_via_client.security_groups.reduce(0) do |sum, sg|
       sum += sg.group_id.count  
      end
    end

But it seems I have something like:

     Failure/Error: its(:security_group_count) { should eq 1 }

     NoMethodError:
       undefined method `security_group_count' for #<Aws::EC2::Instance id="i-0b48e61d85ea5ee57">
     # /Users/sveronese/.rvm/gems/ruby-2.2.4@awspec/gems/awspec-0.61.0/lib/awspec/resource_reader.rb:11:in `method_missing_via_black_list'
     # /Users/sveronese/.rvm/gems/ruby-2.2.4@awspec/gems/awspec-0.61.0/lib/awspec/resource_reader.rb:51:in `method_missing'
     # /Users/sveronese/.rvm/gems/ruby-2.2.4@awspec/gems/awspec-0.61.0/lib/awspec/resource_reader.rb:11:in `method_missing_via_black_list'
     # /Users/sveronese/.rvm/gems/ruby-2.2.4@awspec/gems/awspec-0.61.0/lib/awspec/type/base.rb:62:in `method_missing'
     # ./spec/sg_spec.rb:14:in `block (2 levels) in <top (required)>'

I think I didn't understand the logic of the application for the moment, still digging.

from awspec.

CarlInglisBJSS avatar CarlInglisBJSS commented on June 3, 2024

@sveronese That's pretty much how I'd approach it. I don't know the applicaton logic that well myself, if I get time at the weekend I'll take a look - I'm now interested in knowing more. :)

from awspec.

k1LoW avatar k1LoW commented on June 3, 2024

Hi @sveronese

its(:security_group_count) { should eq 1 }

LGTM!

from awspec.

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.