rds-ruby-example-list-security-groups.rb - AWS Code Sample


Lists the security groups for you RDS instances.

# Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. # # This file is licensed under the Apache License, Version 2.0 (the "License"). # You may not use this file except in compliance with the License. A copy of the # License is located at # # http://aws.amazon.com/apache2.0/ # # This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS # OF ANY KIND, either express or implied. See the License for the specific # language governing permissions and limitations under the License. require 'aws-sdk-rds' # v2: require 'aws-sdk' rds = Aws::RDS::Resource.new(region: 'us-west-2') rds.db_instances.each do |i| # Show any security group IDs and descriptions puts 'Security Groups:' i.db_security_groups.each do |sg| puts sg.db_security_group_name puts ' ' + sg.db_security_group_description puts end # Show any VPC security group IDs and their status puts 'VPC Security Groups:' i.vpc_security_groups.each do |vsg| puts vsg.vpc_security_group_id puts ' ' + vsg.status puts end end

Sample Details

Service: rds

Last tested: 2018-03-16

Author: Doug-AWS

Type: full-example