Unable to create an AWS instance in particular security group.

235 views
Skip to first unread message

Pradeep Chhetri

unread,
Apr 6, 2014, 8:24:00 AM4/6/14
to ruby...@googlegroups.com
Hello,

I am trying to create an instance in AWS in a particular security group.

server = conn.servers.create(:image_id => "#{@ami_id}",
                                           :flavor_id => "#{@instancetype}",
                                           :key_name => "#{@aws_ssh_key_name}",
                                           :groups => "Monitoring",
                                           :subnet_id => "#{@subnetid.shuffle.first}",
                                           :user_data => "#{user_data}")

where Monitoring is the name of the security group.

But when the machine comes up. It takes the "default" security group. I tried replacing "Monitoring" with the security-group-id but still I wasn't able to get Monitoring security group in the new instance. Can someone please help me out.


Thank you,

- Pradeep

Pradeep Chhetri

unread,
Apr 7, 2014, 2:55:38 AM4/7/14
to ruby...@googlegroups.com
Finally figured out that I should use :security_group_ids => ["sg-xxxxxxx"]. 

Frederick Cheung

unread,
Apr 7, 2014, 4:48:30 AM4/7/14
to ruby...@googlegroups.com, Pradeep Chhetri
You definitely can use the group names, but it needs to be an array - :groups => ['Monitoring'], even if there's only the one group.

Fred 
> --
> You received this message because you are subscribed to the Google Groups "ruby-fog"
> group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+u...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

Pradeep

unread,
Apr 7, 2014, 4:53:20 AM4/7/14
to Frederick Cheung, ruby...@googlegroups.com
Hi Fred,

As you said, I tried passing as an array as well. It didn't work. It
took the "default" Security group only. The machine is inside VPC.
Should it make any difference ? Do I need to mentioned vpc-id anywhere ?

Frederick Cheung

unread,
Apr 7, 2014, 5:31:10 AM4/7/14
to ruby...@googlegroups.com, Pradeep, ruby...@googlegroups.com
Ah, may well change things - I've never used that before. Security groups are different with a vpc so it wouldn't surprise me if there was a difference 

Fred

Pradeep

unread,
Apr 7, 2014, 5:35:47 AM4/7/14
to Frederick Cheung, ruby...@googlegroups.com
For now, security_group_ids is working for me nicely. Thank you Fred.

-Pradeep

Pradeep

unread,
Apr 7, 2014, 7:35:43 AM4/7/14
to Suresh Prajapati, ruby...@googlegroups.com
Thanks Suresh.

On Monday 07 April 2014 04:38:16 PM IST, Suresh Prajapati wrote:
> Hi Pradeep,
>
> Below is the code which is working fine for me .
>
> instance = compute.servers.create ({
> :flavor_id => opts[:flavor],
> :key_name => opts[:key],
> :image_id => opts[:ami],
> :security_group_ids => opts[:security_group],
> :subnet_id => opts[:subnet_id],
> :tags => {"Name" => opts[:name]}
> })
>
> So you should use security_group_ids in your code. Those are unique
> and different for VPC and EC2 classic .
>
>
> On Mon, Apr 7, 2014 at 3:05 PM, Pradeep <pradeep....@gmail.com
> <mailto:pradeep....@gmail.com>> wrote:
>
> For now, security_group_ids is working for me nicely. Thank you Fred.
>
> -Pradeep
>
> On Monday 07 April 2014 03:01:10 PM IST, Frederick Cheung wrote:
>
> Ah, may well change things - I've never used that before.
> Security groups are different with a vpc so it wouldn't
> surprise me if there was a difference
>
> Fred
>
> On 7 April 2014 at 09:53:27, Pradeep
> (pradeep....@gmail.com
> <mailto:pradeep....@gmail.com>) wrote:
>
> Hi Fred,
>
> As you said, I tried passing as an array as well. It
> didn't work. It
> took the "default" Security group only. The machine is
> inside VPC.
> Should it make any difference ? Do I need to mentioned
> vpc-id anywhere ?
>
> On Monday 07 April 2014 02:18:30 PM IST, Frederick Cheung
> wrote:
>
> You definitely can use the group names, but it needs
> to be an array - :groups => ['Monitoring'],
>
> even if there's only the one group.
>
>
> Fred
>
>
> On 7 April 2014 at 07:55:40, Pradeep Chhetri
> (pradeep....@gmail.com
> ruby-fog+unsubscribe@__googlegroups.com
> <mailto:ruby-fog%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
>
> --
> You received this message because you are subscribed to
> the Google Groups "ruby-fog"
> group.
> To unsubscribe from this group and stop receiving emails
> from it, send an email to
> ruby-fog+unsubscribe@__googlegroups.com
> <mailto:ruby-fog%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "ruby-fog" group.
> To unsubscribe from this group and stop receiving emails from it,
> send an email to ruby-fog+unsubscribe@__googlegroups.com
> <mailto:ruby-fog%2Bunsu...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/__optout
> <https://groups.google.com/d/optout>.
>
>
>
>
> --
> Best Regards,
> Suresh Prajapati
> Mob No: +91-9000173245
> ----------------------------------------------------------------------------------------
> Theory is when you know all and nothing works. Practice is when all
> works and nobody knows why. In this case we have put together theory
> and practice: nothing works... and nobody knows why!

Suresh Prajapati

unread,
Apr 7, 2014, 7:08:16 AM4/7/14
to ruby...@googlegroups.com, pradeep....@gmail.com, Frederick Cheung
Hi Pradeep,

Below is the code which is working fine for me .

  instance = compute.servers.create ({
      :flavor_id => opts[:flavor],
      :key_name => opts[:key],
      :image_id => opts[:ami],
      :security_group_ids => opts[:security_group],
      :subnet_id => opts[:subnet_id],
      :tags => {"Name" => opts[:name]}
     })

So you should use security_group_ids in your code. Those are unique and different for VPC and EC2 classic .
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "ruby-fog"
group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.


--
You received this message because you are subscribed to the Google Groups "ruby-fog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ruby-fog+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages