From 0cf0f16948199db76499650b11b1e2e566156561 Mon Sep 17 00:00:00 2001 From: Joel Balcaen Date: Fri, 3 May 2024 15:32:46 -0300 Subject: [PATCH] allow sending email --- .../rfp_email_form_fill/state_machine.json | 41 ++++++++++++++++++- .../rfp_email_form_fill/state_machine.tf | 23 +++++++++++ 2 files changed, 63 insertions(+), 1 deletion(-) diff --git a/state_machines/rfp_email_form_fill/state_machine.json b/state_machines/rfp_email_form_fill/state_machine.json index 9a7ed22..5091e8a 100644 --- a/state_machines/rfp_email_form_fill/state_machine.json +++ b/state_machines/rfp_email_form_fill/state_machine.json @@ -392,12 +392,51 @@ } }, "ItemsPath": "$.download_email_attachments_ouput.Payload.attachments", - "Next": "Get Prompts", + "Next": "Check has LLM friendly files", "ResultSelector": { "attachment_uris.$": "$[*][*]" }, "Type": "Map", "ResultPath": "$.parsed_attachments_for_llm_ouput" + }, + "Check has LLM friendly files": { + "Type": "Choice", + "Choices": [ + { + "Not": { + "Variable": "$.parsed_attachments_for_llm_ouput[0]", + "IsPresent": true + }, + "Next": "Send no valid attachments email" + } + ], + "Default": "Get Prompts" + }, + "Send no valid attachments email": { + "Type": "Task", + "Next": "Fail", + "Parameters": { + "FromEmailAddress.$": "$.execution_metadata.destination_email[0]", + "Destination": { + "ToAddresses.$": "States.Array($.execution_metadata.sender_email)" + }, + "Content": { + "Simple": { + "Subject": { + "Data": "Erreur de pièce jointe incompatible" + }, + "Body": { + "Text": { + "Data": "Seul les fichiers des format suivant sont acceptés: pdf, txt, csv, docx, xlsx, json, png, jpeg" + } + } + } + } + }, + "Resource": "arn:aws:states:::aws-sdk:sesv2:sendEmail" + }, + "Fail": { + "Type": "Fail" } } } diff --git a/state_machines/rfp_email_form_fill/state_machine.tf b/state_machines/rfp_email_form_fill/state_machine.tf index 8825afa..ea283f3 100644 --- a/state_machines/rfp_email_form_fill/state_machine.tf +++ b/state_machines/rfp_email_form_fill/state_machine.tf @@ -67,6 +67,29 @@ resource "aws_iam_role_policy" "sfn_lambda_invoke_access" { EOF } +resource "aws_iam_role_policy" "ses_send_email_access" { + name = "ses_send_email_access" + role = aws_iam_role.iam_for_sfn.id + + policy = <