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
Prerequisite: Example assumes you have previously authenticated, and your valid session cookie is in 'mycookie'.
#!/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
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
© 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.