amazon.aws.rds_subnet_group 模块 – 管理 RDS 数据库子网组

注意

此模块是 amazon.aws 集合(版本 9.0.0)的一部分。

如果您正在使用 ansible 包,您可能已经安装了此集合。它不包含在 ansible-core 中。要检查是否已安装,请运行 ansible-galaxy collection list

要安装它,请使用:ansible-galaxy collection install amazon.aws。您需要进一步的要求才能使用此模块,有关详细信息,请参阅 要求

要在 playbook 中使用它,请指定:amazon.aws.rds_subnet_group

amazon.aws 5.0.0 中的新增功能

概要

  • 创建、修改和删除 RDS 数据库子网组。

  • 此模块最初在 1.0.0 版本中添加到 community.aws

要求

执行此模块的主机需要以下要求。

  • python >= 3.6

  • boto3 >= 1.28.0

  • botocore >= 1.31.0

参数

参数

注释

access_key

别名:aws_access_key_id, aws_access_key, ec2_access_key

字符串

AWS 访问密钥 ID。

有关访问令牌的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys

也可以按优先级降序使用 AWS_ACCESS_KEY_IDAWS_ACCESS_KEYEC2_ACCESS_KEY 环境变量。

aws_access_keyprofile 选项是互斥的。

为了与 AWS botocore SDK 保持一致,在 5.1.0 版本中添加了 aws_access_key_id 别名。

ec2_access_key 别名已弃用,将在 2024-12-01 之后的版本中删除。

EC2_ACCESS_KEY 环境变量的支持已弃用,将在 2024-12-01 之后的版本中删除。

aws_ca_bundle

路径

验证 SSL 证书时要使用的 CA 包的位置。

也可以使用 AWS_CA_BUNDLE 环境变量。

aws_config

字典

用于修改 botocore 配置的字典。

可以在 AWS 文档中找到参数 https://botocore.amazonaws.com/v1/documentation/api/latest/reference/config.html#botocore.config.Config

debug_botocore_endpoint_logs

布尔值

使用 botocore.endpoint 记录器来解析任务期间进行的唯一(而不是总计)"resource:action" API 调用,将集合输出到任务结果中的 resource_actions 键。使用 aws_resource_action 回调来输出 playbook 期间生成的总列表。

也可以使用 ANSIBLE_DEBUG_BOTOCORE_LOGS 环境变量。

选择

  • false ← (默认)

  • true

description

字符串

数据库子网组描述。

state=present 时是必需的。

endpoint_url

别名:ec2_url, aws_endpoint_url, s3_url

字符串

连接的 URL,而不是默认的 AWS 端点。虽然这可以用于连接到其他与 AWS 兼容的服务,但 amazon.aws 和 community.aws 集合仅针对 AWS 进行了测试。

也可以按优先级降序使用 AWS_URLEC2_URL 环境变量。

ec2_urls3_url 别名已弃用,将在 2024-12-01 之后的版本中删除。

EC2_URL 环境变量的支持已弃用,将在 2024-12-01 之后的版本中删除。

name

字符串 / 必需

数据库子网组标识符。

profile

别名:aws_profile

字符串

用于身份验证的命名 AWS 配置文件。

有关命名配置文件的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-profiles.html

也可以使用 AWS_PROFILE 环境变量。

profile 选项与 aws_access_keyaws_secret_keysecurity_token 选项互斥。

purge_tags

布尔值

如果 purge_tags=true 且设置了 tags,则将从资源中清除现有标签以完全匹配 tags 参数定义的标签。

如果未设置 tags 参数,则即使 purge_tags=True,也不会修改标签。

aws: 开头的标签键是 Amazon 保留的,不能修改。因此,为了 purge_tags 参数的目的,它们将被忽略。更多信息请参阅 Amazon 文档 https://docs.aws.amazon.com/general/latest/gr/aws_tagging.html#tag-conventions

选择

  • false

  • true ← (默认)

region

别名: aws_region, ec2_region

字符串

要使用的 AWS 区域。

对于诸如 IAM、Route53 和 CloudFront 等全局服务,region 将被忽略。

也可以使用 AWS_REGIONEC2_REGION 环境变量。

有关更多信息,请参阅 Amazon AWS 文档 http://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region

ec2_region 别名已被弃用,将在 2024-12-01 之后的版本中移除。

EC2_REGION 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中移除。

secret_key

别名: aws_secret_access_key, aws_secret_key, ec2_secret_key

字符串

AWS 密钥访问密钥。

有关访问令牌的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys

也可以使用 AWS_SECRET_ACCESS_KEYAWS_SECRET_KEYEC2_SECRET_KEY 环境变量,优先级递减。

secret_keyprofile 选项是互斥的。

为了与 AWS botocore SDK 保持一致,在 5.1.0 版本中添加了 aws_secret_access_key 别名。

ec2_secret_key 别名已被弃用,将在 2024-12-01 之后的版本中移除。

EC2_SECRET_KEY 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中移除。

session_token

别名: aws_session_token, security_token, aws_security_token, access_token

字符串

用于临时凭证的 AWS STS 会话令牌。

