Skip to content
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

Unsupported Field Type for Resource #1204

Open
mohammadmuazam opened this issue Jun 5, 2023 · 0 comments
Open

Unsupported Field Type for Resource #1204

mohammadmuazam opened this issue Jun 5, 2023 · 0 comments
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework

Comments

@mohammadmuazam
Copy link

SDK version

$ cat go.mod | grep terraform-plugin-sdk
  github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.0
$ terraform version
  Terraform v1.4.2
  on darwin_arm64

  Your version of Terraform is out of date! The latest version
  is 1.4.6. You can update by downloading from https://www.terraform.io/downloads.html
$ terraform version -json
  {
    "terraform_version": "1.4.2",
    "platform": "darwin_arm64",
    "provider_selections": {},
    "terraform_outdated": true
  }

Description

Our API returns type of any for a specific field, which can be string, int, or bool. However, it seems that the current implementation of the provider SDK does not support this (as we need to specify one primitive type). We need to find a way to handle fields of type string, int, or bool interchangeably.

Expected Behavior:

The Terraform provider SDK should provide support for fields that can accept values of multiple types, such as string, int, or bool.

Steps to Reproduce:

Specify a resource with a field that can accept values of multiple types (string, int, bool) in the Terraform provider SDK.
Attempt to create or update the resource with values of different types for the field.
Observe that the provider SDK throws an error or fails to handle the field correctly.

Actual Behavior:

The Terraform provider SDK does not support fields of type any, causing errors or incorrect handling when attempting to create or update resources with fields that can accept values of multiple types.

Relevant Provider Source Code

"basic_expressions": {
	Description: "The basic expression which needs to be evaluated to be true for this rule to apply.",
	Type:        schema.TypeList,
	Optional:    true,
	MinItems:    1,
	Elem: &schema.Resource{
		Schema: map[string]*schema.Schema{
			....
			"rhs": {
				Description: "right hand side value",
				Type:        schema.TypeString,          # API can respond with string, int or bool
				Required:    true,
			},
		},
	},
},

Error while importing using Terraformer

2023/06/02 17:40:09 WARN: Fail read resource from provider, wait 300ms before retry
2023/06/02 17:40:09 json: cannot unmarshal number into Go struct field TaggingRuleCondition.data.rules.basic_expression.rhs of type string
2023/06/02 17:40:09 WARN: Fail read resource from provider, wait 300ms before retry
2023/06/02 17:40:10 json: cannot unmarshal number into Go struct field TaggingRuleCondition.data.rules.basic_expression.rhs of type string
2023/06/02 17:40:10 WARN: Fail read resource from provider, wait 300ms before retry
2023/06/02 17:40:10 json: cannot unmarshal number into Go struct field TaggingRuleCondition.data.rules.basic_expression.rhs of type string
2023/06/02 17:40:10 WARN: Fail read resource from provider, wait 300ms before retry
2023/06/02 17:40:10 json: cannot unmarshal number into Go struct field TaggingRuleCondition.data.rules.basic_expression.rhs of type string
2023/06/02 17:40:10 WARN: Fail read resource from provider, wait 300ms before retry
@mohammadmuazam mohammadmuazam added the enhancement New feature or request label Jun 5, 2023
@mohammadmuazam mohammadmuazam changed the title Terraform Provider SDK - Unsupported Field Type for Resource Unsupported Field Type for Resource Jun 5, 2023
@bflad bflad added the terraform-plugin-framework Resolved in terraform-plugin-framework label Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request terraform-plugin-framework Resolved in terraform-plugin-framework
Projects
None yet
Development

No branches or pull requests

2 participants