Repository: runatlantis/atlantis (language: go)

Issue:
Terraform version detection fails when `configuration_aliases` is specified in a `required_providers` block
<!--- Please keep this note for the community --->

### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request. Searching for pre-existing feature requests helps us consolidate datapoints for identical requirements into a single place, thank you!
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.
* If you are interested in working on this issue or have submitted a pull request, please leave a comment.

<!--- Thank you for keeping this note for the community --->

---

<!--- When filing a bug, please include the following headings if possible. Any example text in this template can be deleted. --->

### Overview of the Issue
This is a duplicate of #2355 which was closed without discussion.

When attempting to plan a project with an exact terraform version specified and `configuration_aliases` set in a subsequent required providers configuration the terraform version specified is not used.

<!--- Please describe the issue you are having and how you encountered the problem. --->

### Reproduction Steps
With the following in a terraform file: 

```hcl
terraform {
  required_version = "1.2.9"

  required_providers {
    aws = {
      source                = "hashicorp/aws"
      version               = ">= 2.42"
      configuration_aliases = [aws.replica]
    }
  }
}
```

Atlantis fails to initialize and plan with the following output:

```
running "/usr/local/bin/terraform init -input=false" in "/home/atlantis/.atlantis/repos/drata/terraform/836/default/aws/prod/retool": exit status 1

Initializing modules...
Downloading ... cut for brevity ...
╷
│ Error: Unsupported Terraform Core version
│ 
│   on backend.tf line 15, in terraform:
│   15:   required_version = "1.2.9"
│ 
│ This configuration does not support Terraform version 1.3.1. To proceed,
│ either choose another supported Terraform version or update this version
│ constraint. Version constraints are normally set for good reason, so
│ updating the constraint may lead to other errors or unexpected behavior.
╵
```

Removing the line with `configuration_aliases` allows the init and plan to proceed.
<!--- 

In order to effectively and quickly resolve the issue, please provide exact steps that allow us the reproduce the problem. If no steps are provided, then it will likely take longer to get the issue resolved.
  
--->

### Logs

```
[info] 2022-10-18T20:26:34.336Z: successfully parsed atlantis.yaml file
[info] 2022-10-18T20:26:34.360Z: 1 projects are to be planned based on their when_modified config
[error] 2022-10-18T20:26:34.398Z: trying to detect required version: Variables not allowed: Variables may not be used here.
[info] 2022-10-18T20:26:36.315Z: acquired lock with id \"drata/terraform/aws/prod/retool/default\"
[info] 2022-10-18T20:26:36.315Z: Refreshing git tokens for Github App
[info] 2022-10-18T20:26:36.336Z: successfully ran \"echo \\\"default plan\nTerraform Version: ${ATLANTIS_TERRAFORM_VERSION}\\\"\" in \"/home/atlantis/.atlantis/repos/drata/terraform/836/default/aws/prod/retool\"
[info] 2022-10-18T20:26:36.338Z: successfully ran \"mkdir -p ~/.aws\" in \"/home/atlantis/.atlantis/repos/drata/terraform/836/default/aws/prod/retool\"
[info] 2022-10-18T20:26:36.371Z: successfully ran \"cp `git rev-parse --show-toplevel`/atlantis_aws_config ~/.aws/config || true\" in \"/home/atlantis/.atlantis/repos/drata/terraform/836/default/aws/prod/retool\"
[error] 2022-10-18T20:27:03.993Z: running \"/usr/local/bin/terraform init -input=false\" in \"/home/atlantis/.atlantis/repos/drata/terraform/836/default/aws/prod/retool\": exit status 1
[error] 2022-10-18T20:27:04.494Z: Error running plan operation: running \"/usr/local/bin/terraform init -input=false\" in \"/home/atlantis/.atlantis/repos/drata/terraform/836/default/aws/prod/retool\": exit status 1
default plan
Terraform Version: 1.3.1

Initializing modules...
Downloading git::ssh://git@github.com/drata/terraform-module-aws-backup-vault.git?ref=1.0.0 for backup_vault...
- backup_vault in .terraform/modules/backup_vault
... cut for brevity ...
╷
│ Error: Unsupported Terraform Core version
│ 
│   on backend.tf line 15, in terraform:
│   15:   required_version = \"1.2.9\"
│ 
│ This configuration does not support Terraform version 1.3.1. To proceed,
│ either choose another supported Terraform version or update this version
│ constraint. Version constraints are normally set for good reason, so
│ updating the constraint may lead to other errors or unexpected behavior.
╵"
```

