backport of commit d6283a9352fe46e20206a4ab9ed76ff0c04bde53 Co-authored-by: DanStough <dan.stough@hashicorp.com>