-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support configuration_aliases argument #40
Comments
@takumin Thank you for reporting this! I confirmed that if we have the I found the root cause of this problem is a dirty hack in the tfupdate implementation due to limitations of the hcl library. We expect a literal expression here: If my understanding is correct, the I think it should be fixed, but it may be quite difficult under the current technical constraints. I'm not sure how to fix it for now 🤔 |
I found the |
Fixes #40 The tfupdate mainly uses the hclwrite parser to preserve comments, but the hclwrite doesn't have enough AST for an object type, as a compromise, the tfupdate also uses the hclsyntax parser to detect old version. Terraform v0.15 introduced a new configuration_aliases syntax. https://www.terraform.io/upgrade-guides/0-15.html#alternative-provider-configurations-within-modules It's not directly related version updating but it contains provider references and it causes a parse error without an EvalContext. The ideal solution would be extending the hclwrite to be able to parse such a complicated object, but it's not realistic to expect it to be possible in the short term. So I decided to add a new hack on top of the existing hack to achieve the short term goal. After seeking a temporary solution, I found that the terraform-config-inspect parses the configuration_aliases by using a hcl.ExprMap which doesn't require to decode fully references. I feel the implementation is messy and fragile. It's probably better not to re-implement by ourselves and depend on the terraform-config-inspect. However the terraform-config-inspect loads a root module not a file, and the current implementation of tfupdate detects and updates version in a single file. It's hard to use it for now. Using the terraform-config-inspect would require additional refactors for splitting the implementation to detecting and updating. To minimize the patch, I fixed only how to parse the required_providers block.
Fixes #40 The tfupdate mainly uses the hclwrite parser to preserve comments, but the hclwrite doesn't have enough AST for an object type, as a compromise, the tfupdate also uses the hclsyntax parser to detect old version. Terraform v0.15 introduced a new configuration_aliases syntax. https://www.terraform.io/upgrade-guides/0-15.html#alternative-provider-configurations-within-modules It's not directly related version updating but it contains provider references and it causes a parse error without an EvalContext. The ideal solution would be extending the hclwrite to be able to parse such a complicated object, but it's not realistic to expect it to be possible in the short term. So I decided to add a new hack on top of the existing hack to achieve the short term goal. After seeking a temporary solution, I found that the terraform-config-inspect parses the configuration_aliases by using a hcl.ExprMap which doesn't require to decode fully references. I feel the implementation is messy and fragile. It's probably better not to re-implement by ourselves and depend on the terraform-config-inspect. However the terraform-config-inspect loads a root module not a file, and the current implementation of tfupdate detects and updates version in a single file. It's hard to use it for now. Using the terraform-config-inspect would require additional refactors for splitting the implementation to detecting and updating. To minimize the patch, I fixed only how to parse the required_providers block.
Fixes #40 The tfupdate mainly uses the hclwrite parser to preserve comments, but the hclwrite doesn't have enough AST for an object type, as a compromise, the tfupdate also uses the hclsyntax parser to detect old version. Terraform v0.15 introduced a new configuration_aliases syntax. https://www.terraform.io/upgrade-guides/0-15.html#alternative-provider-configurations-within-modules It's not directly related version updating but it contains provider references and it causes a parse error without an EvalContext. The ideal solution would be extending the hclwrite to be able to parse such a complicated object, but it's not realistic to expect it to be possible in the short term. So I decided to add a new hack on top of the existing hack to achieve the short term goal. After seeking a temporary solution, I found that the terraform-config-inspect parses the configuration_aliases by using a hcl.ExprMap which doesn't require to decode fully references. I feel the implementation is messy and fragile. It's probably better not to re-implement by ourselves and depend on the terraform-config-inspect. However the terraform-config-inspect loads a root module not a file, and the current implementation of tfupdate detects and updates version in a single file. It's hard to use it for now. Using the terraform-config-inspect would require additional refactors for splitting the implementation to detecting and updating. To minimize the patch, I fixed only how to parse the required_providers block.
@takumin Fixed in v0.5.1 🚀 |
Starting with Terraform 0.15,
configuration_aliases
is available.See also 1: https://www.terraform.io/upgrade-guides/0-15.html#alternative-provider-configurations-within-modules
See also 2: https://www.terraform.io/docs/language/modules/develop/providers.html#provider-aliases-within-modules
For example, the following declaration.
Are you planning to support this syntax?
The text was updated successfully, but these errors were encountered: