hashicorp / terraform-provider-awscc

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

awscc_lightsail_instance: Perpetual changes on apply without config change, update does not complete #1819

Open acwwat opened 3 weeks ago

acwwat commented 3 weeks ago

Community Note

Terraform CLI and Terraform AWS Cloud Control Provider Version

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_lightsail_instance" "example" {
  blueprint_id  = "amazon_linux_2023"
  bundle_id     = "nano_3_0"
  instance_name = "example-instance"
}

Debug Output

...
2024-06-15T22:25:44.830-0400 [TRACE] checkPlannedChange: Verifying that actual change (action Update) matches planned change (action Update)
2024-06-15T22:25:44.830-0400 [TRACE] GRPCProvider.v6: GetProviderSchema
2024-06-15T22:25:44.830-0400 [TRACE] GRPCProvider.v6: returning cached schema: EXTRA_VALUE_AT_END=registry.terraform.io/hashicorp/awscc
2024-06-15T22:25:44.830-0400 [INFO]  Starting apply for awscc_lightsail_instance.example
2024-06-15T22:25:44.830-0400 [DEBUG] skipping FixUpBlockAttrs
2024-06-15T22:25:44.830-0400 [TRACE] GRPCProvider.v6: GetProviderSchema
2024-06-15T22:25:44.830-0400 [TRACE] GRPCProvider.v6: returning cached schema: EXTRA_VALUE_AT_END=registry.terraform.io/hashicorp/awscc
2024-06-15T22:25:44.830-0400 [DEBUG] awscc_lightsail_instance.example: applying the planned Update change
2024-06-15T22:25:44.831-0400 [TRACE] GRPCProvider.v6: ApplyResourceChange
2024-06-15T22:25:44.831-0400 [TRACE] GRPCProvider.v6: GetProviderSchema
2024-06-15T22:25:44.831-0400 [TRACE] GRPCProvider.v6: returning cached schema: EXTRA_VALUE_AT_END=registry.terraform.io/hashicorp/awscc
2024-06-15T22:25:44.831-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Received request: tf_proto_version=6.6 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_resource_type=awscc_lightsail_instance @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:852 @module=sdk.proto tf_rpc=ApplyResourceChange tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 timestamp=2024-06-15T22:25:44.831-0400
2024-06-15T22:25:44.831-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Sending request downstream: @module=sdk.proto tf_proto_version=6.6 tf_resource_type=awscc_lightsail_instance @caller=github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tf6serverlogging/downstream_request.go:22 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_rpc=ApplyResourceChange timestamp=2024-06-15T22:25:44.831-0400
2024-06-15T22:25:44.831-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Checking ResourceTypes lock: tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server.go:510 tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_resource_type=awscc_lightsail_instance @module=sdk.framework tf_provider_addr=registry.terraform.io/hashicorp/awscc timestamp=2024-06-15T22:25:44.831-0400
2024-06-15T22:25:44.834-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: ApplyResourceChange running UpdateResource: tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_applyresourcechange.go:89 @module=sdk.framework tf_resource_type=awscc_lightsail_instance timestamp=2024-06-15T22:25:44.833-0400
2024-06-15T22:25:44.834-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Resource implements ResourceWithConfigure: @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_updateresource.go:48 @module=sdk.framework tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_resource_type=awscc_lightsail_instance tf_rpc=ApplyResourceChange timestamp=2024-06-15T22:25:44.834-0400
2024-06-15T22:25:44.834-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Calling provider defined Resource Configure: @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_updateresource.go:55 @module=sdk.framework tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_resource_type=awscc_lightsail_instance tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_rpc=ApplyResourceChange timestamp=2024-06-15T22:25:44.834-0400
2024-06-15T22:25:44.834-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Called provider defined Resource Configure: tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_resource_type=awscc_lightsail_instance tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_updateresource.go:57 @module=sdk.framework timestamp=2024-06-15T22:25:44.834-0400
2024-06-15T22:25:44.834-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Calling provider defined Resource Update: @module=sdk.framework tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_resource_type=awscc_lightsail_instance tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_updateresource.go:121 timestamp=2024-06-15T22:25:44.834-0400
2024-06-15T22:25:44.834-0400 [TRACE] provider.terraform-provider-awscc_v1.2.0_x5.exe: Resource.Update entry: tf_resource_type=awscc_lightsail_instance @caller=github.com/hashicorp/terraform-provider-awscc/internal/generic/logging.go:18 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 @module=awscc cfn_type=AWS::Lightsail::Instance tf_rpc=ApplyResourceChange timestamp=2024-06-15T22:25:44.834-0400
2024-06-15T22:25:44.835-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: Cloud Control API PatchDocument: tf_provider_addr=registry.terraform.io/hashicorp/awscc cfn_type=AWS::Lightsail::Instance tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_resource_type=awscc_lightsail_instance tf_rpc=ApplyResourceChange @caller=github.com/hashicorp/terraform-provider-awscc/internal/generic/resource.go:583 @module=awscc value=[] timestamp=2024-06-15T22:25:44.835-0400
2024-06-15T22:25:44.835-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: HTTP Request Sent: http.request_content_length=145 tf_aws.signing_region="" http.request.header.x_amz_security_token="*****" net.peer.name=cloudcontrolapi.us-east-1.amazonaws.com rpc.service=CloudControl tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_resource_type=awscc_lightsail_instance @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.53/logging/tf_logger.go:45 http.request.header.amz_sdk_request="attempt=1; max=25" http.request.header.x_amz_date=20240616T022544Z http.request.header.x_amz_target=CloudApiService.UpdateResource
  http.request.body=
  | {"ClientToken":"terraform-20240616022544835100000001","Identifier":"example-instance","PatchDocument":"[]","TypeName":"AWS::Lightsail::Instance"}
   http.request.header.authorization="AWS4-HMAC-SHA256 Credential=ASIA************436L/20240616/us-east-1/cloudcontrolapi/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-date;x-amz-security-token;x-amz-target, Signature=*****" http.user_agent="APN/1.0 HashiCorp/1.0 Terraform/1.6.6 (+https://www.terraform.io) terraform-provider-awscc/dev (+https://registry.terraform.io/providers/hashicorp/awscc) aws-sdk-go-v2/1.27.2 os/windows lang/go#1.22.2 md/GOOS#windows md/GOARCH#amd64 api/cloudcontrol#1.18.10" @module=awscc http.request.header.content_type=application/x-amz-json-1.0 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_rpc=ApplyResourceChange cfn_type=AWS::Lightsail::Instance http.method=POST http.request.header.amz_sdk_invocation_id=02616cbc-ec03-4a7b-82ec-7bc501183d82 http.url=https://cloudcontrolapi.us-east-1.amazonaws.com/ aws.region=us-east-1 rpc.method=UpdateResource rpc.system=aws-api tf_aws.sdk=aws-sdk-go-v2 timestamp=2024-06-15T22:25:44.835-0400
2024-06-15T22:25:45.983-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: HTTP Response Received: http.duration=1146 http.response.header.connection=keep-alive http.status_code=200 rpc.system=aws-api tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_resource_type=awscc_lightsail_instance cfn_type=AWS::Lightsail::Instance rpc.service=CloudControl tf_aws.sdk=aws-sdk-go-v2 @module=awscc http.response.header.content_type=application/x-amz-json-1.0 http.response_content_length=1646 rpc.method=UpdateResource tf_aws.signing_region="" tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 tf_rpc=ApplyResourceChange http.response.header.x_amzn_requestid=a8707a2a-ea9c-4715-8c91-bf18a7025018 aws.region=us-east-1
  http.response.body=
  | {"ProgressEvent":{"EventTime":1.718504746685E9,"Identifier":"example-instance","Operation":"UPDATE","OperationStatus":"SUCCESS","RequestToken":"110a3be6-5c4e-4dcd-8cfa-0625e6a1d5ec","ResourceModel":"{\"SshKeyName\":\"LightsailDefaultKeyPair\",\"KeyPairName\":\"LightsailDefaultKeyPair\",\"IsStaticIp\":false,\"PrivateIpAddress\":\"172.26.1.55\",\"UserName\":\"ec2-user\",\"BlueprintId\":\"amazon_linux_2023\",\"Networking\":{\"Ports\":[{\"FromPort\":22,\"AccessDirection\":\"inbound\",\"CidrListAliases\":[],\"ToPort\":22,\"Ipv6Cidrs\":[\"::/0\"],\"AccessFrom\":\"Anywhere (0.0.0.0/0 and ::/0)\",\"Protocol\":\"tcp\",\"AccessType\":\"public\",\"Cidrs\":[\"0.0.0.0/0\"],\"CommonName\":\"\"},{\"FromPort\":80,\"AccessDirection\":\"inbound\",\"CidrListAliases\":[],\"ToPort\":80,\"Ipv6Cidrs\":[\"::/0\"],\"AccessFrom\":\"Anywhere (0.0.0.0/0 and ::/0)\",\"Protocol\":\"tcp\",\"AccessType\":\"public\",\"Cidrs\":[\"0.0.0.0/0\"],\"CommonName\":\"\"}],\"MonthlyTransfer\":{\"GbPerMonthAllocated\":\"1024\"}},\"AvailabilityZone\":\"us-east-1a\",\"AddOns\":[],\"ResourceType\":\"Instance\",\"Ipv6Addresses\":[\"2600:1f10:4549:a400:c81d:42ad:2533:aa8d\"],\"PublicIpAddress\":\"34.230.70.217\",\"InstanceName\":\"example-instance\",\"BundleId\":\"nano_3_0\",\"SupportCode\":\"017357350931/i-0d476c55c41e3d90f\",\"State\":{\"Code\":16,\"Name\":\"running\"},\"InstanceArn\":\"arn:aws:lightsail:us-east-1:100180206982:Instance/873c52e9-bf94-4015-b6ce-ad8d27f7db2f\",\"Hardware\":{\"CpuCount\":2,\"RamSizeInGb\":1,\"Disks\":[]},\"Tags\":[],\"Location\":{\"RegionName\":\"us-east-1\",\"AvailabilityZone\":\"us-east-1a\"}}","TypeName":"AWS::Lightsail::Instance"}}
   http.response.header.date="Sun, 16 Jun 2024 02:25:46 GMT" @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.53/logging/tf_logger.go:45 timestamp=2024-06-15T22:25:45.983-0400
