-
Notifications
You must be signed in to change notification settings - Fork 35
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
KeyError: 'type' with valid Ansible and Terrform data #93
Comments
The trace make it look like it errors here
|
@ahussey-redhat Is there a way you can provide a minimal terraform config to reproduce this problem? The error is coming from
The |
Hello @gravesm I have the exact same issue, but unfortunately, I can't share the whole code. However, I could extract the relevant parts of the json output, and "anonymise" what seems necessary. Could you tell me what it is you need that would help you identify the issue ? |
Sorry for my delay in response. |
terraform.tfstate: "type": "aws_iam_policy" I did a |
or maybe this? terraform.tfstate: "type": "null_resource",
terraform.tfstate: "type": "null_resource", |
Looking a bit closer at this, what we actually need would be the output of |
@gravesm This is something that should be fixed, right? Reproducing bug is currently the problem. |
@ahussey-redhat @MehuiSeklayr could you send output of Update: in between I tried to reproduce with terraform 1.6.2. I looked only at 35 official providers from https://registry.terraform.io/browse/providers?tier=official. The same bug was triggered by
json fragment from "hcp_iam_workload_identity_provider": {
"version": 0,
"block": {
"attributes": {
"aws": {
"nested_type": {
"attributes": {
"account_id": {
"type": "string",
"description": "The AWS Account ID that is allowed to exchange workload identities.",
"description_kind": "plain",
"required": true
}
},
"nesting_mode": "single"
},
"description_kind": "plain",
"optional": true
},
"conditional_access": {
"type": "string",
"description": "conditional_access is a hashicorp/go-bexpr string that is evaluated when exchanging tokens. It restricts which upstream identities are allowed to access the service principal.",
"description_kind": "plain",
"required": true
}, Schema is parsed only to detect sensitive values and hide them in output. If it is not worth to properly sanitize sensitive attributes in output, then a single line change in helps:
@classmethod
def from_json(cls, json: TJsonObject) -> "TerraformAttributeSpec":
return cls(
- type=json["type"],
+ type=json.get("type"), Proper sanitize needs some extra work, as TerraformAttributeSpec can contain other complex objects inside. |
Sorry for the delay in response.
The |
The |
Fixes ansible-collections#93 Signed-off-by: Justin Cinkelj <[email protected]>
I didn't but please find the requested output below, run from the directory the Terraform config resides in $ terraform version
Terraform v1.6.3
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.67.0
+ provider registry.terraform.io/hashicorp/null v3.2.1
+ provider registry.terraform.io/hashicorp/random v3.5.1
+ provider registry.terraform.io/hashicorp/time v0.9.1
+ provider registry.terraform.io/terraform-redhat/rhcs v1.4.0 |
The Output of a small debug script that is searching for
The
|
@justinc1 - what is the issue with nested types? RE the |
The |
Fantastic!
Thanks for your fast response and action to this issue
…On Wed, 8 Nov 2023, 18:26 justinc1, ***@***.***> wrote:
The nested_type was simply not implemented, and #101
<#101> does
the implementation.
—
Reply to this email directly, view it on GitHub
<#93 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AWGJ7GCH7W5IKWWWT22Q4DLYDMX2RAVCNFSM6AAAAAA55DFJ4GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMBRGIZTEMJRGY>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
Fixes ansible-collections#93 Signed-off-by: Justin Cinkelj <[email protected]>
* Allow terraform resource_schema attributes with nested_type Fixes #93 Signed-off-by: Justin Cinkelj <[email protected]> * Test nested_type attributes by using awscc Signed-off-by: Justin Cinkelj <[email protected]> * Update unit tests Signed-off-by: Justin Cinkelj <[email protected]> * Add changelog fragment Signed-off-by: Justin Cinkelj <[email protected]> * fix linters, mypy Signed-off-by: Justin Cinkelj <[email protected]> * isort fix Signed-off-by: Justin Cinkelj <[email protected]> --------- Signed-off-by: Justin Cinkelj <[email protected]>
SUMMARY
When running a
cloud.terraform.terraform
task to provision a Red Hat OpenShift Service on AWS (ROSA) instance, I am getting aKeyError: 'type'
.Both the Ansible and Terraform config are valid. If I go to the
project_path
and runterraform plan
it succeeds.ISSUE TYPE
COMPONENT NAME
module_utils/models.py
https://github.com/ansible-collections/cloud.terraform/blob/main/plugins/module_utils/models.py
ANSIBLE VERSION
COLLECTION VERSION
$ ansible-galaxy collection list cloud.terraform # /home/local-admin/.ansible/collections/ansible_collections Collection Version --------------- ------- cloud.terraform 1.1.1
CONFIGURATION
OS / ENVIRONMENT
STEPS TO REPRODUCE
Apply the Terraform from a
project_path
.The
EXPECTED RESULTS
The module executes (whether the Terraform apply works or not).
ACTUAL RESULTS
The text was updated successfully, but these errors were encountered: