Module: ses
Terraform module to provision Simple Email Service on AWS.
Usage
This module creates a SES domain with IAM user that is able to send emails with it. If module is provided with Route53 Zone ID it can also create verification DNS records for domain and DKIM.
For a complete example, see examples/complete.
For automated tests of the complete example using bats and Terratest (which tests and deploys the example on AWS), see test.
What's worth to note is that every AWS SES starts in Sandbox. Sending emails via it (emails not verified in AWS SES) is only allowed after support request.
SES availability in regions can be checked in latest AWS General Reference
Variables
Required Variables
Optional Variables
create_spf_record
(bool
) optionalIf provided the module will create an SPF record for
domain
.Default value:
false
custom_from_behavior_on_mx_failure
(string
) optionalThe behaviour of the custom_from_subdomain when the MX record is not found. Defaults to
UseDefaultValue
.Default value:
"UseDefaultValue"
custom_from_dns_record_enabled
(bool
) optionalIf enabled the module will create a Route53 DNS record for the
From
address subdomain.Default value:
true
custom_from_subdomain
(list(string)
) optionalIf provided the module will create a custom subdomain for the
From
address.Default value:
[ ]
iam_access_key_max_age
(number
) optionalMaximum age of IAM access key (seconds). Defaults to 30 days. Set to 0 to disable expiration.
Default value:
2592000
iam_allowed_resources
(list(string)
) optionalSpecifies resource ARNs that are enabled for
var.iam_permissions
. Wildcards are acceptable.Default value:
[ ]
iam_permissions
(list(string)
) optionalSpecifies permissions for the IAM user.
Default value:
[
"ses:SendRawEmail"
]ses_group_enabled
(bool
) optionalCreates a group with permission to send emails from SES domain
Default value:
true
ses_group_name
(string
) optionalThe name of the IAM group to create. If empty the module will calculate name from a context (recommended).
Default value:
""
ses_group_path
(string
) optionalThe IAM Path of the group to create
Default value:
"/"
ses_user_enabled
(bool
) optionalCreates user with permission to send emails from SES domain
Default value:
true
verify_dkim
(bool
) optionalIf provided the module will create Route53 DNS records used for DKIM verification.
Default value:
false
verify_domain
(bool
) optionalIf provided the module will create Route53 DNS records used for domain verification.
Default value:
false
zone_id
(string
) optionalRoute53 parent zone ID. If provided (not empty), the module will create Route53 DNS records used for verification
Default value:
""
Context Variables
The following variables are defined in the context.tf
file of this module and part of the terraform-null-label pattern.
context.tf
file of this module and part of the terraform-null-label pattern.Outputs
access_key_id
The SMTP user which is access key ID.
custom_from_domain
The custom mail FROM domain
secret_access_key
The IAM secret for usage with SES API. This will be written to the state file in plain text.
ses_dkim_tokens
A list of DKIM Tokens which, when added to the DNS Domain as CNAME records, allows for receivers to verify that emails were indeed authorized by the domain owner.
ses_domain_identity_arn
The ARN of the SES domain identity
ses_domain_identity_verification_token
A code which when added to the domain as a TXT record will signal to SES that the owner of the domain has authorised SES to act on their behalf. The domain identity will be in state 'verification pending' until this is done. See below for an example of how this might be achieved when the domain is hosted in Route 53 and managed by Terraform. Find out more about verifying domains in Amazon SES in the AWS SES docs.
ses_group_name
The IAM group name
ses_smtp_password
The SMTP password. This will be written to the state file in plain text.
spf_record
The SPF record for the domain. This is a TXT record that should be added to the domain's DNS settings to allow SES to send emails on behalf of the domain.
user_arn
The ARN assigned by AWS for this user.
user_name
Normalized IAM user name.
user_unique_id
The unique ID assigned by AWS.
Dependencies
Requirements
terraform
, version:>= 1.1.0
aws
, version:>= 2.0
awsutils
, version:>= 0.11.0
Providers
aws
, version:>= 2.0
Modules
Name | Version | Source | Description |
---|---|---|---|
ses_user | 0.23.2 | cloudposse/iam-system-user/aws | n/a |
this | 0.25.0 | cloudposse/label/null | n/a |
Resources
The following resources are used by this module:
aws_iam_group.ses_users
(resource)aws_iam_group_policy.ses_group_policy
(resource)aws_iam_user_group_membership.ses_user
(resource)aws_iam_user_policy.sending_emails
(resource)aws_route53_record.amazonses_dkim_record
(resource)aws_route53_record.amazonses_spf_record
(resource)aws_route53_record.amazonses_verification_record
(resource)aws_route53_record.custom_mail_from_mx
(resource)aws_ses_domain_dkim.ses_domain_dkim
(resource)aws_ses_domain_identity.ses_domain
(resource)aws_ses_domain_mail_from.custom_mail_from
(resource)
Data Sources
The following data sources are used by this module:
aws_iam_policy_document.ses_policy
(data source)aws_region.current
(data source)