community.aws.ses_identity 模块 – 管理 SES 邮件和域名身份

注意

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

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

要安装它,请使用:ansible-galaxy collection install community.aws。您需要其他要求才能使用此模块,请参阅 要求 获取详细信息。

要在 playbook 中使用它,请指定:community.aws.ses_identity

community.aws 1.0.0 中的新增功能

概要

  • 此模块允许用户管理 SES 的已验证电子邮件和域名身份。

  • 这包括验证和删除身份,以及设置投诉、退回和投递通知设置。

  • 在 5.0.0 版本之前,此模块称为 community.aws.aws_ses_identity。使用方法没有改变。

别名:aws_ses_identity

要求

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

  • 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

bounce_notifications

字典

设置用于报告退回通知的 SNS 主题。

如果省略,则不会将退回通知传递到 SNS 主题。

如果退回通知未传递到 SNS 主题,则必须启用 feedback_forwarding

include_headers

布尔值

是否在传递到 SNS 主题时包含标头。

如果未指定 topic,则这不会产生影响,但即使没有主题,SES 设置也会更新。

选项

  • false ← (默认)

  • true

topic

字符串

要将通知发送到的主题的 ARN。

如果省略,则不会将通知传递到 SNS 主题。

complaint_notifications

字典

设置用于报告投诉通知的 SNS 主题。

如果省略,则不会将投诉通知传递到 SNS 主题。

如果投诉通知未传递到 SNS 主题,则必须启用 feedback_forwarding

include_headers

布尔值

是否在传递到 SNS 主题时包含标头。

如果未指定 topic,则这不会产生影响,但即使没有主题,SES 设置也会更新。

选项

  • false ← (默认)

  • true

topic

字符串

要将通知发送到的主题的 ARN。

如果省略,则不会将通知传递到 SNS 主题。

debug_botocore_endpoint_logs

布尔值

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

也可以使用 ANSIBLE_DEBUG_BOTOCORE_LOGS 环境变量。

选项

  • false ← (默认)

  • true

delivery_notifications

字典

设置用于报告投递通知的 SNS 主题。

如果省略,则不会将投递通知传递到 SNS 主题。

include_headers

布尔值

是否在传递到 SNS 主题时包含标头。

如果未指定 topic,则这不会产生影响,但即使没有主题,SES 设置也会更新。

选项

  • false ← (默认)

  • true

topic

字符串

要将通知发送到的主题的 ARN。

如果省略,则不会将通知传递到 SNS 主题。

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 之后的一个版本中删除。

feedback_forwarding

布尔值

是否启用反馈转发。

只有当 bounce_notificationscomplaint_notifications 都指定了 SNS 主题时,此值才能为 false。

选项

  • false

  • true ← (默认)

identity

字符串 / 必需

这是要验证/删除的电子邮件地址或域名。

如果包含“@”,则将其视为电子邮件。否则,将其视为域名。

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 选项互斥。

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 月 1 日之后的版本中移除。

EC2_REGION 环境变量的支持已弃用,将在 2024 年 12 月 1 日之后的版本中移除。

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 月 1 日之后的版本中移除。

EC2_SECRET_KEY 环境变量的支持已弃用,将在 2024 年 12 月 1 日之后的版本中移除。

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 选项互斥。

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

security_tokenaws_security_tokenaccess_token 别名已弃用,将在 2024 年 12 月 1 日之后的版本中移除。

EC2_SECRET_KEYAWS_SECURITY_TOKEN 环境变量的支持已弃用,将在 2024 年 12 月 1 日之后的版本中移除。

state

字符串

创建(或更新)还是删除身份。

选项

  • "present" ← (默认)

  • "absent"

validate_certs

布尔值

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

强烈建议不要设置 validate_certs=false,可以考虑改用 aws_ca_bundle

选项

  • false

  • true ← (默认)

注释

注意

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

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

示例

# Note: These examples do not set authentication details, see the AWS Guide for details.

- name: Ensure [email protected] email identity exists
  community.aws.ses_identity:
    identity: [email protected]
    state: present

- name: Delete [email protected] email identity
  community.aws.ses_identity:
    email: [email protected]
    state: absent

- name: Ensure example.com domain identity exists
  community.aws.ses_identity:
    identity: example.com
    state: present

# Create an SNS topic and send bounce and complaint notifications to it
# instead of emailing the identity owner
- name: Ensure complaints-topic exists
  community.aws.sns_topic:
    name: "complaints-topic"
    state: present
    purge_subscriptions: false
  register: topic_info

- name: Deliver feedback to topic instead of owner email
  community.aws.ses_identity:
    identity: [email protected]
    state: present
    complaint_notifications:
      topic: "{{ topic_info.sns_arn }}"
      include_headers: true
    bounce_notifications:
      topic: "{{ topic_info.sns_arn }}"
      include_headers: false
    feedback_forwarding: false

# Create an SNS topic for delivery notifications and leave complaints
# Being forwarded to the identity owner email
- name: Ensure delivery-notifications-topic exists
  community.aws.sns_topic:
    name: "delivery-notifications-topic"
    state: present
    purge_subscriptions: false
  register: topic_info

- name: Delivery notifications to topic
  community.aws.ses_identity:
    identity: [email protected]
    state: present
    delivery_notifications:
      topic: "{{ topic_info.sns_arn }}"

返回值

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

Key

描述

identity

字符串

正在修改的身份。

返回:成功

示例: "[email protected]"

identity_arn

字符串

正在修改的身份的 ARN。

返回:成功

示例: "arn:aws:ses:us-east-1:12345678:identity/[email protected]"

notification_attributes

复杂

身份的通知设置。

返回:成功

示例: {"bounce_topic": "arn:aws:sns:....", "complaint_topic": "arn:aws:sns:....", "delivery_topic": "arn:aws:sns:....", "forwarding_enabled": false, "headers_in_bounce_notifications_enabled": true, "headers_in_complaint_notifications_enabled": true, "headers_in_delivery_notifications_enabled": true}

bounce_topic

字符串

传递退信通知的主题的 ARN。

如果不将退信通知传递到主题,则省略。

返回:成功

complaint_topic

字符串

传递投诉通知的主题的 ARN。

如果不将投诉通知传递到主题,则省略。

返回:成功

delivery_topic

字符串

传递投递通知的主题的 ARN。

如果不将投递通知传递到主题,则省略。

返回:成功

forwarding_enabled

布尔值

是否启用反馈转发。

返回:成功

headers_in_bounce_notifications_enabled

布尔值

是否在传递到退信主题的消息中包含标头。

返回:成功

headers_in_complaint_notifications_enabled

布尔值

是否在传递到投诉主题的消息中包含标头。

返回:成功

headers_in_delivery_notifications_enabled

布尔值

是否在传递到投递主题的消息中包含标头。

返回:成功

verification_attributes

复杂

身份的验证信息。

返回:成功

示例: {"verification_status": "Pending", "verification_token": "...."}

verification_status

字符串

身份的验证状态。

返回:成功

示例: "Pending"

verification_token

字符串

域身份的验证令牌。

返回:成功

作者

  • Ed Costello (@orthanc)