How to pass a dynamic policy to a module

I created a module for Rest api that needs a different role dependens on the specification.

Currently I hardcoded a policy and allow sts:AssumeRole using this code:

data "aws_iam_policy_document" "lambda_role" {
    statement {
      actions = ["sts:AssumeRole"]
      principals {
        type        = "Service"
        identifiers = [""]
      effect = "Allow"

  resource "aws_iam_role" "lambda_function_role" {
    name = "${var.lambda_function_name}_role"

    assume_role_policy = data.aws_iam_policy_document.lambda_role.json

and in

  module "myModule" {
    source                   = "../../modules/api"
    lambda_function_name = "products"

I’m looking for passing a dynamic policy config to the module without hardcoding. Is there any possibility to pass a dynamic policy config as a variable to a module with Terraform?

I have the same question. Did you ever figure this out?

UPDATE, I’ve asked a similar question here: How do I pass a configuration block to a variable?