Skip to content

Crash on terraform plan with protocol v6 nested attributes #29697

@ewbankkit

Description

@ewbankkit

Terraform Version

% terraform version
Terraform v1.0.8
on darwin_amd64

Terraform Configuration Files

resource "awscc_s3_bucket" "test" {
  cors_configuration = {
    cors_rules = [{
      allowed_headers = ["*"]
      allowed_methods = ["GET"]
      allowed_origins = ["*"]
      expose_headers  = ["*"]
    }]
  }
}

Debug Output

Crash Output

panic: not a list, map, or tuple type

goroutine 85 [running]:
github.com/zclconf/go-cty/cty.Value.HasIndex(0x37ba8d8, 0xc001581ac0, 0x2f87f00, 0xc002322360, 0x37ba7f8, 0xc000128369, 0x330cc60, 0xc002322480, 0xc002302360, 0xc0023223f0, ...)
	/Users/distiller/go/pkg/mod/github.com/zclconf/go-cty@v1.9.1/cty/value_ops.go:953 +0xc85
github.com/hashicorp/terraform/internal/plans/objchange.proposedNewNestedType(0xc000c48cc0, 0x37ba8d8, 0xc001581ac0, 0x2f87f00, 0xc002322360, 0x37ba868, 0xc001580500, 0x2e65d00, 0xc001796210, 0xc001796210, ...)
	/Users/distiller/project/project/internal/plans/objchange/objchange.go:333 +0x605
github.com/hashicorp/terraform/internal/plans/objchange.proposedNewAttributes(0xc001a8c1b0, 0x37ba8d8, 0xc001581ad0, 0x2f87f00, 0xc0023223c0, 0x37ba8d8, 0xc001580510, 0x2f87f00, 0xc0023023c0, 0x203000)
	/Users/distiller/project/project/internal/plans/objchange/objchange.go:295 +0x49a
github.com/hashicorp/terraform/internal/plans/objchange.proposedNewNestedType(0xc000c48ca0, 0x37ba8d8, 0xc001581a80, 0x0, 0x0, 0x37ba8d8, 0xc001580510, 0x2f87f00, 0xc0023023c0, 0xc0023023c0, ...)
	/Users/distiller/project/project/internal/plans/objchange/objchange.go:317 +0x8b4
github.com/hashicorp/terraform/internal/plans/objchange.proposedNewAttributes(0xc0019d9c50, 0x37ba8d8, 0xc001581aa0, 0x2f87f00, 0xc0023222d0, 0x37ba8d8, 0xc001580720, 0x2f87f00, 0xc002302420, 0x0)
	/Users/distiller/project/project/internal/plans/objchange/objchange.go:295 +0x49a
github.com/hashicorp/terraform/internal/plans/objchange.proposedNew(0xc0019d9cb0, 0x37ba8d8, 0xc001581aa0, 0x2f87f00, 0xc0023222d0, 0x37ba8d8, 0xc001580720, 0x2f87f00, 0xc002302420, 0x20, ...)
	/Users/distiller/project/project/internal/plans/objchange/objchange.go:80 +0x165
github.com/hashicorp/terraform/internal/plans/objchange.ProposedNew(0xc0019d9cb0, 0x37ba8d8, 0xc000f5cc30, 0x0, 0x0, 0x37ba8d8, 0xc001580720, 0x2f87f00, 0xc002302420, 0x0, ...)
	/Users/distiller/project/project/internal/plans/objchange/objchange.go:42 +0x11f
github.com/hashicorp/terraform/internal/terraform.(*NodeAbstractResourceInstance).plan(0xc0025a41c0, 0x37ec280, 0xc0003582a0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
	/Users/distiller/project/project/internal/terraform/node_resource_abstract_instance.go:732 +0xdab
github.com/hashicorp/terraform/internal/terraform.(*NodePlannableResourceInstance).managedResourceExecute(0xc00284ed20, 0x37ec280, 0xc0003582a0, 0x100c408, 0x32fcd00, 0xc002158c50)
	/Users/distiller/project/project/internal/terraform/node_resource_plan_instance.go:196 +0x8cb
github.com/hashicorp/terraform/internal/terraform.(*NodePlannableResourceInstance).Execute(0xc00284ed20, 0x37ec280, 0xc0003582a0, 0xe12c502, 0xc002158ce8, 0x100d305, 0x2fd3240)
	/Users/distiller/project/project/internal/terraform/node_resource_plan_instance.go:54 +0xb3
github.com/hashicorp/terraform/internal/terraform.(*ContextGraphWalker).Execute(0xc0024db2b0, 0x37ec280, 0xc0003582a0, 0xe12c508, 0xc00284ed20, 0x0, 0x0, 0x0)
	/Users/distiller/project/project/internal/terraform/graph_walk_context.go:129 +0xbf
github.com/hashicorp/terraform/internal/terraform.(*Graph).walk.func1(0x32fcd00, 0xc00284ed20, 0x0, 0x0, 0x0)
	/Users/distiller/project/project/internal/terraform/graph.go:59 +0xbd3
github.com/hashicorp/terraform/internal/dag.(*Walker).walkVertex(0xc0008785a0, 0x32fcd00, 0xc00284ed20, 0xc002850340)
	/Users/distiller/project/project/internal/dag/walk.go:381 +0x288
created by github.com/hashicorp/terraform/internal/dag.(*Walker).Update
	/Users/distiller/project/project/internal/dag/walk.go:304 +0x1246

Steps to Reproduce

  1. Create a new configuration as above
  2. terraform plan

Additional Context

The resource is using terraform-plugin-framework and hence protocol v6.
The resource schema definition is here: https://github.com/hashicorp/terraform-provider-awscc/blob/main/internal/aws/s3/bucket_resource_gen.go.

The relevant attribute (core_configuration) is declared as

"cors_configuration": {
	Attributes: tfsdk.SingleNestedAttributes(
		map[string]tfsdk.Attribute{
			"cors_rules": {
				Attributes: tfsdk.ListNestedAttributes(
					map[string]tfsdk.Attribute{
						"allowed_headers": {
							Description: "Headers that are specified in the Access-Control-Request-Headers header.",
							Type:        types.ListType{ElemType: types.StringType},
							Optional:    true,
						},
						"allowed_methods": {
							Description: "An HTTP method that you allow the origin to execute.",
							Type:        types.ListType{ElemType: types.StringType},
							Required:    true,
						},
						"allowed_origins": {
							Description: "One or more origins you want customers to be able to access the bucket from.",
							Type:        types.ListType{ElemType: types.StringType},
							Required:    true,
						},
						"exposed_headers": {
							Description: "One or more headers in the response that you want customers to be able to access from their applications (for example, from a JavaScript XMLHttpRequest object).",
							Type:        types.ListType{ElemType: types.StringType},
							Optional:    true,
						},
						"id": {
							Description: "A unique identifier for this rule.",
							Type:        types.StringType,
							Optional:    true,
						},
						"max_age": {
							Description: "The time in seconds that your browser is to cache the preflight response for the specified resource.",
							Type:        types.NumberType,
							Optional:    true,
						},
					},
					tfsdk.ListNestedAttributesOptions{},
				),
				Required: true,
			},
		},
	),
	Optional: true,
},

References

Relates hashicorp/terraform-provider-awscc#226.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions