Follow these instructions to create a new environment in AWS. You should have at least one environment, and may want multiple environments for different purposes (e.g. development, production).
Prerequisites
- AWS account
- AWS CLI
- Domain name
- Node.js
- Docker
- Copy
.env.example
to.env
and update its values. Code comments in.env
will guide you on additional setup steps that may be necessary. - Install dependencies:
npm install
- Update
lib/reader.ts
with your own Lambda code. (Or do an initial run through with what's already in there, which will output some of the email's details to CloudWatch Logs).
SES only allows one rule set to be active at a time. If you already have a rule set, you can use it. Otherwise, you'll need to follow these steps:
- Create an SES rule set
- Set the rule set to Active.
- Set the
SES_RULE_SET_NAME
environment variable in.env
to the name of the rule set.
AWS CDK is used for managing the AWS infrastructure as code. It also handles the compilation and deployment of the Lambda function.
More detail about the CDK CLI
The `cdk` CLI is installed as part of the project's dependencies (so should already be installed at this point in the instructions). There are a number of `npm` scripts setup for executing common CDK commands (see `package.json`), and you can execute all `cdk` commands using `npx cdk` (i.e. `npx cdk destroy`).-
Bootstrap the AWS environment:
npx cdk bootstrap
-
Optional: Preview the AWS changes to be deployed:
npm run diff
-
Deploy everything to AWS:
npm run deploy
This step is only necessary if you are using a new domain that has not been verified in AWS SES already.
More detail about SES and domain verification
In Amazon SES, a verified identity is a domain that you use to send or receive email.
Before you can receive an email using Amazon SES, you must create and verify each identity that you're going to use. You must complete the verification process with your DNS provider.
- When the stack is deployed following the prior section's steps, it will output the CNAME and MX records that you need to add to your domain's DNS records in order to verify SES is able to receive emails on its behalf.
- Add the CNAME and MX records to your domain’s DNS settings.
You can check the verification status of your domain in the "Verified identities" section of the AWS SES console page. You should also receive an email when the verification is complete.