From 492184c809d8babd53d1b4509fda3b5bf73ccfab Mon Sep 17 00:00:00 2001 From: Buckingham Date: Fri, 22 Nov 2024 14:44:29 +0000 Subject: [PATCH] Update_221124_2 --- terraform/environments/ppud/iam.tf | 60 ++++++++++- terraform/environments/ppud/lambda.tf | 42 ++++++++ .../ppud/lambda_scripts/send_cpu_graph_dev.py | 101 ++++++++++++++++++ 3 files changed, 202 insertions(+), 1 deletion(-) create mode 100644 terraform/environments/ppud/lambda_scripts/send_cpu_graph_dev.py diff --git a/terraform/environments/ppud/iam.tf b/terraform/environments/ppud/iam.tf index c2c40933966..aa7104e6601 100644 --- a/terraform/environments/ppud/iam.tf +++ b/terraform/environments/ppud/iam.tf @@ -1138,4 +1138,62 @@ resource "aws_iam_role_policy_attachment" "attach_aws_signer_policy_to_aws_signe count = local.is-development == true ? 1 : 0 role = aws_iam_role.aws_signer_role_dev[0].name policy_arn = aws_iam_policy.aws_signer_policy_dev[0].arn -} \ No newline at end of file +} + +############################################# +# IAM Role & Policy for Send CPU graph - DEV +############################################# + +resource "aws_iam_role" "lambda_role_cloudwatch_get_metric_data_dev" { + count = local.is-development == true ? 1 : 0 + name = "PPUD_Lambda_Function_Role_Cloudwatch_Get_Metric_Data_Dev" + assume_role_policy = <

{email_body}

" + ) + + try: + ses.send_email( + Source=email_sender, + Destination={'ToAddresses': [email_recipient]}, + Message={ + 'Subject': {'Data': email_subject}, + 'Body': { + 'Html': {'Data': email_html_body} + } + } + ) + print(f"Email sent successfully to {email_recipient}") + except ClientError as e: + print(f"Error sending email: {e}") + return {'statusCode': 500, 'body': str(e)} + + return {'statusCode': 200, 'body': 'Email sent successfully'}