有关访问令牌的更多信息,请参阅 AWS 文档 https://docs.aws.amazon.com/general/latest/gr/aws-sec-cred-types.html#access-keys-and-secret-access-keys

也可以使用 AWS_SESSION_TOKENAWS_SECURITY_TOKENEC2_SECURITY_TOKEN 环境变量,优先级递减。

security_tokenprofile 选项是互斥的。

别名 aws_session_tokensession_token 在 3.2.0 版本中添加,参数在 6.0.0 版本中从 security_token 重命名为 session_token

security_tokenaws_security_tokenaccess_token 别名已被弃用,将在 2024-12-01 之后的版本中移除。

EC2_SECRET_KEYAWS_SECURITY_TOKEN 环境变量的支持已被弃用,将在 2024-12-01 之后的版本中移除。

state

字符串 / 必需

指定子网应该存在还是不存在。

选择

  • "present"

  • "absent"

subnets

list / elements=string

构成数据库子网组的子网 ID 列表。

state=present 时是必需的。

tags

别名: resource_tags

字典

表示要应用于资源的标签的字典。

如果未设置 tags 参数,则不会修改标签。

validate_certs

布尔值

当设置为 false 时,与 AWS API 通信时将不验证 SSL 证书。

强烈建议不要设置 validate_certs=false,作为替代方案,请考虑设置 aws_ca_bundle

选择

  • false

  • true ← (默认)

说明

注意

  • 在 3.2.0 版本中添加了对 tagspurge_tags 的支持。

  • 注意:对于模块,环境变量和配置文件是从 Ansible “主机” 上下文中读取的,而不是从“控制器” 上下文中读取的。因此,可能需要将文件显式复制到“主机”。对于查找和连接插件,环境变量和配置文件是从 Ansible “控制器” 上下文中读取的,而不是从“主机” 上下文中读取的。

  • Ansible 使用的 AWS SDK (boto3) 也可能会从其在 Ansible “主机” 上下文中的配置文件(通常是 ~/.aws/credentials)中读取凭证和其他设置(例如区域)的默认值。有关更多信息,请参阅 https://boto3.amazonaws.com/v1/documentation/api/latest/guide/credentials.html

示例

- name: Add or change a subnet group
  amazon.aws.rds_subnet_group:
    state: present
    name: norwegian-blue
    description: My Fancy Ex Parrot Subnet Group
    subnets:
      - subnet-aaaaaaaa
      - subnet-bbbbbbbb

- name: Add or change a subnet group and associate tags
  amazon.aws.rds_subnet_group:
    state: present
    name: norwegian-blue
    description: My Fancy Ex Parrot Subnet Group
    subnets:
      - subnet-aaaaaaaa
      - subnet-bbbbbbbb
    tags:
      tag1: Tag1
      tag2: Tag2

- name: Remove a subnet group
  amazon.aws.rds_subnet_group:
    state: absent
    name: norwegian-blue

返回值

常见的返回值已在此处记录 这里,以下是此模块独有的字段

描述

changed

布尔值

如果列出 RDS 子网组成功,则为 True。

返回: always

示例: false

subnet_group

复杂

数据库子网组值的字典。

返回: state=present

db_subnet_group_arn

字符串

数据库子网组的 ARN。

返回: state=present

示例: "arn:aws:rds:eu-north-1:123456789012:subgrp:ansible-test-13950442"

db_subnet_group_description

字符串

数据库子网组的描述。

返回: state=present

示例: "Simple description."

db_subnet_group_name

字符串

数据库子网组的名称。

返回: state=present

示例: "ansible-test-mbp-13950442"

description

字符串

数据库子网组的描述(为向后兼容而维护)。

返回: state=present

示例: "Simple description."

name

字符串

数据库子网组的名称(为向后兼容而维护)。

返回: state=present

示例: "ansible-test-mbp-13950442"

status

字符串

数据库子网组的状态(为向后兼容而维护)。

返回: state=present

示例: "Complete"

subnet_group_status

字符串

数据库子网组的状态。

返回: state=present

示例: "Complete"

subnet_ids

list / elements=string

包含子网 ID 列表。

返回: state=present

示例: ["subnet-08c94870f4480797e"]

subnets

list / elements=string

subnet_availability_zone

字典

在 community.aws 3.2.0 中添加

包含可用区信息。

返回: state=present

示例: {"name": "eu-north-1b"}

subnet_identifier

字符串

在 community.aws 3.2.0 中添加

子网的标识符。

返回: state=present

示例: "subnet-08c94870f4480797e"

subnet_outpost

字典

在 community.aws 3.2.0 中添加

此值指定 Outpost。

返回: state=present

示例: {}

subnet_status

字符串

在 community.aws 3.2.0 中添加

子网的状态。

返回: state=present

示例: "Active"

tags

字典

在 community.aws 3.2.0 中添加

与子网组关联的标签。

返回: state=present

示例: {"tag1": "Tag1", "tag2": "Tag2"}

vpc_id

字符串

数据库子网组的 VPC ID。

返回: state=present

示例: "vpc-0acb0ba033ff2119c"

作者

  • Scott Anderson (@tastychutney)

  • Alina Buzachis (@alinabuzachis)