获取有关所有 Amazon RDS 安全组的信息 - 适用于 Ruby 的 Amazon SDK
Amazon Web Services 文档中描述的 Amazon Web Services 服务或功能可能因区域而异。要查看适用于中国区域的差异,请参阅 中国的 Amazon Web Services 服务入门 (PDF)

本文属于机器翻译版本。若本译文内容与英语原文存在差异,则一律以英文原文为准。

获取有关所有 Amazon RDS 安全组的信息

以下示例列出了 us-west-2 区域中的所有 Amazon RDS 安全组的名称。

注意

仅当您使用 Amazon EC2-Classic 平台时,Amazon RDS 安全组才适用。如果您使用的是 Amazon EC2-VPC,请使用 VPC 安全组。在示例中演示了这两种情况。

警告

我们将于 2022 年 8 月 15 日停用 EC2-Classic。我们建议您从 EC2-Classic 迁移到 VPC。有关更多信息,请参阅适用于 Linux 实例的 Amazon EC2 用户指南适用于 Windows 实例的 Amazon EC2 用户指南中的从 EC2-Classic 迁移到 VPC。另请参阅 EC2-Classic Networking is Retiring – Here's How to Prepare 博客文章。

# 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