Error: variables not allowed Variables may not be used here

Hi,

I’m continuously getting below error when trying to deploy code files using AWS CodePipeline service, the same code files work with Azure DevOps pipeline. Please can someone help.

Initializing the backend…
73
74 Error: Variables not allowed
75
76 on main.tf line 8, in terraform:
77 8: bucket = backend_s3_bucket_name
78
79 Variables may not be used here.
80
81
82 Error: Variables not allowed
83
84 on main.tf line 9, in terraform:
85 9: key = backend_key
86
87 Variables may not be used here.
88
89
90 Error: Variables not allowed
91
92 on main.tf line 10, in terraform:
93 10: region = backend_s3_region
94
95 Variables may not be used here.

Hi @workaholicrohit,

Since you didn’t share your configuration I can’t be sure, but from the snippets included in the error message it seems like you have some invalid syntax here:

  • bucket is not a direct argument inside a terraform block. I think perhaps you intended to place it inside a backend "s3" block nested within the terraform block, or similar.
  • These backend configuration arguments expect literal values rather than variables. Where they are strings, that will generally mean values given in quotes, like bucket = "example".

If the above doesn’t answer your question then it would help if you could share your configuration and say a little more about what you are trying to achieve. Thanks!

1 Like