2024-06-15T22:25:45.983-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: HTTP Request Sent: @module=awscc http.user_agent="APN/1.0 HashiCorp/1.0 Terraform/1.6.6 (+https://www.terraform.io) terraform-provider-awscc/dev (+https://registry.terraform.io/providers/hashicorp/awscc) aws-sdk-go-v2/1.27.2 os/windows lang/go#1.22.2 md/GOOS#windows md/GOARCH#amd64 api/cloudcontrol#1.18.10" tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 http.request.header.amz_sdk_request="attempt=1; max=25" http.request.header.authorization="AWS4-HMAC-SHA256 Credential=ASIA************436L/20240616/us-east-1/cloudcontrolapi/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-date;x-amz-security-token;x-amz-target, Signature=*****" rpc.system=aws-api
  http.request.body=
  | {"RequestToken":"110a3be6-5c4e-4dcd-8cfa-0625e6a1d5ec"}
   http.request.header.x_amz_date=20240616T022545Z http.request.header.content_type=application/x-amz-json-1.0 http.request.header.x_amz_target=CloudApiService.GetResourceRequestStatus rpc.method=GetResourceRequestStatus rpc.service=CloudControl tf_resource_type=awscc_lightsail_instance http.request.header.amz_sdk_invocation_id=bb37cf6a-ab52-432e-a293-1ef431a92133 http.request.header.x_amz_security_token="*****" http.request_content_length=55 tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_rpc=ApplyResourceChange aws.region=us-east-1 cfn_type=AWS::Lightsail::Instance http.method=POST tf_aws.sdk=aws-sdk-go-v2 http.url=https://cloudcontrolapi.us-east-1.amazonaws.com/ net.peer.name=cloudcontrolapi.us-east-1.amazonaws.com tf_aws.signing_region="" @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.53/logging/tf_logger.go:45 timestamp=2024-06-15T22:25:45.983-0400
2024-06-15T22:25:46.264-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: HTTP Response Received: aws.region=us-east-1 http.response.header.content_type=application/x-amz-json-1.0 http.response.header.date="Sun, 16 Jun 2024 02:25:46 GMT" http.status_code=200 tf_resource_type=awscc_lightsail_instance @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.53/logging/tf_logger.go:45 cfn_type=AWS::Lightsail::Instance http.response.header.x_amzn_requestid=8153cb59-126c-4667-af15-0234dff8dcfd tf_aws.sdk=aws-sdk-go-v2 tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217
  http.response.body=
  | {"ProgressEvent":{"EventTime":1.718504745828E9,"OperationStatus":"PENDING","RequestToken":"110a3be6-5c4e-4dcd-8cfa-0625e6a1d5ec","TypeName":"AWS::Lightsail::Instance"}}
   http.response.header.connection=keep-alive tf_aws.signing_region="" tf_rpc=ApplyResourceChange rpc.system=aws-api tf_provider_addr=registry.terraform.io/hashicorp/awscc @module=awscc http.duration=281 http.response_content_length=168 rpc.method=GetResourceRequestStatus rpc.service=CloudControl timestamp=2024-06-15T22:25:46.264-0400
2024-06-15T22:25:48.856-0400 [TRACE] dag/walk: vertex "root" is waiting for "provider[\"registry.terraform.io/hashicorp/awscc\"] (close)"
2024-06-15T22:25:48.856-0400 [TRACE] dag/walk: vertex "provider[\"registry.terraform.io/hashicorp/awscc\"] (close)" is waiting for "awscc_lightsail_instance.example"
2024-06-15T22:25:51.268-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: HTTP Request Sent: tf_provider_addr=registry.terraform.io/hashicorp/awscc @module=awscc aws.region=us-east-1
  http.request.body=
  | {"RequestToken":"110a3be6-5c4e-4dcd-8cfa-0625e6a1d5ec"}
   http.request.header.x_amz_date=20240616T022551Z http.request.header.x_amz_target=CloudApiService.GetResourceRequestStatus http.request.header.authorization="AWS4-HMAC-SHA256 Credential=ASIA************436L/20240616/us-east-1/cloudcontrolapi/aws4_request, SignedHeaders=amz-sdk-invocation-id;amz-sdk-request;content-length;content-type;host;x-amz-date;x-amz-security-token;x-amz-target, Signature=*****" rpc.service=CloudControl tf_aws.signing_region="" http.method=POST http.request.header.content_type=application/x-amz-json-1.0 rpc.system=aws-api tf_resource_type=awscc_lightsail_instance @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.53/logging/tf_logger.go:45 http.request.header.amz_sdk_request="attempt=1; max=25" tf_aws.sdk=aws-sdk-go-v2 http.request.header.amz_sdk_invocation_id=50d03a5b-8471-4f8f-995f-2988913b3de9 http.request_content_length=55 http.user_agent="APN/1.0 HashiCorp/1.0 Terraform/1.6.6 (+https://www.terraform.io) terraform-provider-awscc/dev (+https://registry.terraform.io/providers/hashicorp/awscc) aws-sdk-go-v2/1.27.2 os/windows lang/go#1.22.2 md/GOOS#windows md/GOARCH#amd64 api/cloudcontrol#1.18.10" tf_rpc=ApplyResourceChange cfn_type=AWS::Lightsail::Instance http.request.header.x_amz_security_token="*****" http.url=https://cloudcontrolapi.us-east-1.amazonaws.com/ net.peer.name=cloudcontrolapi.us-east-1.amazonaws.com tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 rpc.method=GetResourceRequestStatus timestamp=2024-06-15T22:25:51.268-0400
2024-06-15T22:25:51.311-0400 [DEBUG] provider.terraform-provider-awscc_v1.2.0_x5.exe: HTTP Response Received: @module=awscc aws.region=us-east-1 tf_resource_type=awscc_lightsail_instance http.duration=42 http.response.header.content_type=application/x-amz-json-1.0 http.response.header.date="Sun, 16 Jun 2024 02:25:52 GMT" rpc.system=aws-api http.response_content_length=168 http.status_code=200 @caller=github.com/hashicorp/aws-sdk-go-base/v2@v2.0.0-beta.53/logging/tf_logger.go:45 cfn_type=AWS::Lightsail::Instance
  http.response.body=
  | {"ProgressEvent":{"EventTime":1.718504745828E9,"OperationStatus":"PENDING","RequestToken":"110a3be6-5c4e-4dcd-8cfa-0625e6a1d5ec","TypeName":"AWS::Lightsail::Instance"}}
   http.response.header.connection=keep-alive rpc.method=GetResourceRequestStatus tf_aws.sdk=aws-sdk-go-v2 tf_aws.signing_region="" tf_rpc=ApplyResourceChange http.response.header.x_amzn_requestid=1b4aede9-2bd8-4123-a4ec-03b19352e970 rpc.service=CloudControl tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=795af725-bd04-5bb6-ebb9-7953092de217 timestamp=2024-06-15T22:25:51.311-0400
...

Panic Output

n/a

Expected Behavior

There should not be any changes to the aws_lightsail_instance resource identified when running terraform apply after the first terraform apply is run to create the resource.

Actual Behavior

terraform apply identifies changes to the add_ons, tags, and user_data arguments, and if I proceed, the resource update does not stop until I kill the process. I would assume that it would also reach a timeout eventually, but I couldn't wait long enough to see it.

