Skip to content

terraform provider crashes trying to enable ngwaf on a compute service #1278

@ryanmcmichael

Description

@ryanmcmichael

Terraform Version

Terraform v1.9.8                                                                                                  
on linux_arm64                                                                                                    
+ provider registry.terraform.io/fastly/fastly v9.2.0                                                             
                                                                                                                  
Affected Fastly Terraform Resource(s)                                                                             
                                                                                                                  
- fastly_service_compute                                                                                          
                                                                                                                
Terraform Configuration Files                                                                                   

resource "fastly_service_compute" "grpc_proxy" {
  name = "dev-money-grpc-proxy"                                                                                   

  package {                                                                                                       
    filename         = var.package_path                                                                         
    source_code_hash = data.fastly_package_hash.this.hash                                                         
  }                                                                                                               
                                                                                                                  
  resource_link {                                                                                                 
    name        = "config"                                                                                      
    resource_id = fastly_configstore.config.id                                                                    
  }
                                                                                                                  
  product_enablement {                                                                                          
    ngwaf {                                                                                                     
      enabled      = true                                                                                         
      workspace_id = "example-workspace-id"
    }                                                                                                             
  }                                                                                                             
                                                                                                                
  force_destroy = true
  activate      = true
}                                                                                                                 

Expected Behavior                                                                                                 
                                                                                                                
Adding a product_enablement block with ngwaf to a fastly_service_compute resource should enable NGWAF on the      
Compute service, either during initial creation or as a subsequent update.
                                                                                                                  
Actual Behavior                                                                                                 
                                                                                                                
The Fastly provider crashes with a nil pointer dereference in ProductEnablementServiceAttributeHandler.Read during
 both create and update operations. The service is created in Fastly but the state is not saved, causing "Name
already taken" conflicts on subsequent applies.                                                                   
                                                                                                                
This is reproducible on every apply — both creating a new Compute service with product_enablement and updating an 
existing one to add it.
                                                                                                                  
Stack trace:                                                                                                    
                                                                                                                
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x860f20]
                                                                                                                  
goroutine 56 [running]:
github.com/fastly/terraform-provider-fastly/fastly.(*ProductEnablementServiceAttributeHandler).Read(0x1493330,    
{0xd665a8, 0x4000507260}, 0x4000586d80, 0x0?, 0x0?, 0x4000147180)                                                 
    github.com/fastly/terraform-provider-fastly/fastly/block_fastly_service_product_enablement.go:451 +0x1ce0   
github.com/fastly/terraform-provider-fastly/fastly.(*blockSetAttributeHandler).Read(0x4000586d80?, {0xd665a8?,    
0x4000507260?}, 0x9b2760?, 0x4000011cc0?, 0x4000500170?)                                                          
    github.com/fastly/terraform-provider-fastly/fastly/service_crud_attribute_definition.go:78 +0x54              
github.com/fastly/terraform-provider-fastly/fastly.resourceServiceRead({0xd665a8, 0x4000507260}, 0x4000586d80,    
{0x9b1920, 0x4000136258}, {0xd62ab0, 0x14a57a0})                                                                  
    github.com/fastly/terraform-provider-fastly/fastly/base_fastly_service.go:695 +0x1254                         
github.com/fastly/terraform-provider-fastly/fastly.resourceServiceUpdate({0xd665a8, 0x4000507260}, 0x4000586d80,  
{0x9b1920, 0x4000136258}, {0xd62ab0, 0x14a57a0})                                                                  
    github.com/fastly/terraform-provider-fastly/fastly/base_fastly_service.go:538 +0x2444                         
                                                                                                                  
The crash occurs at block_fastly_service_product_enablement.go:451 during the Read call after the service is      
created/updated. This appears to be specific to fastly_service_compute — the same product_enablement block with   
ngwaf works on fastly_service_vcl resources without issue.                                                        

Debug Output (optional)

Please provide a link to a GitHub Gist containing the complete debug output (see Terraform docs). Ensure any sensitive data is <REDACTED>.

Steps to Reproduce

Please list the steps required to reproduce the issue, for example:

  1. terraform apply

Important Factoids (optional)

Is there anything atypical about your account or set up that we should know?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions