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

Panic when module source is a malformed S3 address #35515

Closed
liamg opened this issue Jul 30, 2024 · 2 comments · Fixed by hashicorp/go-getter#501
Closed

Panic when module source is a malformed S3 address #35515

liamg opened this issue Jul 30, 2024 · 2 comments · Fixed by hashicorp/go-getter#501
Labels
bug new new issue not yet triaged upstream

Comments

@liamg
Copy link

liamg commented Jul 30, 2024

Terraform Version

Tried v1.6.0 and v1.9.3

Terraform Configuration Files

module "uhoh" {
  source = "s3.amazonaws.com/bucket"
}

Debug Output

2024-07-30T16:17:24.344Z [INFO]  Terraform version: 1.9.3
2024-07-30T16:17:24.344Z [DEBUG] using github.com/hashicorp/go-tfe v1.51.0
2024-07-30T16:17:24.344Z [DEBUG] using github.com/hashicorp/hcl/v2 v2.20.0
2024-07-30T16:17:24.344Z [DEBUG] using github.com/hashicorp/terraform-svchost v0.1.1
2024-07-30T16:17:24.344Z [DEBUG] using github.com/zclconf/go-cty v1.14.4
2024-07-30T16:17:24.344Z [INFO]  Go runtime version: go1.22.5
2024-07-30T16:17:24.344Z [INFO]  CLI args: []string{"/bin/terraform", "init"}
2024-07-30T16:17:24.344Z [TRACE] Stdout is a terminal of width 98
2024-07-30T16:17:24.344Z [TRACE] Stderr is a terminal of width 98
2024-07-30T16:17:24.344Z [TRACE] Stdin is a terminal
2024-07-30T16:17:24.344Z [DEBUG] Attempting to open CLI config file: /root/.terraformrc
2024-07-30T16:17:24.344Z [DEBUG] File doesn't exist, but doesn't need to. Ignoring.
2024-07-30T16:17:24.344Z [DEBUG] ignoring non-existing provider search directory terraform.d/plugins
2024-07-30T16:17:24.344Z [DEBUG] ignoring non-existing provider search directory /root/.terraform.d/plugins
2024-07-30T16:17:24.345Z [DEBUG] ignoring non-existing provider search directory /root/.local/share/terraform/plugins
2024-07-30T16:17:24.345Z [DEBUG] ignoring non-existing provider search directory /usr/local/share/terraform/plugins
2024-07-30T16:17:24.345Z [DEBUG] ignoring non-existing provider search directory /usr/share/terraform/plugins
2024-07-30T16:17:24.346Z [INFO]  CLI command args: []string{"init"}
Initializing the backend...
2024-07-30T16:17:24.348Z [TRACE] Meta.Backend: no config given or present on disk, so returning nil config
2024-07-30T16:17:24.348Z [TRACE] Meta.Backend: backend has not previously been initialized in this working directory
2024-07-30T16:17:24.348Z [TRACE] Meta.Backend: using default local state only (no backend configuration, and no existing initialized backend)
2024-07-30T16:17:24.348Z [TRACE] Meta.Backend: instantiated backend of type <nil>
2024-07-30T16:17:24.348Z [DEBUG] checking for provisioner in "."
2024-07-30T16:17:24.349Z [DEBUG] checking for provisioner in "/bin"
2024-07-30T16:17:24.349Z [TRACE] Meta.Backend: backend <nil> does not support operations, so wrapping it in a local backend
2024-07-30T16:17:24.349Z [TRACE] backend/local: state manager for workspace "default" will:
 - read initial snapshot from terraform.tfstate
 - write new snapshots to terraform.tfstate
 - create any backup at terraform.tfstate.backup
2024-07-30T16:17:24.349Z [TRACE] statemgr.Filesystem: reading initial snapshot from terraform.tfstate
2024-07-30T16:17:24.349Z [TRACE] statemgr.Filesystem: snapshot file has nil snapshot, but that's okay
2024-07-30T16:17:24.349Z [TRACE] statemgr.Filesystem: read nil snapshot
Initializing modules...
2024-07-30T16:17:24.349Z [TRACE] ModuleInstaller: installing child modules for . into .terraform/modules
2024-07-30T16:17:24.350Z [DEBUG] Module installer: begin uhoh
2024-07-30T16:17:24.350Z [TRACE] ModuleInstaller: uhoh is not yet installed
2024-07-30T16:17:24.350Z [TRACE] ModuleInstaller: cleaning directory .terraform/modules/uhoh prior to install of uhoh
2024-07-30T16:17:24.350Z [TRACE] ModuleInstaller: uhoh address "s3::https://s3.amazonaws.com/bucket" will be handled by go-getter
Downloading s3::https://s3.amazonaws.com/bucket for uhoh...
2024-07-30T16:17:24.350Z [TRACE] getmodules: fetching "s3::https://s3.amazonaws.com/bucket" to ".terraform/modules/uhoh"

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
Please report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version, the stack trace
shown below, and any additional information which may help replicate the issue.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

panic: runtime error: index out of range [2] with length 2
goroutine 1 [running]:
runtime/debug.Stack()
	runtime/debug/stack.go:24 +0x64
github.com/hashicorp/terraform/internal/logging.PanicHandler()
	github.com/hashicorp/terraform/internal/logging/panic.go:84 +0x198
