Skip to content
This repository was archived by the owner on Jul 22, 2025. It is now read-only.
This repository was archived by the owner on Jul 22, 2025. It is now read-only.

Provider reports "panic: runtime error: invalid memory address or nil pointer dereference" when applying aws account with empty keys #872

@mcasperson

Description

@mcasperson

Describe the bug
When applying an octopusdeploy_aws_account resource with empty strings for access_key, the provider crashes and displayed the panic: runtime error: invalid memory address or nil pointer dereference error.

Steps to reproduce

  1. Extract example.zip
  2. Run docker compose up
  3. Run chmod +x apply.sh
  4. Run apply.sh

Expected behavior
An error message should be presented rather than a crash.

Logs and other supporting information

Initializing the backend...
Initializing provider plugins...
- Reusing previous version of octopusdeploylabs/octopusdeploy from the dependency lock file
- Using previously-installed octopusdeploylabs/octopusdeploy v0.40.4

Terraform has been successfully initialized!

You may now begin working with Terraform. Try running "terraform plan" to see
any changes that are required for your infrastructure. All Terraform commands
should now work.

If you ever set or change modules or backend configuration for Terraform,
rerun this command to reinitialize your working directory. If you forget, other
commands will detect it and remind you to do so if necessary.

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # octopusdeploy_aws_account.account_aws_account will be created
  + resource "octopusdeploy_aws_account" "account_aws_account" {
      + environments                      = (known after apply)
      + id                                = (known after apply)
      + name                              = "test"
      + space_id                          = (known after apply)
      + tenant_tags                       = []
      + tenanted_deployment_participation = "Untenanted"
      + tenants                           = (known after apply)
        # (3 unchanged attributes hidden)
    }

Plan: 1 to add, 0 to change, 0 to destroy.
octopusdeploy_aws_account.account_aws_account: Creating...
╷
│ Error: Request cancelled
│ 
│ The plugin6.(*GRPCProvider).ApplyResourceChange request was cancelled.
╵

Stack trace from the terraform-provider-octopusdeploy_v0.40.4 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xc8 pc=0xb84ebf]

goroutine 36 [running]:
github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy.expandAmazonWebServicesAccount(0xc0007ca080)
	github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy/schema_amazon_web_services_account.go:19 +0x1df
github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy.resourceAmazonWebServicesAccountCreate({0x1311200, 0xc0006919d0}, 0xc0007ca080, {0x101d960, 0xc0003c4588})
	github.com/OctopusDeploy/terraform-provider-octopusdeploy/octopusdeploy/resource_aws_account.go:27 +0x4a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0xc00034d420, {0x1311158, 0xc000757d70}, 0xc0007ca080, {0x101d960, 0xc0003c4588})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:806 +0x119
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc00034d420, {0x1311158, 0xc000757d70}, 0xc00080cc30, 0xc00005de80, {0x101d960, 0xc0003c4588})
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/resource.go:937 +0xa89
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*GRPCProviderServer).ApplyResourceChange(0xc000010228, {0x1311158?, 0xc000757bf0?}, 0xc0003d4780)
	github.com/hashicorp/terraform-plugin-sdk/v2@v2.34.0/helper/schema/grpc_provider.go:1153 +0xd5c
github.com/hashicorp/terraform-plugin-mux/tf5to6server.v5tov6Server.ApplyResourceChange({{0x1320ee0?, 0xc000010228?}}, {0x1311158, 0xc000757bf0}, 0x0?)
	github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf5to6server/tf5to6server.go:38 +0x54
github.com/hashicorp/terraform-plugin-mux/tf6muxserver.(*muxServer).ApplyResourceChange(0xc0001ba5b0, {0x1311158?, 0xc000757920?}, 0xc0003d4730)
	github.com/hashicorp/terraform-plugin-mux@v0.16.0/tf6muxserver/mux_server_ApplyResourceChange.go:36 +0x193
github.com/hashicorp/terraform-plugin-go/tfprotov6/tf6server.(*server).ApplyResourceChange(0xc00061a3c0, {0x1311158?, 0xc000756f30?}, 0xc000691340)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/tf6server/server.go:865 +0x3d0
github.com/hashicorp/terraform-plugin-go/tfprotov6/internal/tfplugin6._Provider_ApplyResourceChange_Handler({0x10f7740, 0xc00061a3c0}, {0x1311158, 0xc000756f30}, 0xc00005d680, 0x0)
	github.com/hashicorp/terraform-plugin-go@v0.23.0/tfprotov6/internal/tfplugin6/tfplugin6_grpc.pb.go:518 +0x1a6
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00043e200, {0x1311158, 0xc000756ea0}, {0x131b320, 0xc0001d8a80}, 0xc0007ae120, 0xc000608690, 0x1b082b8, 0x0)
	google.golang.org/grpc@v1.64.1/server.go:1379 +0xdf8
google.golang.org/grpc.(*Server).handleStream(0xc00043e200, {0x131b320, 0xc0001d8a80}, 0xc0007ae120)
	google.golang.org/grpc@v1.64.1/server.go:1790 +0xe8b
google.golang.org/grpc.(*Server).serveStreams.func2.1()
	google.golang.org/grpc@v1.64.1/server.go:1029 +0x8b
created by google.golang.org/grpc.(*Server).serveStreams.func2 in goroutine 54
	google.golang.org/grpc@v1.64.1/server.go:1040 +0x125

Error: The terraform-provider-octopusdeploy_v0.40.4 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.

Environment and versions:

  • OS: Linux
  • Octopus Server Version: 2024.4
  • Terraform Version: v1.10.5
  • Octopus Terraform Provider Version: 0.40.4

Additional context

The root cause is that an error is ignored on this line:

account, _ := accounts.NewAmazonWebServicesAccount(name, accessKey, secretKey)
. Returning that error allows the provider to display an error message about a missing key rather than crashing.

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions