sl-app
):
- Provisions a Serverless Instance (i.e.,
sl-instance
). - Provisions a Serverless Cluster (i.e.,
sl-clu
). - Provisions a Service Account named
sl-app-sa
. - Provisions an API Key for the Service Account
sl-app-apikey
. - Provisions a Pulsar Tenant named
sl-app-tenant
- Provisions a Pulsar Namespace
sl-app-ns
and grantsproduce
andconsume
permissions to the Service Account on the namespace. - Provisions a Pulsar Topic with 4 partitions
sl-app-topic
. - After provisioning all the resources, we will verify the resources by using the pulsarctl command.
0. Prerequisites
Create a new directory anywhere you’d like for this project.1. Create a Super-Admin Service Account
First, you need to create a service account calledtf-runner
with Super Admin access. Please refer to Create a Service Account for details.
After you have created the service account, download the OAuth2 credentials file and save it as tf-runner.json
in the terraform-getting-started
folder that you created earlier.
2. Create Terraform Configuration Files to provision StreamNative Cloud resources
2.1 Create a Module Folder
Create a module folderstreamnative_cloud
.
2.2 Create Variables File
Create avariables.tf
file inside the streamnative_cloud
folder and add the following code snippet to prepare the variables. Remember to replace <your-organization-id>
with your StreamNative Cloud organization id.
- org_id: Get your StreamNative Cloud organization id from here and replace
<your-organization-id>
with it. - instance_name: The name of the Pulsar instance. Default value is
sl-instance
. - cluster_name: The name of the Pulsar cluster. Default value is
sl-clu
. - app_name: The name of the application. Default value is
sl-app
.
2.3 Create Terraform Configuration File
Create amain.tf
file inside the streamnative_cloud
folder and add the following code snippet to create the resources.
Use the StreamNative Terraform Provider version
0.7.0
or later.3. Create Terraform Configuration Files to provision Pulsar resources
Go back to the root folderterraform-getting-started
.
3.1 Create Variables File
You can copy thevariables.tf
file from the streamnative_cloud
module folder.
{
3.2 Create Terraform Configuration File
Create amain.tf
file in the root folder and add the following code snippet to create the resources.
4. Run Terraform Commands
Before running the Terraform commands, you need to expose the following variables:<your-org-id>
: Your StreamNative Cloud organization ID<your-instance-name>
: A unique name for your Pulsar instance (e.g., “sl-instance”)<your-cluster-name>
: A unique name for your Pulsar cluster (e.g., “sl-clu”)<your-app-name>
: A unique name for your application (e.g., “sl-app”)
4.1 Provision the Cloud Resources
Run a targeted plan to see the changes and preview the resources that will be created.4.2 Provision all the Resources
Runterraform plan
to see the changes and preview the resources that will be created.
terraform apply
to create the resources.
5. Verify the Resources
Use the pulsarctl command to verify all the resources created. Make sure you have installed pulsarctl before running the command. Copy thepulsarctl_command
output and run it in your terminal.
- A Pulsar cluster named
sl-clu
- A Pulsar tenant named
sl-app-tenant
- A Pulsar namespace named
sl-app-ns
- A Pulsar topic named
sl-app-topic
produce
andconsume
permissions are granted tosl-app-sa
on the namespacesl-app-tenant/sl-app-ns