splunk / terraform-provider-splunk

Terraform Provider for Splunk
Mozilla Public License 2.0
103 stars 76 forks source link

Views 404 when name has 2+ _ #51

Open jordanfelle opened 3 years ago

jordanfelle commented 3 years ago

When a view has 2 or more _ in it's name terraform will give a 404. This is impacted more when dealing with imported items. Example below is when I ran apply with tf_test and then renamed it to tf__test

terraform$ terraform apply
module.dashboards.splunk_data_ui_views.tf_test: Refreshing state... [id=tf_test]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # module.dashboards.splunk_data_ui_views.tf_test will be updated in-place
  ~ resource "splunk_data_ui_views" "tf_test" {
      ~ eai_data = <<~EOT
            <dashboard>
              <label>tf_test</label>
            </dashboard>
        EOT
        id       = "tf_test"
        name     = "tf_test"

        acl {
            app              = "search"
            can_change_perms = true
            can_share_app    = true
            can_share_global = true
            can_share_user   = true
            can_write        = true
            owner            = "jfelle"
            read             = []
            removable        = true
            sharing          = "user"
            write            = []
        }
    }

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

module.dashboards.splunk_data_ui_views.tf_test: Modifying... [id=tf_test]
module.dashboards.splunk_data_ui_views.tf_test: Modifications complete after 1s [id=tf_test]

Apply complete! Resources: 0 added, 1 changed, 0 destroyed.

Outputs:

tags = {
  "managed" = "terraform-splunk"
  "origin" = "terraform"
}
terraform$ terraform apply
module.dashboards.splunk_data_ui_views.tf_test: Refreshing state... [id=tf_test]

An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
-/+ destroy and then create replacement

Terraform will perform the following actions:

  # module.dashboards.splunk_data_ui_views.tf_test must be replaced
-/+ resource "splunk_data_ui_views" "tf_test" {
        eai_data = <<~EOT
            <dashboard>
              <label>tf_test</label>
            </dashboard>
        EOT
      ~ id       = "tf_test" -> (known after apply)
      ~ name     = "tf_test" -> "tf__test" # forces replacement

        acl {
            app              = "search"
            can_change_perms = true
            can_share_app    = true
            can_share_global = true
            can_share_user   = true
            can_write        = true
            owner            = "jfelle"
            read             = []
            removable        = true
            sharing          = "user"
            write            = []
        }
    }

Plan: 1 to add, 0 to change, 1 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

module.dashboards.splunk_data_ui_views.tf_test: Destroying... [id=tf_test]
module.dashboards.splunk_data_ui_views.tf_test: Destruction complete after 0s
module.dashboards.splunk_data_ui_views.tf_test: Creating...

Error: Http Error: [404] 404 Not Found {"messages":[{"type":"ERROR","text":"Cannot find entity with name=\"tf__test\""}]}

  on dashboards/observability.tf line 1, in resource "splunk_data_ui_views" "tf_test":
   1: resource "splunk_data_ui_views" "tf_test" {

terraform$

TF

resource "splunk_data_ui_views" "tf_test" {
    eai_data = <<-EOT
        <dashboard>
          <label>tf_test</label>
        </dashboard>
    EOT
    name     = "tf_test"

    acl {
        app              = "search"
        can_change_perms = true
        can_share_app    = true
        can_share_global = true
        can_share_user   = true
        can_write        = true
        owner            = "jfelle"
        read             = []
        removable        = true
        sharing          = "user"
        write            = []
    }
}
anushjay commented 3 years ago

Thanks, @jordanfelle. We take a look at it.

jordanfelle commented 3 years ago

Just some extra feedback, it looks to not just be around 2 _ and a lot of other dames also having issues with any edits and getting the 404. Let me know if there is any extra debug information I can grab.

anushjay commented 3 years ago

Hi @jordanfelle I had a few minutes to look at this and I don't see an issue with the string having underscores. Can you check if the namespace of the resource is different between the creation and the update? I may have seen this issue when the owner or app or sharing values are not matching to an existing resource.

jordanfelle commented 3 years ago

Yea it looks to be almost anything I tried to edit. I am copying exactly what an import sets, and it also happened with assets I created purely in TF and it still happens. I am able to create items, but anytime I tried to update I get this issue.