Using variables when saving state to AWS backend in Terraform using GitLab CI/CD

I have been trying to get the aws backend setup working within, the gitlab CI/CD. I would like to be able to feed variables into the backend. I found they the were not able to be set directly, but using

terraform init -backend-config aws.tfvars 

with the appropriate variables it works locally as expected.

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 3.27"
    }
  }
  backend "aws" {
  }
}

However, when I try to “gitlab-terraform init” using the gitlab-ci.yml, I consistently get the errors:

Error: "bucket": required field is not set
Error: "key": required field is not set

I have been able to trace that the variables are able to be cat’d from the job that is running the init. The issue seems to be tied to the group/subgroup configuration: Troubleshooting the Terraform integration with GitLab | GitLab

I followed the example for the “http” backend and it works great. It seems like the group/subgroup is setup for the variables required for the http backend, but maybe not for the aws one.

Here is an example using http that does work: Storing Your Terraform State in Gitlab

Has anyone run into this issue or found a way to get the aws working with variables in the gitlab ci/cd setup?