• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

intuit / Trapheus / 7ecf2541-e446-4544-a68f-78cc8fdb3252

04 Oct 2023 08:10AM UTC coverage: 95.298%. Remained the same
7ecf2541-e446-4544-a68f-78cc8fdb3252

push

circleci

github-actions[bot]
docs: Added README."fr".md translation via https://github.com/dephraiim/translate-readme

527 of 553 relevant lines covered (95.3%)

0.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/emailalert/email_function.py
1
import os
1✔
2
import constants
1✔
3
import boto3
1✔
4

5
def lambda_handler(event, context):
1✔
6
    """Handles email alerts for any failure scenario in db instance or cluster state machine"""
7
    SENDER = os.environ['SenderEmail']
1✔
8
    RECIPIENTS = os.environ['RecipientEmail'].split(',')
1✔
9
    AWS_REGION = os.environ['Region']
1✔
10
    SUBJECT = "Failure alert for RDS Restore Pipeline"
1✔
11
    result = {}
1✔
12
    if 'status' in event:
1✔
13
        result[constants.ERROR] = event['taskname'] + 'Error'
1✔
14
        result[constants.CAUSE] = event['status']
1✔
15
    elif 'Error' in event:
1✔
16
        result[constants.ERROR] = event['Error']
1✔
17
        result[constants.CAUSE] = event['Cause']
1✔
18
    BODY_HTML = """<html>
1✔
19
    <head></head>
20
    <body>
21
    <h1>Failure alert for RDS Restore Pipeline</h1>
22
    <p>""" + result['Error'] + """ : """ + result['Cause'] + """</p>
23
    </body>
24
    </html>"""
25

26
    CHARSET = "UTF-8"
1✔
27
    client = boto3.client('ses',region_name=AWS_REGION)
1✔
28

29
    # Try to send the email.
30
    try:
1✔
31
        #Provide the contents of the email.
32
        response = client.send_email(
1✔
33
            Destination={
34
                'ToAddresses': RECIPIENTS,
35
            },
36
            Message={
37
                'Body': {
38
                    'Html': {
39
                        'Charset': CHARSET,
40
                        'Data': BODY_HTML,
41
                    },
42
                },
43
                'Subject': {
44
                    'Charset': CHARSET,
45
                    'Data': SUBJECT,
46
                },
47
            },
48
            Source=SENDER
49
        )
50
    # Display an error if something goes wrong.
51
    except Exception as e:
1✔
52
        raise Exception(e)
1✔
53
    else:
54
        result['message'] = response['MessageId']
1✔
55

56
    return result
1✔
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc