where DefaultValueFromEnvironment is a simple modification of the DefaultValue attribute plan modifier.
The problem is that I can’t mark the attribute as required (as in either set in the resource, or from the environment variable), since required seems to be checked a long time before the attribute plan modifiers are ran.
Sorry, but I never found a solution. There seems to be little progress on the new API, and even less interest in supporting and answering early adopters.
I apologize for the delay. Is the username attribute defined in a Provider schema? And is it a top-level attribute or defined within a Block?
In general, we don’t allow the Required field to be defined with the PlanModifiers or Default fields for Resources in the Framework to prevent the Provider from overwriting any user configuration. In either of those cases the attribute would need to be marked Optional and Computed.
If this is an attribute in a Provider schema, then since newer versions of the Framework no longer allow PlanModifiers to be set in Provider schemas (there’s no concept of “planning” at the Provider level), you would move the logic of your DefaultValueFromEnvironment() function to the Provider level Configure() method instead.