You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何使用Ansible获取AWS RDS Aurora集群的cluster endpoint

错误原因说明

  • community.aws.rds_instance_info仅用于查询RDS实例级资源,传入集群标识符自然返回空结果,该模块返回的实例信息中已附带所属集群的端点信息,可直接提取。
  • amazon.aws 2.0.0版本不存在aws_rds模块,属于模块名记忆错误,查询Aurora集群专属信息需使用community.aws.rds_cluster_info模块。

可行解决方案

方案1:复用现有实例查询结果

如果你已经能获取集群下任意实例的ID,无需调整现有查询逻辑,直接从返回结果中提取集群端点即可:

- name: 打印Aurora集群写入端点
  debug:
    msg: "集群Endpoint为 {{ rds_aurora_cluster.instances[0].db_cluster_endpoint }}"

方案2:直接通过集群ID查询

如果仅持有集群标识符,使用专属的集群查询模块即可,首先确认已安装community.aws集合(若未安装执行ansible-galaxy collection install community.aws),参考Playbook如下:

---
- name: Test
  hosts: localhost
  connection: local
  tasks:
    - name: 查询RDS Aurora集群信息
      community.aws.rds_cluster_info:
        db_cluster_identifier: "test-cluster" # 传入你的集群标识符
      register: rds_aurora_cluster

    - name: 打印集群写入端点
      debug:
        msg: "集群写入Endpoint:{{ rds_aurora_cluster.clusters[0].endpoint }}"

    - name: 打印集群只读端点
      debug:
        msg: "集群只读Endpoint:{{ rds_aurora_cluster.clusters[0].reader_endpoint }}"

返回结果中clusters[0].endpoint为集群写入端点,clusters[0].reader_endpoint为集群只读端点,自定义集群端点也可在返回结构中对应字段提取。


内容的提问来源于stack exchange,提问作者Employee

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.02 06:54:01