Note: Please go to docs.rightscale.com to access the current RightScale documentation set. Also, feel free to Chat with us!
Home > Guides > RightScale API 1.5 > Examples > Security Groups > Create Security Group Rules by Group

Create Security Group Rules by Group

Table of Contents

Add a security group rule to an existing security group, allowing port 80 browsing for servers belonging to the security group specified (which is the group itself in our example).

Note:  You cannot specify multiple port ranges in one API call.  That is, had the example below specified a start/end port of 80, 22, and lastly 443, the security group rule would have been created, but only for port 443.  Essentially, the last port range specified wins out.  This applies when adding by source_type=group or source_type=cidr_ips.

Table of Contents

Curl

Prerequisite:  Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.

Example Call

#!/bin/sh -e
CLOUD="2112"
SG="4ISGEDCJCG3CS"
curl -i -H X_API_VERSION:1.5 -b mycookie -X POST \
-d security_group_rule[protocol]=tcp \
-d security_group_rule[protocol_details][start_port]=80 \
-d security_group_rule[protocol_details][end_port]=80 \
-d security_group_rule[source_type]=group \
-d security_group_rule[group_owner]=test \
-d security_group_rule[group_name]="SG for API Sandbox" \
https://my.rightscale.com/api/clouds/$CLOUD/security_groups/$SG/security_group_rules

Sample Output

No content, just header information.

HTTP/1.1 201 Created
Server: nginx/1.0.15
Date: Fri, 26 Oct 2012 18:20:37 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Status: 201 Created
Location: /api/security_group_rules/358914001
X-Runtime: 1487
X-Request-Uuid: 376ddf887be44d3abf6c82d83b9486e7
Set-Cookie: rs_gbl=eNotkElugzAAAP_iM0jYDrGN1AsVaahZQqsIxKViMUuaBYKBkIi_F6TeZ-YwL5AAA1wmoIC8A8YL9J24A4NQSmYFyAwYEOsQEX2LiQLqfIFhijHbIKrCguYqhAKpdAuRChGGmGks1fTNkpPi36WIru5SB1y3oqNw6tvjWeCoSZ00GVPceIHdbIuSn4hVm5IODTKhDG3ytR_i0qso4doUnqyDGwyfWWFPO-Fn3Ov0vLJ3Un18Y8yvLB7xdS_DJz1OMI5Y7Pj-_VKW3rtf_9JLEIo2d4TmnpkrZfPDgkPWFmfJfYFIGGu7D1Ixz-3L1qvHyCTj23rksR5JsuzWX-UyBc7zH--1W2o%3D; domain=.rightscale.com; path=/; HttpOnly
Cache-Control: no-cache
You must to post a comment.
Last modified
23:18, 16 May 2013

Tags

Classifications

This page has no classifications.

Announcements

None


© 2006-2014 RightScale, Inc. All rights reserved.
RightScale is a registered trademark of RightScale, Inc. All other products and services may be trademarks or servicemarks of their respective owners.