-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathaws-cfn-ses-domain.cf.yaml
119 lines (112 loc) · 3.88 KB
/
aws-cfn-ses-domain.cf.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
AWSTemplateFormatVersion: "2010-09-09"
Description: >
Creates an AWS Lambda Function that can be used as a CloudFormation CustomResource
to manage Amazon SES resources that aren't built into CloudFormation, including
domain identities and email identities. (See the readme for more information.)
Parameters:
LambdaCodeS3Bucket:
Type: String
Default: YOUR_BUCKET_NAME
Description: >
The S3 bucket where the LAMBDA_ZIP deployment package
has been uploaded. Must reside in the same AWS Region where your stack
is running.
LambdaCodeS3Key:
Type: String
Default: YOUR_LAMBDA_ZIP_KEY
Description: >
The S3 key to the LAMBDA_ZIP deployment package.
Outputs:
CustomDomainIdentityArn:
Description: The ServiceToken for the Custom::SES_DomainIdentity resource
Value: !GetAtt CustomDomainLambdaFunction.Arn
CustomEmailIdentityArn:
Description: The ServiceToken for the Custom::SES_EmailIdentity resource
Value: !GetAtt CustomEmailLambdaFunction.Arn
Arn:
Description: >
(DEPRECATED - Use CustomDomainIdentityArn instead)
The ServiceToken for the Custom::SES_Domain resource
Value: !GetAtt CustomDomainLambdaFunction.Arn
Name:
Description: >
(DEPRECATED - shouldn't be necessary)
The AWS::Lambda::Function that implements Custom::SES_Domain
Value: !Ref CustomDomainLambdaFunction
Resources:
CustomDomainLambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AssumeLambdaExecutionRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
# (allows logging)
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyName: ProvisionSESDomainIdentities
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowSESDomainIdentityProvisioning
Effect: Allow
Action:
- ses:DeleteIdentity
- ses:GetIdentityDkimAttributes
- ses:GetIdentityMailFromDomainAttributes
- ses:GetIdentityVerificationAttributes
- ses:SetIdentityDkimEnabled
- ses:SetIdentityMailFromDomain
- ses:VerifyDomainDkim
- ses:VerifyDomainIdentity
Resource: "*"
CustomEmailLambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AssumeLambdaExecutionRole
Effect: Allow
Principal:
Service: lambda.amazonaws.com
Action: sts:AssumeRole
ManagedPolicyArns:
# (allows logging)
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
Policies:
- PolicyName: ProvisionSESEmailIdentities
PolicyDocument:
Version: '2012-10-17'
Statement:
- Sid: AllowSESEmailIdentityProvisioning
Effect: Allow
Action:
- ses:DeleteIdentity
- ses:VerifyEmailIdentity
Resource: "*"
CustomDomainLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Description: CloudFormation custom SES domain provisioning
Handler: index.handle_domain_identity_request
Role: !GetAtt CustomDomainLambdaExecutionRole.Arn
Runtime: python3.9
Code:
S3Bucket: !Ref LambdaCodeS3Bucket
S3Key: !Ref LambdaCodeS3Key
CustomEmailLambdaFunction:
Type: AWS::Lambda::Function
Properties:
Description: CloudFormation custom SES email identity provisioning
Handler: index.handle_email_identity_request
Role: !GetAtt CustomEmailLambdaExecutionRole.Arn
Runtime: python3.9
Code:
S3Bucket: !Ref LambdaCodeS3Bucket
S3Key: !Ref LambdaCodeS3Key