IAM for API -> Lambda -> SQS -> Lambda -> SES

I am trying to setup a aws_apigatewayv2_api that calls a aws_lambda_function, which sends something into a aws_sqs_queue, which is connected via aws_lambda_event_source_mapping to another aws_lambda_function which then will send a message via SES.

All to control the sending speed to SES :-/

What I am struggling with is the IAM part defining:

aws_iam_role
aws_iam_policy
aws_iam_role_policy_attachment
aws_iam_policy_document
aws_lambda_permission

correctly.

Before I get into specifics about the configuration. Is this right place to ask? Or is this not terraform specific enough?

Or does anyone know of a similar example available somewhere? Most examples I found are usually on the “hello world” level.

@tcurdt I can’t promise success, but I will try to help if you describe the issue in detail.
I am preparing for AWS SAP exam so I need some practice :joy:

Thanks for the offer :slight_smile:
Not a fun ride - but I figured it out in the end.

The biggest problem left is controlling the throughput of the SQS consumer. Even at a concurrency of 1. It seems like there is just no mechanism for that in AWS. And delaying delivery in a lambda is not exactly a smart thing to do.