Yaml file skip content without values

I have this yaml structure. I’m able the read this with the terraform code below. The problem I run into is that ViewOnlyAccess role does not have values for authorizations. Therefore terraform stops with ** The expression result is null. Cannot include a null value in a string template.**

How can I check if this values are null and then simply skip them?

  ciss-dev:
    accountid: "098453041XXX"
    roles:
      AdministratorAccess:
        authorizations:
          - name: "aws-infrastructure-core-vpc"
            namespace: 91
            project: 164
          - name: "vault-auth01-goes-dev"
            namespace: 110
            project: 207
      Billing:
        authorizations:
          - name: "aws-infrastructure-core-vpc"
            namespace: 91
            project: 164
      ViewOnlyAccess:
        authorizations:
          - name:
            namespace:
            project:
resource "vault_aws_secret_backend_role" "gitlab" {

  for_each = {
    for s in local.gitlab : "gitlab-${s.namespace}-${s.project}-${s.pipeline_name}-${s.account_id}-${s.account_name}--${s.role_name}" => s...
    if var.aws_enabled
  }
  backend = vault_aws_secret_backend.aws-ciss.path
  name  = each.key
  credential_type = "iam_user"
  policy_document = <<EOT
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iam:*",
      "Resource": "*"
    }
  ]
}
EOT
}
  gitlab = flatten([
    for name, id in var.aws_accounts : [
      for role, pl  in id.roles : [
        for p in pl.authorizations  : {
          account_name    = name
          account_id      = id.accountid
          role_name       = role
          pipeline_name   = p.name
          namespace       = p.namespace
          project         = p.project
        }
      ]
    ]
  ])

Found a solution for this.

resource "vault_aws_secret_backend_role" "gitlab" {

  for_each = {
    for s in local.gitlab : "gitlab-${s.namespace}-${s.project}-${s.pipeline_name}-${s.account_id}-${s.account_name}--${s.role_name}" => s...
    if s.pipeline_name != null || s.project != null || s.namespace != null
  }
  backend = vault_aws_secret_backend.aws-ciss.path
  name  = each.key
  credential_type = "iam_user"
  policy_document = <<EOT
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "iam:*",
      "Resource": "*"
    }
  ]
}
EOT
}