PS C:\working\tf-test> terraform apply
╷
│ Warning: Provider development overrides are in effect
│
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp/aws in C:\Users\Anthony\go\bin
│
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with published     
│ releases.
╵
awscc_lightsail_instance.example: Refreshing state... [id=example-instance]

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_lightsail_instance.example will be updated in-place
  ~ resource "awscc_lightsail_instance" "example" {
      + add_ons            = (known after apply)
        id                 = "example-instance"
      + tags               = (known after apply)
      + user_data          = (known after apply)
        # (18 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

awscc_lightsail_instance.example: Modifying... [id=example-instance]
awscc_lightsail_instance.example: Still modifying... [id=example-instance, 10s elapsed]
awscc_lightsail_instance.example: Still modifying... [id=example-instance, 20s elapsed]
awscc_lightsail_instance.example: Still modifying... [id=example-instance, 30s elapsed]
...

Steps to Reproduce

  1. terraform apply
  2. terraform apply again, without any changes to the Terraform configuration

Important Factoids

n/a

References

n/a

quixoticmonk commented 3 weeks ago

Thank you for opening the issue @acwwat . I can reproduce it with the instance example you have provided.

On the subsequent apply:

awscc_lightsail_instance.example: Refreshing state... [id=example-instance]

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_lightsail_instance.example will be updated in-place
  ~ resource "awscc_lightsail_instance" "example" {
      + add_ons            = (known after apply)
        id                 = "example-instance"
      + tags               = (known after apply)
      + user_data          = (known after apply)
        # (18 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.

The statefile on the initial apply is missing values for the above fields and are marked as null.

{
  "version": 4,
  "terraform_version": "1.8.4",
  "resources": [
    {
      "mode": "managed",
      "type": "awscc_lightsail_instance",
      "name": "example",
      "provider": "provider[\"registry.terraform.io/hashicorp/awscc\"]",
      "instances": [
        {
          "schema_version": 1,
          "attributes": {
            "add_ons": null,
            .......
            "tags": null,
            "user_data": null,
            "user_name": "ec2-user"
          },
          "sensitive_attributes": []
        }
      ]
    }
  ],
  "check_results": null
}
wellsiau-aws commented 1 week ago

On my test, the debug logs detected change in the attribute networking:

2024-06-28T14:39:28.923-0700 [DEBUG] provider.terraform-provider-awscc_v1.4.0_x5: Detected value change between proposed new state and prior state: tf_provider_addr=registry.terraform.io/hashicorp/awscc tf_req_id=9a35c22d-cf48-56e3-4712-e7e2332da199 tf_attribute_path=networking @module=sdk.framework tf_resource_type=awscc_lightsail_instance tf_rpc=PlanResourceChange @caller=github.com/hashicorp/terraform-plugin-framework@v1.9.0/internal/fwserver/server_planresourcechange.go:208 timestamp=2024-06-28T14:39:28.923-0700
wellsiau-aws commented 1 week ago

upon further investigation, this is related to #1216.

Here is the debug log snapshot (some details omitted for brevity)

PlanResourceChange_Request_PriorState

{
  "blueprint_id": "amazon_linux_2023",
  "bundle_id": "nano_3_0",
  "id": "example-instance",
  "instance_arn": "arn:aws:lightsail:us-east-1:204034886740:Instance/d7536891-2ba5-4429-9b6b-826413ae98f2",
  "instance_name": "example-instance",
  . . .
  "networking": {
    "monthly_transfer": {
      "gb_per_month_allocated": "1024"
    },
 . . .
}

PlanResourceChange_Request_ProposedNewState notice how the networking attribute was set to null by Terraform.

{
  "blueprint_id": "amazon_linux_2023",
  "bundle_id": "nano_3_0",
  "id": "example-instance",
  "instance_arn": "arn:aws:lightsail:us-east-1:204034886740:Instance/d7536891-2ba5-4429-9b6b-826413ae98f2",
  "instance_name": "example-instance",
  . . .
  "networking": null,
 . . .
}

PlanResourceChange_Response_PlannedState further down, plan modifiers recover the value from the statefile, but at this point, Terraform already "thinks" that there is change / drift.

{
  "blueprint_id": "amazon_linux_2023",
  "bundle_id": "nano_3_0",
  "id": "example-instance",
  "instance_arn": "arn:aws:lightsail:us-east-1:204034886740:Instance/d7536891-2ba5-4429-9b6b-826413ae98f2",
  "instance_name": "example-instance",
  . . .
  "networking": {
    "monthly_transfer": {
      "gb_per_month_allocated": "1024"
    },
 . . .
}
wellsiau-aws commented 1 week ago

Local test by removing required flag on the attribute networking confirms that the drift is no longer occurring, however this is not the right approach to fix the problem.

diff --git a/internal/aws/lightsail/instance_resource_gen.go b/internal/aws/lightsail/instance_resource_gen.go
index d867daebe..b7961cd8d 100644
--- a/internal/aws/lightsail/instance_resource_gen.go
+++ b/internal/aws/lightsail/instance_resource_gen.go
@@ -708,7 +708,9 @@ func instanceResource(ctx context.Context) (resource.Resource, error) {
                                                }, /*END SCHEMA*/
                                        }, /*END NESTED OBJECT*/
                                        Description: "Ports to the Instance.",
-                                       Required:    true,
+                                       // Required:    true,
+                                       Optional: true,
+                                       Computed: true,
                                }, /*END ATTRIBUTE*/
                        }, /*END SCHEMA*/
                        Description: "Networking of the Instance.",

Plan output:

╷
│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp/awscc in /usr/local/go/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause
│ the state to become incompatible with published releases.
╵
awscc_lightsail_instance.example: Refreshing state... [id=example-instance]

No changes. Your infrastructure matches the configuration.
wellsiau-aws commented 1 week ago

@acwwat , thank you for reporting this issue. We are still finalizing the appropriate fix to this problem, which may require upstream dependencies as well.