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

ibm_atracker_settings fails to store state accurately #5043

Open
shemau opened this issue Jan 12, 2024 · 2 comments
Open

ibm_atracker_settings fails to store state accurately #5043

shemau opened this issue Jan 12, 2024 · 2 comments
Labels
service/Activity Tracker Issues related to Activity Tracker

Comments

@shemau
Copy link

shemau commented Jan 12, 2024

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform CLI and Terraform IBM Provider Version

terraform 1.5.7
ibm provider 1.51.0 through 1.61.0

Affected Resource(s)

  • ibm_atracker_settings

Terraform Configuration Files

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

# Copy-paste your Terraform configurations here - for large Terraform configs,
# please share a link to the ZIP file.

resource "ibm_atracker_settings" "atracker_settings" {
  count                     = length(var.global_event_routing_settings == null ? [] : [1])
  default_targets           = var.global_event_routing_settings.default_targets
  metadata_region_primary   = var.global_event_routing_settings.metadata_region_primary
  metadata_region_backup    = var.global_event_routing_settings.metadata_region_backup
  permitted_target_regions  = var.global_event_routing_settings.permitted_target_regions
  private_api_endpoint_only = var.global_event_routing_settings.private_api_endpoint_only

  lifecycle {
    create_before_destroy = true
  }
}

Debug Output

Following apply the subsequent plan/apply reports changes

 # module.test_observability_instance_creation.module.observability_instances[0].module.activity_tracker.ibm_atracker_settings.atracker_settings[0] will be updated in-place
   ~ resource "ibm_atracker_settings" "atracker_settings" {
       ~ default_targets           = [
           + "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",  # redacted
         ]
         id                        = "us-south"
        # (5 unchanged attributes hidden)
    }

Panic Output

Expected Behavior

The initial apply to have created the target and the target to be stored in the state file.

Actual Behavior

The default targets were not stored in the state file. This results in the subsequent plan/apply showing outstanding changes to be applied.

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Important Factoids

This may be an intermittent problem, possibly caused by a slowness on the backend. I have not managed to find any correlation between changes and the error. This is currently failing on our main branch which had previously passed.

References

  • #0000
@github-actions github-actions bot added the service/Activity Tracker Issues related to Activity Tracker label Jan 12, 2024
@shemau
Copy link
Author

shemau commented Jan 16, 2024

I have re-created this issue on Mac OSX.

Above I made the assumption that it was not stored in the state file, but that may be inaccurate.

terraform.tfstate includes:

    {
      "module": "module.test_observability_instance_creation.module.observability_instances[0].module.activity_tracker",
      "mode": "managed",
      "type": "ibm_atracker_settings",
      "name": "atracker_settings",
      "provider": "provider[\"registry.terraform.io/ibm-cloud/ibm\"]",
      "instances": [
        {
          "index_key": 0,
          "schema_version": 0,
          "attributes": {
            "api_version": 2,
            "default_targets": [
              "3d554ab7-b77b-45fd-95fc-206d61c0bfc2"
            ],
            "id": "us-south",
            "metadata_region_backup": "us-east",
            "metadata_region_primary": "us-south",
            "permitted_target_regions": [
              "us-south",
              "eu-de",
              "us-east",
              "eu-es",
              "eu-gb",
              "au-syd"
            ],
            "private_api_endpoint_only": false
          },
          "sensitive_attributes": [],
          "private": "REDACTED",
          "dependencies": [
            "ibm_resource_key.cos_resource_key",
            "ibm_resource_key.es_resource_key",
            "module.cos_bucket.ibm_cos_bucket.cos_bucket",
            "module.cos_bucket.ibm_cos_bucket.cos_bucket1",
            "module.cos_bucket.ibm_iam_authorization_policy.policy",
            "module.cos_bucket.ibm_resource_instance.cos_instance",
            "module.cos_bucket.random_string.bucket_name_suffix",
            "module.event_streams.ibm_event_streams_topic.es_topic",
            "module.event_streams.ibm_resource_instance.es_instance",
            "module.log_analysis.ibm_resource_instance.log_analysis",
            "module.log_analysis.ibm_resource_key.resource_key",
            "module.resource_group.data.ibm_resource_group.existing_resource_group",
            "module.resource_group.ibm_resource_group.resource_group",
            "module.test_observability_instance_creation.module.observability_instances.module.activity_tracker.ibm_atracker_target.atracker_cos_targets",
            "module.test_observability_instance_creation.module.observability_instances.module.activity_tracker.ibm_atracker_target.atracker_eventstreams_targets",
            "module.test_observability_instance_creation.module.observability_instances.module.activity_tracker.ibm_atracker_target.atracker_log_analysis_targets"
          ],
          "create_before_destroy": true
        }
      ]
    },

@shemau
Copy link
Author

shemau commented Jan 16, 2024

Whilst the terraform plan shows

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:

  # module.test_observability_instance_creation.module.observability_instances[0].module.activity_tracker.ibm_atracker_settings.atracker_settings[0] will be updated in-place
  ~ resource "ibm_atracker_settings" "atracker_settings" {
      ~ default_targets           = [
          + "3d554ab7-b77b-45fd-95fc-206d61c0bfc2",
        ]
        id                        = "us-south"
      + metadata_region_backup    = "us-east"
      ~ permitted_target_regions  = [
          + "us-south",
          + "eu-de",
          + "us-east",
          + "eu-es",
          + "eu-gb",
          + "au-syd",
        ]
        # (3 unchanged attributes hidden)
    }

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

Which the shows the same default target and the same list of permitted_target_regions in the same order.

The plan is incorrectly identifying that it is an update in place when there is no change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
service/Activity Tracker Issues related to Activity Tracker
Projects
None yet
Development

No branches or pull requests

1 participant