Skip to content

Latest commit

 

History

History
71 lines (46 loc) · 3.23 KB

create-environment.md

File metadata and controls

71 lines (46 loc) · 3.23 KB

Creating a new environment

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

1️⃣ Install and configure your local environment

  1. Copy .env.example to .env and update its values. Code comments in .env will guide you on additional setup steps that may be necessary.
  2. Install dependencies: npm install
  3. 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).

2️⃣ Manually create an AWS SES rule set

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:

  1. Create an SES rule set
  2. Set the rule set to Active.
  3. Set the SES_RULE_SET_NAME environment variable in .env to the name of the rule set.

3️⃣ Deploy to AWS

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`).
  1. Authenticate the AWS CLI

  2. Bootstrap the AWS environment:

    npx cdk bootstrap
  3. Optional: Preview the AWS changes to be deployed:

    npm run diff
  4. Deploy everything to AWS:

    npm run deploy

4️⃣ Verify your email domain

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.

  1. 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.
  2. 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.