### Environment details

- Atlantis version: v0.19.9
- If not running the latest Atlantis version have you tried to reproduce this issue on the latest version: No
- Atlantis flags: 
```dotenv
ATLANTIS_ALLOW_REPO_CONFIG=false
ATLANTIS_LOG_LEVEL=debug
ATLANTIS_ATLANTIS_URL=https://atlantis.drata.net
ATLANTIS_GH_APP_ID=<redacted>
ATLANTIS_GH_API_KEY=<redacted>
ATLANTIS_GH_WEBHOOK_SECRET=<redacted>
ATLANTIS_REPO_ALLOWLIST=<omitted>
ATLANTIS_REPO_CONFIG_JSON=<omitted>
```




Discussion / hints:
It looks like that error is coming from a dependency: `github.com/hashicorp/terraform-config-inspect/tfconfig` This probably isn't an Atlantis problem but would appreciate someone double checking me on that.
Looking at this with fresh eyes this morning I notice that `terraform-config-inspect` is locked to [c481b8bf](https://github.com/hashicorp/terraform-config-inspect/commit/c481b8bfa41ea9dca417c2a8a98fd21bd0399e14) (a commit from 2020) and support for `configuration_aliases` was added in [9a80970](https://github.com/hashicorp/terraform-config-inspect/commit/9a80970d6b348d0c23719ed60bccb83d4bfc2ccd) in 2021. I'll put together a commit to update to the latest commit and see what the test suite says.

Fix patch:
diff --git a/go.mod b/go.mod
index e54b0137e5..bb21060377 100644
--- a/go.mod
+++ b/go.mod
@@ -22,7 +22,7 @@ require (
 	github.com/gorilla/websocket v1.5.0
 	github.com/hashicorp/go-getter v1.6.2
 	github.com/hashicorp/go-version v1.6.0
-	github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e
+	github.com/hashicorp/terraform-config-inspect v0.0.0-20221012204812-413b69327090
 	github.com/mcdafydd/go-azuredevops v0.12.1
 	github.com/microcosm-cc/bluemonday v1.0.21
 	github.com/mitchellh/colorstring v0.0.0-20150917214807-8631ce90f286
diff --git a/go.sum b/go.sum
index 32998e08f7..741be8d663 100644
--- a/go.sum
+++ b/go.sum
@@ -332,6 +332,8 @@ github.com/hashicorp/serf v0.9.6/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpT
 github.com/hashicorp/serf v0.9.7/go.mod h1:TXZNMjZQijwlDvp+r0b63xZ45H7JmCmgg4gpTwn9UV4=
 github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e h1:wIsEsIITggCC4FTO9PisDjy561UU7OPL6uTu7tnkHH8=
 github.com/hashicorp/terraform-config-inspect v0.0.0-20200806211835-c481b8bfa41e/go.mod h1:Z0Nnk4+3Cy89smEbrq+sl1bxc9198gIP4I7wcQF6Kqs=
+github.com/hashicorp/terraform-config-inspect v0.0.0-20221012204812-413b69327090 h1:UnVTr6jkguxyA4OfL9kJOoe4hoWyicC+LRiS4e3EJl0=
+github.com/hashicorp/terraform-config-inspect v0.0.0-20221012204812-413b69327090/go.mod h1:Z0Nnk4+3Cy89smEbrq+sl1bxc9198gIP4I7wcQF6Kqs=
 github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
 github.com/huandu/xstrings v1.3.1 h1:4jgBlKK6tLKFvO8u5pmYjG91cqytmDCDvGh7ECVFfFs=
 github.com/huandu/xstrings v1.3.1/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=


Test patch: