# Where i can get the source code for create a security group in aws or openstack

**URL:** https://discourse.chef.io/t/where-i-can-get-the-source-code-for-create-a-security-group-in-aws-or-openstack/3386
**Category:** Chef Infra (archive)
**Created:** [December 10, 2012, 8:52am UTC](https://discourse.chef.io/t/where-i-can-get-the-source-code-for-create-a-security-group-in-aws-or-openstack/3386 "2012-12-10T08:52:01Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Ganesan\_A](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@Ganesan\_A](https://discourse.chef.io/u/Ganesan_A)
#### Post date: [December 10, 2012, 8:52am UTC](https://discourse.chef.io/t/where-i-can-get-the-source-code-for-create-a-security-group-in-aws-or-openstack/3386/1 "2012-12-10T08:52:01Z")

</div>

i not familiar with chef just now i started to explore… my task is i have chef  
client/server and hosted chef setup also, from this i have to connect the  
Amazon EC2 and create a security group (i had a account in aws) only and enable  
port for that respective group. i go through the aws cookbook, we should  
install the plugin for that but i need to know apart from aws cookbook and  
plugins, any cookbook or any ruby sample code with out any plugins for  
available to connect with aws and create security group only if it is possible,  
please post the respective code or the cookbook name. i go through the code in  
mailing list and tested its not working…

code in my ruby file:

def run

```
   $stdout.sync = true
   $name = groop
   aws_access_key_id = XXXXXXXXXXXX
   aws_secret_access_key = XXXXXXXXXXXXXXXX
   name = hai

  secgroup_def = { :name => config[:name], :description

```

=\>config[:description], :ip\_permissions =\> nil, :owner\_id =\> nil }  
conn = Fog::Compute.new(  
:provider =\> ‘AWS’,  
:aws\_access\_key\_id =\>  
Chef::Config[:knife][:aws\_access\_key\_id],  
:aws\_secret\_access\_key =\>  
Chef::Config[:knife][:aws\_secret\_access\_key],  
:region =\> locate\_config\_value(:region)  
)  
# conn = connection.create()  
secgroup = conn.security\_groups.new(secgroup\_def)

end
