Skip to main content

Generate SES smtp credentials for a given user and store the credentials in a SecretsManager Secret.

Project description

PRs Welcome GitHub npm (scoped) PyPI Nuget Sonatype Nexus (Releases) GitHub Workflow Status (branch) GitHub release (latest SemVer) Gitpod ready-to-code

AWS CDK Ses Smtp Credentials

Generate SES smtp credentials for a user and store the credentials in a SecretsManager Secret.

View on Construct Hub

Install

TypeScript

npm install @pepperize/cdk-ses-smtp-credentials

or

yarn add @pepperize/cdk-ses-smtp-credentials

Python

pip install pepperize.cdk-ses-smtp-credentials

C# / .Net

dotnet add package Pepperize.CDK.SesSmtpCredentials

Java

<dependency>
  <groupId>com.pepperize</groupId>
  <artifactId>cdk-ses-smtp-credentials</artifactId>
  <version>${cdkSesSmtpCredentials.version}</version>
</dependency>

Usage

npm install @pepperize/cdk-ses-smtp-credentials

See API.md.

Create AWS SES Smtp Credentials for a given user

Attaches an inline policy to the user allowing to send emails

import { User } from "@aws-cdk/aws-iam";
import { SesSmtpCredentials } from "@pepperize/cdk-ses-smtp-credentials";

const user = new User(stack, "SesUser", {
  userName: "ses-user",
});
const smtpCredentials = new SesSmtpCredentials(this, "SmtpCredentials", {
  user: user,
});

// smtpCredentials.secret contains json value {username: "<the generated access key id>", password: "<the calculated ses smtp password>"}

See API Reference - SesSmtpCredentials

Create AWS SES Smtp Credentials and create a new user

Attaches an inline policy to the user allowing to send emails

import { User } from "@aws-cdk/aws-iam";
import { SesSmtpCredentials } from "@pepperize/cdk-ses-smtp-credentials";

const smtpCredentials = new SesSmtpCredentials(this, "SmtpCredentials", {
  userName: "ses-user",
});

// smtpCredentials.secret contains json value {username: "<the generated access key id>", password: "<the calculated ses smtp password>"}

See API Reference - SesSmtpCredentials

Calculate the AWS SES Smtp password on your own

import * as AWS from "aws-sdk";
import { calculateSesSmtpPassword } from "@pepperize/cdk-ses-smtp-credentials";

const iam = new AWS.IAM();
const accessKey = await iam
  .createAccessKey({
    UserName: username,
  })
  .promise();
const accessKeyId = accessKey.AccessKey.AccessKeyId;
const secretAccessKey = accessKey.AccessKey.SecretAccessKey;

const password = calculateSesSmtpPassword(secretAccessKey, "us-east-1");

console.log({
  username: accessKeyId,
  password: password,
});

See Obtaining Amazon SES SMTP credentials by converting existing AWS credentials

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Built Distribution

File details

Details for the file pepperize.cdk-ses-smtp-credentials-0.3.354.tar.gz.

File metadata

File hashes

Hashes for pepperize.cdk-ses-smtp-credentials-0.3.354.tar.gz
Algorithm Hash digest
SHA256 a4dba2e8d3e8abf037f3bb8f845a3aeffd09648a9285c367622fc266462e9c9b
MD5 f70607dbdf7f1a77164a050178d21493
BLAKE2b-256 7e6838a20aebbd3c74ef2418394442835ddfad9239d74d180bd5b0391cd6f89e

See more details on using hashes here.

Provenance

File details

Details for the file pepperize.cdk_ses_smtp_credentials-0.3.354-py3-none-any.whl.

File metadata

File hashes

Hashes for pepperize.cdk_ses_smtp_credentials-0.3.354-py3-none-any.whl
Algorithm Hash digest
SHA256 00054458f6bef61fa72c36fe716b10d8292cdc2cd0b5737b14ba8f423e8d6f48
MD5 a39ffd5f523e3b21c09e93ee6e64ced1
BLAKE2b-256 2374fbe81dc2bd1eda1f5d89b1001815b742608cf4157493254d30417fd273ce

See more details on using hashes here.

Provenance

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page