Skip to content

Commit

Permalink
allow sending email
Browse files Browse the repository at this point in the history
  • Loading branch information
joelbalcaen committed May 3, 2024
1 parent 4eabb76 commit 0cf0f16
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 1 deletion.
41 changes: 40 additions & 1 deletion state_machines/rfp_email_form_fill/state_machine.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}
}
Expand Down
23 changes: 23 additions & 0 deletions state_machines/rfp_email_form_fill/state_machine.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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 = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"ses:SendEmail",
"ses:SendRawEmail"
],
"Resource": "*"
}
]
}
EOF
}




resource "aws_sfn_state_machine" "sfn_state_machine" {
name = "esta-rfp-form-filler"
Expand Down

0 comments on commit 0cf0f16

Please sign in to comment.