Terraform

Terraform is a Cloud configuration tool from Hashicorp. We maintain a Provider for Terraform called terraform-provider-jetstream that can maintain JetStream using Terraform.

Find it in the Terraform registry.

Setup

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. }

Sample code below that creates 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. }