Set configuration from environment variable

I have a config.toml that looks like this

[[deployment.targets]]
name = “s3”
URL = “s3://foobarbaz?region=us-east-1”
cloudFrontDistributionID = “E1IL5123456789”

I would like to remove cloudFrontDistributionID from the file and set it in the environment. I’ve read the docs on configuring Hugo with environment variables but found them a little terse. I tried a bunch of things like HUGO_DEPLOYMENT_TARGETS_cloudFrontDistributionID but no joy. Is this possible?

And if not, how do people set secrets in Hugo configuration in the context of a CI pipeline?

I believe you configure the deployment variables per the service used, in your case S3. The CLI should have docs on authentication via environmental variables, set in your build process.

Try all upper case.

All upper case did not work either. Not picked up by hugo. Is DEPLOYMENT_TARGETS the right way to translate deployment.targets?

Thanks. I guess I should be clearer that the specific configration variable is a red herring. I’m asking how to set arbitrary config.toml entries from the environment. The docs imply this is possible, but the text is too terse for me to make sense of it.

OK, now I see. The thing is “[[deployment.targets]]” is a slice/array of values, and I’m pretty sure you curently cannot do DEPLOYMENT_TARGETS[0].NAME = “FOO” etc. from the environment, but it would be useful.