Terraform AWS SES凭证资源

时间:2018-10-17 08:14:24

标签: terraform amazon-ses

我已经搜索过,但没有找到信息。 我们可以使用Terraform创建AWS SES凭证吗?

2 个答案:

答案 0 :(得分:4)

使用以下terraform代码获取SES凭证-

resource "aws_iam_user" "smtp_user" {
  name = "smtp_user"
}

resource "aws_iam_access_key" "smtp_user" {
  user = aws_iam_user.smtp_user.name
}

data "aws_iam_policy_document" "ses_sender" {
  statement {
    actions   = ["ses:SendRawEmail"]
    resources = ["*"]
  }
}

resource "aws_iam_policy" "ses_sender" {
  name        = "ses_sender"
  description = "Allows sending of e-mails via Simple Email Service"
  policy      = data.aws_iam_policy_document.ses_sender.json
}

resource "aws_iam_user_policy_attachment" "test-attach" {
  user       = aws_iam_user.smtp_user.name
  policy_arn = aws_iam_policy.ses_sender.arn
}

output "smtp_username" {
  value = aws_iam_access_key.smtp_user.id
}

output "smtp_password" {
  value = aws_iam_access_key.smtp_user.ses_smtp_password_v4
}

答案 1 :(得分:1)

aws ses smtp凭据是转换为smtp凭据的iam凭据。您应该创建一个iam用户,并将其作为smtp凭据输出,例如以下模块 https://github.com/terraform-aws-modules/terraform-aws-iam/tree/master/examples/iam-user