1. Packages
  2. Mailgun Provider
  3. API Docs
  4. Route
Mailgun v3.5.9 published on Wednesday, Apr 9, 2025 by Pulumi

mailgun.Route

Explore with Pulumi AI

Provides a Mailgun Route resource. This can be used to create and manage routes on Mailgun.

Example Usage

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

// Create a new Mailgun route
const _default = new mailgun.Route("default", {
    priority: 0,
    description: "inbound",
    expression: "match_recipient('.*@foo.example.com')",
    actions: [
        "forward('http://example.com/api/v1/foos/')",
        "stop()",
    ],
});
Copy
import pulumi
import pulumi_mailgun as mailgun

# Create a new Mailgun route
default = mailgun.Route("default",
    priority=0,
    description="inbound",
    expression="match_recipient('.*@foo.example.com')",
    actions=[
        "forward('http://example.com/api/v1/foos/')",
        "stop()",
    ])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a new Mailgun route
		_, err := mailgun.NewRoute(ctx, "default", &mailgun.RouteArgs{
			Priority:    pulumi.Int(0),
			Description: pulumi.String("inbound"),
			Expression:  pulumi.String("match_recipient('.*@foo.example.com')"),
			Actions: pulumi.StringArray{
				pulumi.String("forward('http://example.com/api/v1/foos/')"),
				pulumi.String("stop()"),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Mailgun = Pulumi.Mailgun;

return await Deployment.RunAsync(() => 
{
    // Create a new Mailgun route
    var @default = new Mailgun.Route("default", new()
    {
        Priority = 0,
        Description = "inbound",
        Expression = "match_recipient('.*@foo.example.com')",
        Actions = new[]
        {
            "forward('http://example.com/api/v1/foos/')",
            "stop()",
        },
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.mailgun.Route;
import com.pulumi.mailgun.RouteArgs;
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) {
        // Create a new Mailgun route
        var default_ = new Route("default", RouteArgs.builder()
            .priority(0)
            .description("inbound")
            .expression("match_recipient('.*@foo.example.com')")
            .actions(            
                "forward('http://example.com/api/v1/foos/')",
                "stop()")
            .build());

    }
}
Copy
resources:
  # Create a new Mailgun route
  default:
    type: mailgun:Route
    properties:
      priority: '0'
      description: inbound
      expression: match_recipient('.*@foo.example.com')
      actions:
        - forward('http://example.com/api/v1/foos/')
        - stop()
Copy

Create Route Resource

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

Constructor syntax

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

@overload
def Route(resource_name: str,
          opts: Optional[ResourceOptions] = None,
          actions: Optional[Sequence[str]] = None,
          expression: Optional[str] = None,
          priority: Optional[int] = None,
          description: Optional[str] = None,
          region: Optional[str] = None)
func NewRoute(ctx *Context, name string, args RouteArgs, opts ...ResourceOption) (*Route, error)
public Route(string name, RouteArgs args, CustomResourceOptions? opts = null)
public Route(String name, RouteArgs args)
public Route(String name, RouteArgs args, CustomResourceOptions options)
type: mailgun:Route
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. RouteArgs
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. RouteArgs
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. RouteArgs
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. RouteArgs
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. RouteArgs
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 routeResource = new Mailgun.Route("routeResource", new()
{
    Actions = new[]
    {
        "string",
    },
    Expression = "string",
    Priority = 0,
    Description = "string",
    Region = "string",
});
Copy
example, err := mailgun.NewRoute(ctx, "routeResource", &mailgun.RouteArgs{
	Actions: pulumi.StringArray{
		pulumi.String("string"),
	},
	Expression:  pulumi.String("string"),
	Priority:    pulumi.Int(0),
	Description: pulumi.String("string"),
	Region:      pulumi.String("string"),
})
Copy
var routeResource = new Route("routeResource", RouteArgs.builder()
    .actions("string")
    .expression("string")
    .priority(0)
    .description("string")
    .region("string")
    .build());
Copy
route_resource = mailgun.Route("routeResource",
    actions=["string"],
    expression="string",
    priority=0,
    description="string",
    region="string")
Copy
const routeResource = new mailgun.Route("routeResource", {
    actions: ["string"],
    expression: "string",
    priority: 0,
    description: "string",
    region: "string",
});
Copy
type: mailgun:Route
properties:
    actions:
        - string
    description: string
    expression: string
    priority: 0
    region: string
Copy

Route 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 Route resource accepts the following input properties:

Actions This property is required. List<string>
Expression This property is required. string
A filter expression like match_recipient('.*@gmail.com')
Priority This property is required. int
Smaller number indicates higher priority. Higher priority routes are handled first.
Description string
Region Changes to this property will trigger replacement. string
The region where domain will be created. Default value is us.
Actions This property is required. []string
Expression This property is required. string
A filter expression like match_recipient('.*@gmail.com')
Priority This property is required. int
Smaller number indicates higher priority. Higher priority routes are handled first.
Description string
Region Changes to this property will trigger replacement. string
The region where domain will be created. Default value is us.
actions This property is required. List<String>
expression This property is required. String
A filter expression like match_recipient('.*@gmail.com')
priority This property is required. Integer
Smaller number indicates higher priority. Higher priority routes are handled first.
description String
region Changes to this property will trigger replacement. String
The region where domain will be created. Default value is us.
actions This property is required. string[]
expression This property is required. string
A filter expression like match_recipient('.*@gmail.com')
priority This property is required. number
Smaller number indicates higher priority. Higher priority routes are handled first.
description string
region Changes to this property will trigger replacement. string
The region where domain will be created. Default value is us.
actions This property is required. Sequence[str]
expression This property is required. str
A filter expression like match_recipient('.*@gmail.com')
priority This property is required. int
Smaller number indicates higher priority. Higher priority routes are handled first.
description str
region Changes to this property will trigger replacement. str
The region where domain will be created. Default value is us.
actions This property is required. List<String>
expression This property is required. String
A filter expression like match_recipient('.*@gmail.com')
priority This property is required. Number
Smaller number indicates higher priority. Higher priority routes are handled first.
description String
region Changes to this property will trigger replacement. String
The region where domain will be created. Default value is us.

Outputs

All input properties are implicitly available as output properties. Additionally, the Route 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 Route Resource

Get an existing Route 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?: RouteState, opts?: CustomResourceOptions): Route
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        actions: Optional[Sequence[str]] = None,
        description: Optional[str] = None,
        expression: Optional[str] = None,
        priority: Optional[int] = None,
        region: Optional[str] = None) -> Route
func GetRoute(ctx *Context, name string, id IDInput, state *RouteState, opts ...ResourceOption) (*Route, error)
public static Route Get(string name, Input<string> id, RouteState? state, CustomResourceOptions? opts = null)
public static Route get(String name, Output<String> id, RouteState state, CustomResourceOptions options)
resources:  _:    type: mailgun:Route    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:
Actions List<string>
Description string
Expression string
A filter expression like match_recipient('.*@gmail.com')
Priority int
Smaller number indicates higher priority. Higher priority routes are handled first.
Region Changes to this property will trigger replacement. string
The region where domain will be created. Default value is us.
Actions []string
Description string
Expression string
A filter expression like match_recipient('.*@gmail.com')
Priority int
Smaller number indicates higher priority. Higher priority routes are handled first.
Region Changes to this property will trigger replacement. string
The region where domain will be created. Default value is us.
actions List<String>
description String
expression String
A filter expression like match_recipient('.*@gmail.com')
priority Integer
Smaller number indicates higher priority. Higher priority routes are handled first.
region Changes to this property will trigger replacement. String
The region where domain will be created. Default value is us.
actions string[]
description string
expression string
A filter expression like match_recipient('.*@gmail.com')
priority number
Smaller number indicates higher priority. Higher priority routes are handled first.
region Changes to this property will trigger replacement. string
The region where domain will be created. Default value is us.
actions Sequence[str]
description str
expression str
A filter expression like match_recipient('.*@gmail.com')
priority int
Smaller number indicates higher priority. Higher priority routes are handled first.
region Changes to this property will trigger replacement. str
The region where domain will be created. Default value is us.
actions List<String>
description String
expression String
A filter expression like match_recipient('.*@gmail.com')
priority Number
Smaller number indicates higher priority. Higher priority routes are handled first.
region Changes to this property will trigger replacement. String
The region where domain will be created. Default value is us.

Import

Routes can be imported using ROUTE_ID and region via import command. Route ID can be found on Mailgun portal in section Receiving/Routes. Region has to be chosen from eu or us (when no selection us is applied).

hcl

$ pulumi import mailgun:index/route:Route test eu:123456789
Copy

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

Package Details

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