From a1a6b0601ba3284379f4893d5d347babe419d696 Mon Sep 17 00:00:00 2001 From: Joel Balcaen Date: Fri, 19 Apr 2024 18:26:27 -0300 Subject: [PATCH] put object lambda --- .../email_form_fill/state_machine.tf | 27 +++++++++++++++++++ state_machines/email_form_fill/variables.tf | 6 +++++ terraform/modules.tf | 3 ++- 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/state_machines/email_form_fill/state_machine.tf b/state_machines/email_form_fill/state_machine.tf index fd0f4ee..0cd04f5 100644 --- a/state_machines/email_form_fill/state_machine.tf +++ b/state_machines/email_form_fill/state_machine.tf @@ -18,6 +18,13 @@ resource "aws_iam_role" "iam_for_sfn" { "lambda:InvokeFunction" ], "Resource": "*" + }, + { + "Effect": "Allow", + "Action": [ + "s3:PutObject" + ], + "Resource": "arn:aws:s3:::*/*" } ] } @@ -33,6 +40,26 @@ resource "aws_sfn_state_machine" "sfn_state_machine" { "Comment": "A description of my state machine", "StartAt": "Lambda Invoke", "States": { + "Store Email Medata": { + "Type": "Task", + "Next": "Lambda Invoke", + "Parameters": { + "Body": { + "sender_email": "joel.balcaen@levio.ca", + "destination_email": "bla", + "prompts": [ + { + "key": "A", + "prompt": "", + "answer": "" + } + ] + }, + "Bucket": "${var.workspace_bucket_name}", + "Key": "MyData" + }, + "Resource": "arn:aws:states:::aws-sdk:s3:putObject" + }, "Lambda Invoke": { "Type": "Task", "Resource": "arn:aws:states:::lambda:invoke", diff --git a/state_machines/email_form_fill/variables.tf b/state_machines/email_form_fill/variables.tf index a3df896..0b16ac1 100644 --- a/state_machines/email_form_fill/variables.tf +++ b/state_machines/email_form_fill/variables.tf @@ -1,4 +1,10 @@ variable "attachment_saver_lambda_name" { type = string nullable = false +} + +variable "workspace_bucket_name" { + type = string + nullable = false + } \ No newline at end of file diff --git a/terraform/modules.tf b/terraform/modules.tf index c4b8bf1..85699e8 100644 --- a/terraform/modules.tf +++ b/terraform/modules.tf @@ -256,6 +256,7 @@ module "step_function_invoker" { module "email_formfiller_state_machine" { source = "../state_machines/email_form_fill" attachment_saver_lambda_name = module.attachment_saver.lambda_function_name + workspace_bucket_name = module.s3_bucket.s3_bucket_arn } @@ -263,6 +264,6 @@ module "email_attachment_saver" { source = "../lambdas/email_attachment_saver" lambda_storage_bucket = aws_s3_bucket.lambda_storage.id aws_region = var.aws_region - allowed_s3_resources = [module.s3_bucket.s3_bucket_arn] + allowed_s3_resources = [module.s3_bucket.s3_bucket_arn] }