Stelvio supports creating and managing Amazon SES (Simple Email Service) identities using the Email component. This allows you to send emails from your applications.
Sandbox Mode
Your AWS account might be sandboxed and thus, only allows validated email recipients.
You can create an email identity by instantiating the Email component in your stlv_app.py.
fromstelvio.aws.emailimportEmailfromstelvio.aws.functionimportFunction@app.rundefrun()->None:# Create an email identityemail=Email("stlv_email","sender@example.com",)# Link it to a functionlinked_function=Function("MyFunctionA",handler="functions/api.handler",url="public",links=[email],)
Sending Emails
Using the linking mechanism, you can easily access the SES identity in your Lambda functions using the regular boto3 library.
The Email component exposes the sender identity and its ARN through stlv_resources.
importboto3fromstlv_resourcesimportResourcesdefhandler(event,context):client=boto3.client('sesv2')# Access the linked resource propertiesresources=Resources.stlv_emailSENDER=resources.email_identity_senderRECIPIENT="recipient@example.com"body="Hello from Stelvio!"response=client.send_email(FromEmailAddress=SENDER,Destination={'ToAddresses':[RECIPIENT]},Content={'Simple':{'Subject':{'Data':'Test Subject'},'Body':{'Text':{'Data':body}}}})return{"statusCode":200,"body":"Email sent!"}
Domain Identities
If you provide a domain name instead of an email address as the sender, Stelvio will create a domain identity.
AWS accounts start in SES sandbox mode, which restricts sending to verified email addresses only. Stelvio provides a sandbox parameter to configure permissions accordingly.
When sandbox=True, the linked Lambda function receives broader permissions ("*" resource) for sending emails, which is required when your account is in sandbox mode. Once you have requested production access, you can set sandbox=False (the default) to use more restrictive permissions.
Event Destinations
You can configure SNS event destinations to receive notifications about email events such as bounces, complaints, and deliveries.
The Email component supports the customize parameter to override underlying Pulumi resource properties. For an overview of how customization works, see the Customization guide.