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: interface conversion: interface {} is bool, not string when generating cloudflare_access_application #734

Open
2 tasks done
sashasimkin opened this issue Aug 5, 2024 · 1 comment · May be fixed by #736
Open
2 tasks done

Comments

@sashasimkin
Copy link

Confirmation

  • My issue isn't already found on the issue tracker.
  • I have replicated my issue using the latest version of the library and it is still present.

cf-terraforming version

0.20.0

Expected outcome

Resource generated.

Actual outcome

panik

Steps to reproduce

$ cf-terraforming -a *** -t $CLOUDFLARE_API_TOKEN generate --resource-type cloudflare_access_application

panic: interface conversion: interface {} is bool, not string

goroutine 1 [running]:
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc00012b778, 0x8}, {0xcbcedc0, 0xc000680e10}, {0x0?, 0xcbd8480?}, 0xc000680c48)
	internal/app/cf-terraforming/cmd/util.go:228 +0xe1d
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc00012b778, 0x8}, {0xcbd1da0, 0xc000680b40}, {0x0, 0x0}, 0xc000680c48)
	internal/app/cf-terraforming/cmd/util.go:275 +0x167c
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.init.generateResources.func2(0xd103f40, {0xca66777?, 0x4?, 0xca666f7?})
	internal/app/cf-terraforming/cmd/generate.go:1325 +0x62ae
github.com/spf13/cobra.(*Command).execute(0xd103f40, {0xc000141680, 0x6, 0x8})
	/Users/x/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:987 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xd104500)
	/Users/x/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1115 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/x/Library/Caches/Homebrew/go_mod_cache/pkg/mod/github.com/spf13/[email protected]/command.go:1039
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.Execute()
	internal/app/cf-terraforming/cmd/root.go:30 +0x1a
main.main()
	cmd/cf-terraforming/main.go:8 +0xf

I dug into the code a little, and seems like terraforming can't cope with policies.*.reusable (looking at this case https://github.com/cloudflare/cf-terraforming/blob/v0.20.0/internal/app/cf-terraforming/cmd/util.go#L251), here's an excerpt of API response that I received while running with --verbose flag:

{
  "result": [
    {
      "id": "***",
      "uid": "***",
      "type": "warp",
      "name": "Warp Login App",
      "aud": "***",
      "created_at": "2024-07-02T15:17:29Z",
      "updated_at": "2024-08-02T15:47:40Z",
      "domain": "***.cloudflareaccess.com/warp",
      "allowed_idps": [],
      "session_duration": "24h",
      "auto_redirect_to_identity": false,
      "policies": [
        {
          "created_at": "2024-07-02T15:17:29Z",
          "decision": "allow",
          "exclude": [],
          "id": "***",
          "include": [
            {
              "login_method": {
                "id": "***"
              }
            }
          ],
          "name": "Allow access with AWS login",
          "require": [],
          "uid": "***",
          "updated_at": "2024-08-02T15:47:40Z",
          "reusable": false,
          "precedence": 2
        },
        {
          "created_at": "2024-08-02T15:46:23Z",
          "decision": "allow",
          "exclude": [],
          "id": "***",
          "include": [
            {
              "email_domain": {
                "domain": "***"
              }
            }
          ],
          "name": "Allow all @***",
          "require": [],
          "uid": "***",
          "updated_at": "2024-08-02T15:47:40Z",
          "reusable": false,
          "precedence": 3
        }
      ],
      "tags": []
    },
......

References

No response

@sashasimkin
Copy link
Author

On current master (3ab7b24) the error is different:

$ cf-terraforming -a $CF_ACC -t $CLOUDFLARE_API_TOKEN generate --resource-type cloudflare_access_application
2024/08/06 13:38:09 [DEBUG] GET https://releases.hashicorp.com/terraform/index.json
2024/08/06 13:38:10 [DEBUG] GET https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_SHA256SUMS.72D7468F.sig
2024/08/06 13:38:10 [DEBUG] GET https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_SHA256SUMS
2024/08/06 13:38:10 [DEBUG] GET https://releases.hashicorp.com/terraform/1.9.3/terraform_1.9.3_darwin_amd64.zip
panic: interface conversion: interface {} is []interface {}, not string

goroutine 1 [running]:
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc0004ef498, 0x8}, {0xb9939c0, 0xc000119140}, {0x0?, 0xb99d200?}, 0xc000118f90)
	/Users/x/go/pkg/mod/github.com/cloudflare/[email protected]/internal/app/cf-terraforming/cmd/util.go:228 +0xe1d
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.writeAttrLine({0xc0004ef498, 0x8}, {0xb9969e0, 0xc000118e88}, {0x0, 0x0}, 0xc000118f90)
	/Users/x/go/pkg/mod/github.com/cloudflare/[email protected]/internal/app/cf-terraforming/cmd/util.go:275 +0x167c
github.com/x/cf-terraforming/internal/app/cf-terraforming/cmd.init.generateResources.func2(0xbecc200, {0xb828b13?, 0x4?, 0xb828a97?})
	/Users/x/go/pkg/mod/github.com/cloudflare/[email protected]/internal/app/cf-terraforming/cmd/generate.go:1328 +0x62ee
github.com/spf13/cobra.(*Command).execute(0xbecc200, {0xc000198360, 0x6, 0x6})
	/Users/x/go/pkg/mod/github.com/spf13/[email protected]/command.go:989 +0xab1
github.com/spf13/cobra.(*Command).ExecuteC(0xbecc7c0)
	/Users/x/go/pkg/mod/github.com/spf13/[email protected]/command.go:1117 +0x3ff
github.com/spf13/cobra.(*Command).Execute(...)
	/Users/x/go/pkg/mod/github.com/spf13/[email protected]/command.go:1041
github.com/cloudflare/cf-terraforming/internal/app/cf-terraforming/cmd.Execute()
	/Users/x/go/pkg/mod/github.com/cloudflare/[email protected]/internal/app/cf-terraforming/cmd/root.go:30 +0x1a
main.main()
	/Users/x/go/pkg/mod/github.com/cloudflare/[email protected]/cmd/cf-terraforming/main.go:8 +0xf

@hur hur linked a pull request Aug 16, 2024 that will close this issue
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

Successfully merging a pull request may close this issue.

1 participant