The included fabfile
can faciliate setting up LambdaMLM.
- Need pip, Virtualenv, and Fabric installed.
- Clone this repo.
- Copy
config.example.py
toconfig.py
and edit/fill in the appropriate values. In particular, your S3 bucket name must be globally unique, not just unique within your account.
Note: If you're planning to use multiple configurations, you can keep each configuration in a file namedconfig.somename.py
and passsomename
as a parameter to thefab
commandscreate_lambda:somename
andupdate_lambda:somename
. The specificsomename
configuration will be copied overconfig.py
before the rest of thefab
command runs. - In the directory, run
fab setup_virtualenv
to set up the virtual environment for LambdaMLM and install required dependencies. - Run
fab create_lambda
to create the S3 bucket, an IAM role under which LambdaMLM will run (with an appropriate policy), and the lambda function itself. - In SES, in the region defined as
lambda_region
inconfig.py
:- Verify all domains to be used for lists.
- Configure DKIM and SPF for domains.
- Create an Email Receiving rule that applies to all domains to be used for lists with two actions:
- S3: Store to the S3 bucket defined in your
config.py
with the incoming email prefix defined inconfig.py
(example isincoming/
). - Lambda: Invoke the lambda function as an Event.
- S3: Store to the S3 bucket defined in your
If you make any further changes to config.py
or to the code, run fab update_lambda
to update the Lambda function's code with your local code.
The fab create_lambda
command:
-
does a quick check of your
config.py
file -
creates the S3 bucket in the specified region.
-
creates an IAM role with the name defined in
config.py
and with policy (where[s3_bucket]
is the bucket name defined inconfig.py
):{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": "arn:aws:logs:*:*:*" }, { "Effect": "Allow", "Action": [ "s3:GetLifecycleConfiguration" ], "Resource": [ "arn:aws:s3:::[s3_bucket]" ] }, { "Effect": "Allow", "Action": [ "s3:PutObject", "s3:GetObject", "s3:DeleteObject" ], "Resource": [ "arn:aws:s3:::[s3_bucket]/*" ] }, { "Effect": "Allow", "Action": [ "SES:SendEmail", "SES:SendRawEmail" ], "Resource": [ "arn:aws:ses:*:*:identity/*" ] } ] }
-
creates a Lambda function with name defined in
config.py
using the Python 2.7 runtime, with the handler and role set appropriately