如何在Terraform中默认使用AWS托管SES IP池
解决Terraform中SES默认配置集关联托管IP池的问题
1. 关联配置集与托管IP池
你需要通过aws_sesv2_configuration_set_delivery_options资源,将已创建的配置集和托管IP池绑定,完整代码如下:
resource "aws_sesv2_dedicated_ip_pool" "this" { pool_name = "default-app" scaling_mode = "MANAGED" } resource "aws_ses_configuration_set" "this" { name = "default-app" } # 绑定配置集与IP池 resource "aws_sesv2_configuration_set_delivery_options" "this" { configuration_set_name = aws_ses_configuration_set.this.name sending_pool_name = aws_sesv2_dedicated_ip_pool.this.pool_name }
2. 设置为默认配置集
AWS SES没有全局默认配置集的直接Terraform资源,但可以通过以下两种方式实现默认生效:
- 账户级默认配置
使用aws_sesv2_account资源指定账户默认配置集,所有未明确指定配置集的发送请求都会自动使用它:resource "aws_sesv2_account" "this" { default_email_sending_configuration { configuration_set_name = aws_ses_configuration_set.this.name } } - 发送请求显式指定
若通过SES API/SDK发送邮件,在请求参数中显式填写ConfigurationSetName为default-app,确保使用该配置集及关联IP池。
注意事项
- 确认AWS账户拥有
ses:CreateConfigurationSet、ses:CreateDedicatedIpPool等必要权限。 - 托管IP池创建后需等待数分钟生效,避免立即测试发送。
内容的提问来源于stack exchange,提问作者eltiare
相关产品推荐
相关产品推荐

