hashicorp / terraform-provider-awscc

Terraform AWS Cloud Control provider
https://registry.terraform.io/providers/hashicorp/awscc/latest/docs
Mozilla Public License 2.0
261 stars 120 forks source link

awscc_glue_schema fails on apply on adding tags #1566

Open quixoticmonk opened 7 months ago

quixoticmonk commented 7 months ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

terraform --version
Terraform v1.7.4

terraform {
  required_providers {
    awscc = {
      source  = "hashicorp/awscc"
      version = "0.74.0"
    }
  }
}

Affected Resource(s)

Terraform Configuration Files

Please include all Terraform configurations required to reproduce the bug. Bug reports without a functional reproduction may be closed without investigation.

resource "awscc_glue_schema" "example" {
  name       = "example"
  registry      = {
    arn=awscc_glue_registry.example.arn
  }
  data_format       = "AVRO"
  compatibility     = "NONE"
  schema_definition = "{\"type\": \"record\", \"name\": \"r1\", \"fields\": [ {\"name\": \"f1\", \"type\": \"int\"}, {\"name\": \"f2\", \"type\": \"string\"} ]}"

}

resource "awscc_glue_registry" "example" {
  name        = "example-registry"
  description = "Glue registry example"

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
}

Updated configuation

resource "awscc_glue_schema" "example" {
  name       = "example"
  registry      = {
    arn=awscc_glue_registry.example.arn
  }
  data_format       = "AVRO"
  compatibility     = "NONE"
  schema_definition = "{\"type\": \"record\", \"name\": \"r1\", \"fields\": [ {\"name\": \"f1\", \"type\": \"int\"}, {\"name\": \"f2\", \"type\": \"string\"} ]}"
  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]

}

resource "awscc_glue_registry" "example" {
  name        = "example-registry"
  description = "Glue registry example"

  tags = [{
    key   = "Modified By"
    value = "AWSCC"
  }]
}

Debug Output

Panic Output

Expected Behavior

Actual Behavior

The plan/apply identifies this as an in-place update, but fails stating schemadefinition is not found ( which is not changed).

Terraform used the selected providers to generate the following execution plan. Resource actions are
indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # awscc_glue_schema.example will be updated in-place
  ~ resource "awscc_glue_schema" "example" {
      + description               = (known after apply)
        id                        = "arn:aws:glue:us-east-1:#######:schema/example-registry/example"
        name                      = "example"
      + tags                      = [
          + {
              + key   = "Modified By"
              + value = "AWSCC"
            },
        ]
        # (7 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
awscc_glue_schema.example: Modifying... [id=arn:aws:glue:us-east-1:#######:schema/example-registry/example]
β•·
β”‚ Error: AWS SDK Go Service Operation Unsuccessful
β”‚
β”‚   with awscc_glue_schema.example,
β”‚   on main.tf line 1, in resource "awscc_glue_schema" "example":
β”‚    1: resource "awscc_glue_schema" "example" {
β”‚
β”‚ Calling Cloud Control API service UpdateResource operation returned: operation error CloudControl:
β”‚ UpdateResource, https response error StatusCode: 400, RequestID: 60edebed-5ea8-46a9-9205-82eae9eeedb1, api
β”‚ error ValidationException: Model validation failed (#: required key [SchemaDefinition] not found)

Steps to Reproduce

  1. terraform apply with the first configuration.
  2. Add tags to the schema and apply again.

Important Factoids

References

quixoticmonk commented 4 months ago
2024-06-30T23:30:35.159-0400 [DEBUG] provider.terraform-provider-awscc_v1.4.0_x5: 
Detected value change between proposed new state and prior state: @module=sdk.framework tf_resource_type=awscc_glue_schema tf_provider_addr=registry.terraform.io/hashicorp/awscc 
tf_req_id=a3305589-d9c0-987f-8e25-d95ece26527e tf_rpc=PlanResourceChange 
@caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_planresourcechange.go:208 
tf_attribute_path=tags timestamp=2024-06-30T23:30:35.159-0400

2024-06-30T23:30:34.023-0400 [DEBUG] provider.terraform-provider-awscc_v1.4.0_x5: 
Detected value change between proposed new state and prior state: tf_attribute_path=tags tf_provider_addr=registry.terraform.io/hashicorp/awscc 
tf_resource_type=awscc_glue_schema tf_rpc=PlanResourceChange 
@caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_planresourcechange.go:208 
@module=sdk.framework tf_req_id=d53bba71-800a-29a5-3b5c-c09add360687 timestamp=2024-06-30T23:30:34.023-0400
2024-06-30T23:30:35.166-0400 [DEBUG] provider.terraform-provider-awscc_v1.4.0_x5: 
Cloud Control API PatchDocument: 
value="[{\"op\":\"add\",\"path\":\"/SchemaDefinition\",\"value\":\"{\\"type\\": \\"record\\", \\"name\\": \\"r1\\", \\"fields\\": [ {\\"name\\": \\"f1\\", \\"type\\": \\"int\\"}, {\\"name\\": \\"f2\\", \\"type\\": \\"string\\"} ]}\"},{\"op\":\"add\",\"path\":\"/Tags\",\"value\":[{\"Key\":\"Modified By\",\"Value\":\"AWSCC\"}]}]" 
cfn_type=AWS::Glue::Schema tf_req_id=1ff50dd5-cef2-233d-19a0-5976e618bcdf tf_rpc=ApplyResourceChange tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_resource_type=awscc_glue_schema
 @caller=github.com/hashicorp/terraform-provider-awscc/internal/generic/resource.go:583 @module=awscc timestamp=2024-06-30T23:30:35.166-0400
{
    "arn": "arn:aws:glue:us-east-1:############:schema/example-registry/example",
    "checkpoint_version": {
      "is_latest": true,
      "version_number": 1
    },
    "compatibility": "NONE",
    "data_format": "AVRO",
    "description": null,
    "id": "arn:aws:glue:us-east-1:############:schema/example-registry/example",
    "initial_schema_version_id": "a28bbf6f-85ce-408b-b940-2d62ce7f052a",
    "name": "example",
    "registry": {
      "arn": "arn:aws:glue:us-east-1:############:registry/example-registry",
      "name": "example-registry"
    },
    "schema_definition": "{\"type\": \"record\", \"name\": \"r1\", \"fields\": [ {\"name\": \"f1\", \"type\": \"int\"}, {\"name\": \"f2\", \"type\": \"string\"} ]}",
    "tags": null
  }
{
    "arn": "arn:aws:glue:us-east-1:############:schema/example-registry/example",
    "checkpoint_version": {
      "is_latest": true,
      "version_number": 1
    },
    "compatibility": "NONE",
    "data_format": "AVRO",
    "description": null,
    "id": "arn:aws:glue:us-east-1:############:schema/example-registry/example",
    "initial_schema_version_id": "a28bbf6f-85ce-408b-b940-2d62ce7f052a",
    "name": "example",
    "registry": {
      "arn": "arn:aws:glue:us-east-1:############:registry/example-registry",
      "name": "example-registry"
    },
    "schema_definition": "{\"type\": \"record\", \"name\": \"r1\", \"fields\": [ {\"name\": \"f1\", \"type\": \"int\"}, {\"name\": \"f2\", \"type\": \"string\"} ]}",
    "tags": [
      {
        "key": "Modified By",
        "value": "AWSCC"
      }
    ]
  }