panic({0x2b8af80?, 0x4000074e40?})
	runtime/panic.go:770 +0x124
github.com/hashicorp/go-getter.(*S3Getter).parseUrl(0x28?, 0x400028db00)
	github.com/hashicorp/go-getter@v1.7.5/get_s3.go:272 +0x7e0
github.com/hashicorp/go-getter.(*S3Getter).Get(0x400097c360, {0x4000074d80, 0x17}, 0x400028db00)
	github.com/hashicorp/go-getter@v1.7.5/get_s3.go:90 +0xc4
github.com/hashicorp/go-getter.(*Client).Get(0x4000af8160)
	github.com/hashicorp/go-getter@v1.7.5/client.go:321 +0xae0
github.com/hashicorp/terraform/internal/getmodules.reusingGetter.getWithGoGetter(0x400098dc20, {0x3684458, 0x400098d4a0}, {0x4000074d80, 0x17}, {0x4000896330, 0x23})
	github.com/hashicorp/terraform/internal/getmodules/getter.go:137 +0x3c4
github.com/hashicorp/terraform/internal/getmodules.(*PackageFetcher).FetchPackage(...)
	github.com/hashicorp/terraform/internal/getmodules/installer.go:46
github.com/hashicorp/terraform/internal/initwd.(*ModuleInstaller).installGoGetterModule(0x400098d5c0, {0x3684458, 0x400098d4a0}, 0x400094f320, {0x40008ec168, 0x4}, {0x4000074d80, 0x17}, 0x400098dbf0, {0x365a640, ...}, ...)
	github.com/hashicorp/terraform/internal/initwd/module_install.go:712 +0x2ac
github.com/hashicorp/terraform/internal/initwd.(*ModuleInstaller).InstallModules.(*ModuleInstaller).moduleInstallWalker.func2(0x400094f320)
	github.com/hashicorp/terraform/internal/initwd/module_install.go:282 +0x8e0
github.com/hashicorp/terraform/internal/configs.ModuleWalkerFunc.LoadModule(0x4000b1eba8?, 0x7df98?)
	github.com/hashicorp/terraform/internal/configs/config_build.go:280 +0x28
github.com/hashicorp/terraform/internal/configs.loadModule(0x400080c7e0, 0x400094f320, {0x3649c40, 0x40008ce2d0})
	github.com/hashicorp/terraform/internal/configs/config_build.go:191 +0x3c
github.com/hashicorp/terraform/internal/configs.buildChildModules(0x400080c7e0, {0x3649c40, 0x40008ce2d0})
	github.com/hashicorp/terraform/internal/configs/config_build.go:174 +0x3b8
github.com/hashicorp/terraform/internal/configs.BuildConfig(0x40004ec5a0, {0x3649c40, 0x40008ce2d0}, {0x3649c80, 0x400097c580})
	github.com/hashicorp/terraform/internal/configs/config_build.go:33 +0x74
github.com/hashicorp/terraform/internal/initwd.(*ModuleInstaller).installDescendentModules(0x400098d5c0, 0x40004ec5a0, 0x400098dbf0, {0x3649c40, 0x40008ce2d0}, 0x0)
	github.com/hashicorp/terraform/internal/initwd/module_install.go:315 +0x114
github.com/hashicorp/terraform/internal/initwd.(*ModuleInstaller).InstallModules(0x400098d5c0, {0x3684458, 0x400098d4a0}, {0x3636c98, 0x1}, {0x2d92183, 0x5}, 0x0, 0x0, {0x365a640, ...})
	github.com/hashicorp/terraform/internal/initwd/module_install.go:140 +0x4c4
github.com/hashicorp/terraform/internal/command.(*Meta).installModules(0x4000ac2380, {0x3684458?, 0x400098d440?}, {0x4000ad6018, 0x11}, {0x2d92183, 0x5}, 0x0, 0x0, {0x365a640, ...})
	github.com/hashicorp/terraform/internal/command/meta_config.go:206 +0x2f4
github.com/hashicorp/terraform/internal/command.(*InitCommand).getModules(0x4000ac2380, {0x3684490, 0x4000af2050}, {0x4000ad6018, 0x11}, {0x2d92183, 0x5}, 0x40004ec1e0, 0x0, {0x3689960, ...})
	github.com/hashicorp/terraform/internal/command/init.go:368 +0x410
github.com/hashicorp/terraform/internal/command.(*InitCommand).Run(0x4000ac2380, {0x400006e050?, 0x0?, 0x0?})
	github.com/hashicorp/terraform/internal/command/init.go:226 +0xea8
github.com/hashicorp/cli.(*CLI).Run(0x4000adc000)
	github.com/hashicorp/cli@v1.1.6/cli.go:265 +0x4a8
main.realMain()
	github.com/hashicorp/terraform/main.go:339 +0x18f8
main.main()
	github.com/hashicorp/terraform/main.go:64 +0x1c

Expected Behavior

No panic

Actual Behavior

Panic

Steps to Reproduce

  1. terraform init with the above example

Additional Context

Fix in go-getter below.

References

hashicorp/go-getter#501

@crw
Copy link
Contributor

crw commented Jul 30, 2024

Thanks for this report and the potential fix!

Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug new new issue not yet triaged upstream
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants