Skip to content

Update Snowbridge testing guide to include http request templating #1209

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion docs/destinations/forwarding-events/snowbridge/testing/index.md
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ To test transformations, you only need to add the `transform` block(s) to your c

To test specific sources or targets, add the respective `source` or `target` blocks. For example, see the [configuration](/docs/destinations/forwarding-events/snowbridge/configuration/targets/http/google-tag-manager.md) for an HTTP target sending data to Google Tag Manager Server Side.

### Adding custom transformation scripts
### Adding a custom transformation script

You can add custom scripts by mounting a file, similarly to the above. Assuming the script is in `script.js`, that looks like this:

@@ -98,6 +98,31 @@ transform {
}
```

### Adding an HTTP request template

For the HTTP target, you can add a custom HTTP request template by mounting a file, similarly to above. Assuming the template is in `template.tpl`, that looks like this:

<CodeBlock language="bash">{
`cat data.tsv | docker run -i \\
--env ACCEPT_LIMITED_USE_LICENSE=yes \\
--mount type=bind,source=$(pwd)/config.hcl,target=/tmp/config.hcl \\
--mount type=bind,source=$(pwd)/template.tpl,target=/tmp/template.tpl \\
snowplow/snowbridge:${versions.snowbridge}`
}</CodeBlock>



The HTTP target config should point to the path of the script _inside_ the container (`/tmp/template.tpl` above). For example, the HTTP target block in the configuration might look like this:

```hcl
target {
use "http" {
url = "http://myApi.com/events"
template_file = "/tmp/template.tpl"
}
}
```

## Further testing

You can use the above method to test all aspects of the app from a local environment too, including sources, targets, failure targets, metrics endpoints etc. In some cases, you'll need to ensure that the local environment has access to any required resources and can authenticate (e.g. connecting from a laptop to a cloud account/local mock of cloud resources, or setting up a local metrics server for testing). Once that’s done, provide Snowbridge with an hcl file configuring it to connect to those resources, and run it the same way as in the examples above.