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

Creating an Source with "verification" set results in 422 API response #60

Closed
leggetter opened this issue May 10, 2024 · 5 comments
Closed

Comments

@leggetter
Copy link
Collaborator

Using this definition:

resource "hookdeck_source_verification" "my_authenticated_source" {
  source_id = "my_authenticated_source"
  verification = {
    json = jsonencode({
      type = "BASIC_AUTH"
      configs = {
        username = "some-username"
        password = "blah-blah-blah"
      }
    })
  }
}

Running terraform apply results in the error shown below:

$ terraform apply                                                                                                                                                                                                 
hookdeck_source.my_source: Refreshing state... 
hookdeck_destination.my_destination: Refreshing state... 
hookdeck_connection.my_connection: Refreshing state... 

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:

  # hookdeck_source_verification.my_authenticated_source will be created
  + resource "hookdeck_source_verification" "my_authenticated_source" {
      + source_id    = "my_authenticated_source"
      + verification = {
          + json = jsonencode(
                {
                  + configs = {
                      + password = "blah-blah-blah"
                      + username = "some-username"
                    }
                  + type    = "BASIC_AUTH"
                }
            )
        }
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

hookdeck_source_verification.my_authenticated_source: Creating...
╷
│ Error: Error creating source verification
│ 
│   with hookdeck_source_verification.my_authenticated_source,
│   on main.tf line 26, in resource "hookdeck_source_verification" "my_authenticated_source":
│   26: resource "hookdeck_source_verification" "my_authenticated_source" {
│ 
│ 422: {"level":"info","handled":true,"report":true,"data":["verification does not match any of the allowed types"],"status":422,"code":"UNPROCESSABLE_ENTITY"}
@leggetter
Copy link
Collaborator Author

leggetter commented May 10, 2024

I've confirmed that the Source API endpoint appears to work as expected:

curl --location 'https://api.hookdeck.com/2024-03-01/sources' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}' \
--data '{
  "name": "my-example-source-2",
  "verification": {
    "type": "BASIC_AUTH",
    "configs": {
      "username": "example_username",
      "password": "example_password"
    }
  }
}'

And the Connection API endpoint:

curl --location 'https://api.hookdeck.com/2024-03-01/connections' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: Bearer {token}' \
--data '{
  "name": "connection-example-1",
  "destination": {
    "name": "my-destination",
    "url": "https://mock.hookdeck.com"
  },
  "source": {
  "name": "my-example-source-3",
  "verification": {
    "type": "BASIC_AUTH",
    "configs": {
      "username": "example_username",
      "password": "example_password"
    }
  }
}
}'

@leggetter
Copy link
Collaborator Author

leggetter commented May 10, 2024

@alexluong within the following, how are we supposed to know the source_id? Should we be using name instead?

resource "hookdeck_source_verification" "my_authenticated_source" {
  source_id = "my_authenticated_source"
  verification = {
    json = jsonencode({
      type = "BASIC_AUTH"
      configs = {
        username = "some-username"
        password = "blah-blah-blah"
      }
    })
  }
}

Note: I've tested and you can create or update a Source with just the name and the id isn't required.

@alexluong
Copy link
Collaborator

@leggetter you're supposed to use the source you created like so

resource "hookdeck_source" "my_authenticated_source" {
  name = "my_authenticated_source"
}

resource "hookdeck_source_verification" "my_authenticated_source" {
  source_id = hookdeck_source.my_authenticated_source.id
  verification = {
    json = jsonencode({
      type = "BASIC_AUTH"
      configs = {
        username = "some-username"
        password = "blah-blah-blah"
      }
    })
  }
}

@leggetter
Copy link
Collaborator Author

leggetter commented May 10, 2024

@leggetter you're supposed to use the source you created like so

resource "hookdeck_source" "my_authenticated_source" {
  name = "my_authenticated_source"
}

resource "hookdeck_source_verification" "my_authenticated_source" {
  source_id = hookdeck_source.my_authenticated_source.id
  verification = {
    json = jsonencode({
      type = "BASIC_AUTH"
      configs = {
        username = "some-username"
        password = "blah-blah-blah"
      }
    })
  }
}

@alexluong - Ok, thanks 👍

@leggetter
Copy link
Collaborator Author

Fixed in #63

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