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

permadiff when creating an event rule with no advanced conditions #155

Closed
yob opened this issue Sep 26, 2019 · 4 comments
Closed

permadiff when creating an event rule with no advanced conditions #155

yob opened this issue Sep 26, 2019 · 4 comments

Comments

@yob
Copy link

yob commented Sep 26, 2019

Terraform Version

Terraform v0.12.6

Affected Resource(s)

  • pagerduty_event_rule

Terraform Configuration Files

resource "pagerduty_event_rule" "info-for-service" {
  action_json = jsonencode([
    [
      "route",
      "12345"
    ],
    [
      "severity",
      "info",
    ]
  ])
  condition_json = jsonencode([
    "and",
    ["equals", ["path", "vendor"], "datadog"],
    ["contains", ["path", "payload", "custom_details", "title"], "sev:info"],
    ["contains", ["path", "payload", "custom_details", "title"], "service:12345"]
  ])
  //advanced_condition_json = "[]"
  //advanced_condition_json = "null"
  //advanced_condition_json = jsonencode(null)
}

Debug Output

N/A

Panic Output

N/A

Expected Behavior

After applying this resource, additional plans should show no changes.

Actual Behavior

I get a permadiff:

 # pagerduty_event_rule.info-for-service will be updated in-place                                           
  ~ resource "pagerduty_event_rule" "info-for-service" {            
        action_json             = jsonencode(                          
            [                                                          
                [                                                                                                                             
                    "route",                                           
                    "12345",                                         
                ],                                                     
                [                                                      
                    "severity",                                        
                    "info",                                         
                ],                                                     
            ]                                                          
        )                                                              
      - advanced_condition_json = "null" -> null                       
        catch_all               = false                                
        condition_json          = jsonencode(                          
            [                                                          
                "and",                                                 
                [                                                      
                    "equals",                                          
                    [                                                  
                        "path",                                        
                        "vendor",                                      
                    ],                                                 
                    "datadog",                                         
                ],                                                     
                [                                                      
                    "contains",                                        
                    [                                                  
                        "path",                                        
                        "payload",                                     
                        "custom_details",                              
                        "title",                                       
                    ],                                                 
                    "sev:warning",                                     
                ],                                                     
                [                                                      
                    "contains",                                        
                    [                                                  
                        "path",                                        
                        "payload",                                     
                        "custom_details",                              
                        "title",                                       
                    ],                                                 
                    "service:12345",                                 
                ],                                                                                                                            
            ]                                                                                                                                 
        )                                                                                                                                     
        id                      = "<uuid>"                                                                      
    }                                                                  
                                                                       
Plan: 0 to add, 40 to change, 0 to destroy.

Steps to Reproduce

  1. terraform apply
  2. terraform plan

Important Factoids

The pagerduty web UI allows events rules with no advanced conditions, but I've tried a few ways to achieve this with the terraform provider and always get a permadiff.

References

N/A

@stmcallister
Copy link
Contributor

Thanks for pointing this out! I'll take a look and see what I can do.

stmcallister pushed a commit to stmcallister/terraform-provider-pagerduty that referenced this issue Oct 3, 2019
@yob
Copy link
Author

yob commented Oct 4, 2019

I'm not sure if it's related, but with the same config I sometimes get this error when running terraform apply:

Error: Provider produced inconsistent result after apply

When applying changes to
pagerduty_event_rule.info-for-service,
provider "pagerduty" produced an unexpected new value for was present, but now
absent.

This is a bug in the provider, which should be reported in the provider's own
issue tracker

@yob
Copy link
Author

yob commented Oct 10, 2019

I've compiled the latest version from master and tested locally. I can confirm this fixes both issues for us:

  1. the permadiff when resources don't specify an advanced_condition
  2. the Provider produced inconsistent result after apply error

The docs still list advanced_conditions as (Required). Would it be appropriate to mark it optional?

@stmcallister
Copy link
Contributor

@yob Great! Glad both issues are fixed. Good call on the Docs. I'll go fix those right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants