Terraform

Terraform is a Cloud configuration tool from Hashicorp found at terraform.io, we maintain a Provider for Terraform called terraform-provider-jetstream that can maintain JetStream using Terraform.

Setup

Our provider is not hosted by Hashicorp so installation is a bit more complex than typical. Browse to the Release Page and download the release for your platform and extract it into your Terraform plugins directory.

  1. $ unzip -l terraform-provider-jetstream_0.0.2_darwin_amd64.zip
  2. Archive: terraform-provider-jetstream_0.0.2_darwin_amd64.zip
  3. Length Date Time Name
  4. --------- ---------- ----- ----
  5. 11357 03-09-2020 10:48 LICENSE
  6. 1830 03-09-2020 12:53 README.md
  7. 24574336 03-09-2020 12:54 terraform-provider-jetstream_v0.0.2

Place the terraform-provider-jetstream_v0.0.2 file in ~/.terraform.d/plugins/terraform-provider-jetstream_v0.0.2

In your project you can configure the Provider like this:

  1. provider "jetstream" {
  2. servers = "connect.ngs.global"
  3. credentials = "ngs_jetstream_admin.creds"
  4. }

And start using it, here’s an example that create the ORDERS example. Review the Project README for full details.

  1. resource "jetstream_stream" "ORDERS" {
  2. name = "ORDERS"
  3. subjects = ["ORDERS.*"]
  4. storage = "file"
  5. max_age = 60 * 60 * 24 * 365
  6. }
  7. resource "jetstream_consumer" "ORDERS_NEW" {
  8. stream_id = jetstream_stream.ORDERS.id
  9. durable_name = "NEW"
  10. deliver_all = true
  11. filter_subject = "ORDERS.received"
  12. sample_freq = 100
  13. }
  14. resource "jetstream_consumer" "ORDERS_DISPATCH" {
  15. stream_id = jetstream_stream.ORDERS.id
  16. durable_name = "DISPATCH"
  17. deliver_all = true
  18. filter_subject = "ORDERS.processed"
  19. sample_freq = 100
  20. }
  21. resource "jetstream_consumer" "ORDERS_MONITOR" {
  22. stream_id = jetstream_stream.ORDERS.id
  23. durable_name = "MONITOR"
  24. deliver_last = true
  25. ack_policy = "none"
  26. delivery_subject = "monitor.ORDERS"
  27. }
  28. output "ORDERS_SUBJECTS" {
  29. value = jetstream_stream.ORDERS.subjects
  30. }