Map attribute with object elements -- with optional attributes?

Hello!

I’m writing a provider and have a resource attribute defined like this:

resp.Schema = schema.Schema{
    Attributes: map[string]schema.Attribute{
        "policy": schema.SingleNestedAttribute{
            Optional:            true,
            Attributes: map[string]schema.Attribute{
                "default_env": schema.MapAttribute{
                    ElementType:         EnvV,
                    Optional:            true,
                },
            },
        },
    },
   // ...
}

Where EnvV looks like:

var EnvV = types.ObjectType{
    AttrTypes: map[string]attr.Type{
        "value":  types.StringType,
        "secret": EnvSecretV,
    },
}

Is it possible to make the value and secret fields on EnvV optional? Or should I be defining this differently?

Ah MapNestedAttribute seems to be the answer!