module "slzApolloApiFlow_role" {
  source      = "../../../modules/iam/roles/stepfunction_role"
  name_prefix = local.name_prefix
  name        = "slzApolloApiFlow_role"
  common_tags = merge(
    local.common_tags,
    {
      project                  = "SLZ Ingestion",
      service                  = "Step Functions",
      plat_env_project_service = "${local.aggregated_tag}_SLZI_SFU"
    }
  )
  policies_list = [
    module.iam_map.lambda_invoke.arn,
    data.aws_iam_policy.logging.arn,
  ]
}

resource "aws_sfn_state_machine" "slzApolloApiFlow" {
  name       = "${local.name_prefix}-slzApolloApiFlow"
  role_arn   = module.slzApolloApiFlow_role.role.arn
  definition = <<EOF
{
  "StartAt": "Placeholder",
  "States": {
    "Placeholder": {
      "Type": "Pass",
      "End": true
    }
  }
}
EOF
  tags = merge(
    local.common_tags,
    {
      project                  = "SLZ Ingestion",
      service                  = "Step Functions",
      plat_env_project_service = "${local.aggregated_tag}_SLZI_SFU"
    }
  )
  lifecycle {
    ignore_changes = [definition]
  }
}

module "dae_apollo_api_scraper_role" {
  source = "../../../modules/iam/roles/lambda_role"

  name_prefix                = "${local.env_prefix}-${local.project_group}"
  name                       = "dae_apollo_api_scraper_role"
  allow_execution_inside_vpc = true

  policies_list = [
    data.aws_iam_policy.logging.arn,
    data.aws_iam_policy.secrets-services-ro.arn,
    module.iam_map.s3_env_rw.arn,
  ]

  common_tags = merge(
    local.common_tags,
    {
      project                  = "Delphi Application Enablement",
      service                  = "Lambda",
      plat_env_project_service = "${local.aggregated_tag}_DAE_LMB"
    }
  )
}
