-
Notifications
You must be signed in to change notification settings - Fork 358
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
Config() rpc call failing when terraform variable has default value but no type defined #1300
Comments
Hi @Vince-Chenal, thank you for opening this issue. I'm currently working on a major update to the plugin API, and perhaps the new API will be able to meet this requirement. providers, _ := runner.GetModuleContent(&hclext.BodySchema{
Blocks: []hclext.BlockSchema{
{
Type: "provider",
LabelNames: []string{"name"},
Body: &hclext.BodySchema{
Attributes: []hclext.AttributeSchema{{Name: "default_tags"}},
},
},
},
}, nil)
for _, provider := range providers.Blocks {
provider.Body.Attributes["default_tags"].Expr // => An expression of `default_tags`
} Please see here for details. You can try out the new API by building these.
If you're in a hurry, it's a bug that causes an error in the current |
Hey @wata727, |
Hey @wata727, I've been trying to adapt my custom plugin to the new sdk version with success so far. At some point I need to retrieve all the aws providers so I wrote the following code as you suggested:
I thought the schema would act as some kind of filter (retrieving only the providers that match this schema) but in the result I get all the providers and not only the ones that match the schema. Am I missing something? |
This is intended behavior. Top-level schemas only match provider blocks, but nested schemas are always optional. So, it also matches provider blocks that do not have The original issue has been fixed in v0.35, so close this issue. If you have any other questions about the SDK's usage, open a new issue in https://github.com/terraform-linters/tflint-plugin-sdk. |
I was writing a custom tflint ruleset and found this problem.
My usecase is to be able to verify that any aws provider has
default_tags
block defined.I can use
RootProvider()
function to get a provider by name like this:But I don't know the aliases in advance, so I need a way to list providers first.
I found this issue in which I saw that there was no official way for listing providers and that the only way was calling the
Config()
function and then search for.Module.ProviderConfigs
inside.Trying to do so, I got a lot of errors like this one:
After investigations I found that the problem was that
Config()
function is unable to encode variables that have a default value but no type defined.I think having a
RootProviders()
function listing all providers as suggested here would be the best option.In the meantime I'll stick with
Config()
function and catch the error.Steps to reproduce
tflint custom rule
Terraform
Working:
Not Working:
Version
The text was updated successfully, but these errors were encountered: