1. Packages
  2. Rabbitmq Provider
  3. API Docs
  4. Exchange
RabbitMQ v3.3.9 published on Wednesday, Feb 12, 2025 by Pulumi

rabbitmq.Exchange

Explore with Pulumi AI

The rabbitmq.Exchange resource creates and manages an exchange.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as rabbitmq from "@pulumi/rabbitmq";

const test = new rabbitmq.VHost("test", {name: "test"});
const guest = new rabbitmq.Permissions("guest", {
    user: "guest",
    vhost: test.name,
    permissions: {
        configure: ".*",
        write: ".*",
        read: ".*",
    },
});
const testExchange = new rabbitmq.Exchange("test", {
    name: "test",
    vhost: guest.vhost,
    settings: {
        type: "fanout",
        durable: false,
        autoDelete: true,
    },
});
Copy
import pulumi
import pulumi_rabbitmq as rabbitmq

test = rabbitmq.VHost("test", name="test")
guest = rabbitmq.Permissions("guest",
    user="guest",
    vhost=test.name,
    permissions={
        "configure": ".*",
        "write": ".*",
        "read": ".*",
    })
test_exchange = rabbitmq.Exchange("test",
    name="test",
    vhost=guest.vhost,
    settings={
        "type": "fanout",
        "durable": False,
        "auto_delete": True,
    })
Copy
package main

import (
	"github.com/pulumi/pulumi-rabbitmq/sdk/v3/go/rabbitmq"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		test, err := rabbitmq.NewVHost(ctx, "test", &rabbitmq.VHostArgs{
			Name: pulumi.String("test"),
		})
		if err != nil {
			return err
		}
		guest, err := rabbitmq.NewPermissions(ctx, "guest", &rabbitmq.PermissionsArgs{
			User:  pulumi.String("guest"),
			Vhost: test.Name,
			Permissions: &rabbitmq.PermissionsPermissionsArgs{
				Configure: pulumi.String(".*"),
				Write:     pulumi.String(".*"),
				Read:      pulumi.String(".*"),
			},
		})
		if err != nil {
			return err
		}
		_, err = rabbitmq.NewExchange(ctx, "test", &rabbitmq.ExchangeArgs{
			Name:  pulumi.String("test"),
			Vhost: guest.Vhost,
			Settings: &rabbitmq.ExchangeSettingsArgs{
				Type:       pulumi.String("fanout"),
				Durable:    pulumi.Bool(false),
				AutoDelete: pulumi.Bool(true),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using RabbitMQ = Pulumi.RabbitMQ;

return await Deployment.RunAsync(() => 
{
    var test = new RabbitMQ.VHost("test", new()
    {
        Name = "test",
    });

    var guest = new RabbitMQ.Permissions("guest", new()
    {
        User = "guest",
        Vhost = test.Name,
        PermissionDetails = new RabbitMQ.Inputs.PermissionsPermissionsArgs
        {
            Configure = ".*",
            Write = ".*",
            Read = ".*",
        },
    });

    var testExchange = new RabbitMQ.Exchange("test", new()
    {
        Name = "test",
        Vhost = guest.Vhost,
        Settings = new RabbitMQ.Inputs.ExchangeSettingsArgs
        {
            Type = "fanout",
            Durable = false,
            AutoDelete = true,
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.rabbitmq.VHost;
import com.pulumi.rabbitmq.VHostArgs;
import com.pulumi.rabbitmq.Permissions;
import com.pulumi.rabbitmq.PermissionsArgs;
import com.pulumi.rabbitmq.inputs.PermissionsPermissionsArgs;
import com.pulumi.rabbitmq.Exchange;
import com.pulumi.rabbitmq.ExchangeArgs;
import com.pulumi.rabbitmq.inputs.ExchangeSettingsArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var test = new VHost("test", VHostArgs.builder()
            .name("test")
            .build());

        var guest = new Permissions("guest", PermissionsArgs.builder()
            .user("guest")
            .vhost(test.name())
            .permissions(PermissionsPermissionsArgs.builder()
                .configure(".*")
                .write(".*")
                .read(".*")
                .build())
            .build());

        var testExchange = new Exchange("testExchange", ExchangeArgs.builder()
            .name("test")
            .vhost(guest.vhost())
            .settings(ExchangeSettingsArgs.builder()
                .type("fanout")
                .durable(false)
                .autoDelete(true)
                .build())
            .build());

    }
}
Copy
resources:
  test:
    type: rabbitmq:VHost
    properties:
      name: test
  guest:
    type: rabbitmq:Permissions
    properties:
      user: guest
      vhost: ${test.name}
      permissions:
        configure: .*
        write: .*
        read: .*
  testExchange:
    type: rabbitmq:Exchange
    name: test
    properties:
      name: test
      vhost: ${guest.vhost}
      settings:
        type: fanout
        durable: false
        autoDelete: true
Copy

Create Exchange Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new Exchange(name: string, args: ExchangeArgs, opts?: CustomResourceOptions);
@overload
def Exchange(resource_name: str,
             args: ExchangeArgs,
             opts: Optional[ResourceOptions] = None)

@overload
def Exchange(resource_name: str,
             opts: Optional[ResourceOptions] = None,
             settings: Optional[ExchangeSettingsArgs] = None,
             name: Optional[str] = None,
             vhost: Optional[str] = None)
func NewExchange(ctx *Context, name string, args ExchangeArgs, opts ...ResourceOption) (*Exchange, error)
public Exchange(string name, ExchangeArgs args, CustomResourceOptions? opts = null)
public Exchange(String name, ExchangeArgs args)
public Exchange(String name, ExchangeArgs args, CustomResourceOptions options)
type: rabbitmq:Exchange
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. ExchangeArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. ExchangeArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. ExchangeArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. ExchangeArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. ExchangeArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var exchangeResource = new RabbitMQ.Exchange("exchangeResource", new()
{
    Settings = new RabbitMQ.Inputs.ExchangeSettingsArgs
    {
        Type = "string",
        Arguments = 
        {
            { "string", "string" },
        },
        AutoDelete = false,
        Durable = false,
    },
    Name = "string",
    Vhost = "string",
});
Copy
example, err := rabbitmq.NewExchange(ctx, "exchangeResource", &rabbitmq.ExchangeArgs{
	Settings: &rabbitmq.ExchangeSettingsArgs{
		Type: pulumi.String("string"),
		Arguments: pulumi.StringMap{
			"string": pulumi.String("string"),
		},
		AutoDelete: pulumi.Bool(false),
		Durable:    pulumi.Bool(false),
	},
	Name:  pulumi.String("string"),
	Vhost: pulumi.String("string"),
})
Copy
var exchangeResource = new Exchange("exchangeResource", ExchangeArgs.builder()
    .settings(ExchangeSettingsArgs.builder()
        .type("string")
        .arguments(Map.of("string", "string"))
        .autoDelete(false)
        .durable(false)
        .build())
    .name("string")
    .vhost("string")
    .build());
Copy
exchange_resource = rabbitmq.Exchange("exchangeResource",
    settings={
        "type": "string",
        "arguments": {
            "string": "string",
        },
        "auto_delete": False,
        "durable": False,
    },
    name="string",
    vhost="string")
Copy
const exchangeResource = new rabbitmq.Exchange("exchangeResource", {
    settings: {
        type: "string",
        arguments: {
            string: "string",
        },
        autoDelete: false,
        durable: false,
    },
    name: "string",
    vhost: "string",
});
Copy
type: rabbitmq:Exchange
properties:
    name: string
    settings:
        arguments:
            string: string
        autoDelete: false
        durable: false
        type: string
    vhost: string
Copy

Exchange Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The Exchange resource accepts the following input properties:

Settings
This property is required.
Changes to this property will trigger replacement.
Pulumi.RabbitMQ.Inputs.ExchangeSettings
The settings of the exchange. The structure is described below.
Name Changes to this property will trigger replacement. string
The name of the exchange.
Vhost Changes to this property will trigger replacement. string
The vhost to create the resource in.
Settings
This property is required.
Changes to this property will trigger replacement.
ExchangeSettingsArgs
The settings of the exchange. The structure is described below.
Name Changes to this property will trigger replacement. string
The name of the exchange.
Vhost Changes to this property will trigger replacement. string
The vhost to create the resource in.
settings
This property is required.
Changes to this property will trigger replacement.
ExchangeSettings
The settings of the exchange. The structure is described below.
name Changes to this property will trigger replacement. String
The name of the exchange.
vhost Changes to this property will trigger replacement. String
The vhost to create the resource in.
settings
This property is required.
Changes to this property will trigger replacement.
ExchangeSettings
The settings of the exchange. The structure is described below.
name Changes to this property will trigger replacement. string
The name of the exchange.
vhost Changes to this property will trigger replacement. string
The vhost to create the resource in.
settings
This property is required.
Changes to this property will trigger replacement.
ExchangeSettingsArgs
The settings of the exchange. The structure is described below.
name Changes to this property will trigger replacement. str
The name of the exchange.
vhost Changes to this property will trigger replacement. str
The vhost to create the resource in.
settings
This property is required.
Changes to this property will trigger replacement.
Property Map
The settings of the exchange. The structure is described below.
name Changes to this property will trigger replacement. String
The name of the exchange.
vhost Changes to this property will trigger replacement. String
The vhost to create the resource in.

Outputs

All input properties are implicitly available as output properties. Additionally, the Exchange resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.
id String
The provider-assigned unique ID for this managed resource.

Look up Existing Exchange Resource

Get an existing Exchange resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: ExchangeState, opts?: CustomResourceOptions): Exchange
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        name: Optional[str] = None,
        settings: Optional[ExchangeSettingsArgs] = None,
        vhost: Optional[str] = None) -> Exchange
func GetExchange(ctx *Context, name string, id IDInput, state *ExchangeState, opts ...ResourceOption) (*Exchange, error)
public static Exchange Get(string name, Input<string> id, ExchangeState? state, CustomResourceOptions? opts = null)
public static Exchange get(String name, Output<String> id, ExchangeState state, CustomResourceOptions options)
resources:  _:    type: rabbitmq:Exchange    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
Name Changes to this property will trigger replacement. string
The name of the exchange.
Settings Changes to this property will trigger replacement. Pulumi.RabbitMQ.Inputs.ExchangeSettings
The settings of the exchange. The structure is described below.
Vhost Changes to this property will trigger replacement. string
The vhost to create the resource in.
Name Changes to this property will trigger replacement. string
The name of the exchange.
Settings Changes to this property will trigger replacement. ExchangeSettingsArgs
The settings of the exchange. The structure is described below.
Vhost Changes to this property will trigger replacement. string
The vhost to create the resource in.
name Changes to this property will trigger replacement. String
The name of the exchange.
settings Changes to this property will trigger replacement. ExchangeSettings
The settings of the exchange. The structure is described below.
vhost Changes to this property will trigger replacement. String
The vhost to create the resource in.
name Changes to this property will trigger replacement. string
The name of the exchange.
settings Changes to this property will trigger replacement. ExchangeSettings
The settings of the exchange. The structure is described below.
vhost Changes to this property will trigger replacement. string
The vhost to create the resource in.
name Changes to this property will trigger replacement. str
The name of the exchange.
settings Changes to this property will trigger replacement. ExchangeSettingsArgs
The settings of the exchange. The structure is described below.
vhost Changes to this property will trigger replacement. str
The vhost to create the resource in.
name Changes to this property will trigger replacement. String
The name of the exchange.
settings Changes to this property will trigger replacement. Property Map
The settings of the exchange. The structure is described below.
vhost Changes to this property will trigger replacement. String
The vhost to create the resource in.

Supporting Types

ExchangeSettings
, ExchangeSettingsArgs

Type This property is required. string
The type of exchange.
Arguments Dictionary<string, string>
Additional key/value settings for the exchange.
AutoDelete bool
Whether the exchange will self-delete when all queues have finished using it.
Durable bool
Whether the exchange survives server restarts. Defaults to false.
Type This property is required. string
The type of exchange.
Arguments map[string]string
Additional key/value settings for the exchange.
AutoDelete bool
Whether the exchange will self-delete when all queues have finished using it.
Durable bool
Whether the exchange survives server restarts. Defaults to false.
type This property is required. String
The type of exchange.
arguments Map<String,String>
Additional key/value settings for the exchange.
autoDelete Boolean
Whether the exchange will self-delete when all queues have finished using it.
durable Boolean
Whether the exchange survives server restarts. Defaults to false.
type This property is required. string
The type of exchange.
arguments {[key: string]: string}
Additional key/value settings for the exchange.
autoDelete boolean
Whether the exchange will self-delete when all queues have finished using it.
durable boolean
Whether the exchange survives server restarts. Defaults to false.
type This property is required. str
The type of exchange.
arguments Mapping[str, str]
Additional key/value settings for the exchange.
auto_delete bool
Whether the exchange will self-delete when all queues have finished using it.
durable bool
Whether the exchange survives server restarts. Defaults to false.
type This property is required. String
The type of exchange.
arguments Map<String>
Additional key/value settings for the exchange.
autoDelete Boolean
Whether the exchange will self-delete when all queues have finished using it.
durable Boolean
Whether the exchange survives server restarts. Defaults to false.

Import

Exchanges can be imported using the id which is composed of name@vhost.

E.g.

$ pulumi import rabbitmq:index/exchange:Exchange test test@vhost
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
RabbitMQ pulumi/pulumi-rabbitmq
License
Apache-2.0
Notes
This Pulumi package is based on the rabbitmq Terraform Provider.