1. Packages
  2. Cloudflare
  3. API Docs
  4. EmailRoutingRule
Cloudflare v5.33.1 published on Wednesday, Jun 26, 2024 by Pulumi

cloudflare.EmailRoutingRule

Explore with Pulumi AI

cloudflare logo
Cloudflare v5.33.1 published on Wednesday, Jun 26, 2024 by Pulumi

    The Email Routing Rule resource allows you to create and manage email routing rules for a zone.

    Example Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as cloudflare from "@pulumi/cloudflare";
    
    const main = new cloudflare.EmailRoutingRule("main", {
        zoneId: "0da42c8d2132a9ddaf714f9e7c920711",
        name: "terraform rule",
        enabled: true,
        matchers: [{
            type: "literal",
            field: "to",
            value: "test@example.com",
        }],
        actions: [{
            type: "forward",
            values: ["destinationaddress@example.net"],
        }],
    });
    
    import pulumi
    import pulumi_cloudflare as cloudflare
    
    main = cloudflare.EmailRoutingRule("main",
        zone_id="0da42c8d2132a9ddaf714f9e7c920711",
        name="terraform rule",
        enabled=True,
        matchers=[cloudflare.EmailRoutingRuleMatcherArgs(
            type="literal",
            field="to",
            value="test@example.com",
        )],
        actions=[cloudflare.EmailRoutingRuleActionArgs(
            type="forward",
            values=["destinationaddress@example.net"],
        )])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-cloudflare/sdk/v5/go/cloudflare"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_, err := cloudflare.NewEmailRoutingRule(ctx, "main", &cloudflare.EmailRoutingRuleArgs{
    			ZoneId:  pulumi.String("0da42c8d2132a9ddaf714f9e7c920711"),
    			Name:    pulumi.String("terraform rule"),
    			Enabled: pulumi.Bool(true),
    			Matchers: cloudflare.EmailRoutingRuleMatcherArray{
    				&cloudflare.EmailRoutingRuleMatcherArgs{
    					Type:  pulumi.String("literal"),
    					Field: pulumi.String("to"),
    					Value: pulumi.String("test@example.com"),
    				},
    			},
    			Actions: cloudflare.EmailRoutingRuleActionArray{
    				&cloudflare.EmailRoutingRuleActionArgs{
    					Type: pulumi.String("forward"),
    					Values: pulumi.StringArray{
    						pulumi.String("destinationaddress@example.net"),
    					},
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    using System.Collections.Generic;
    using System.Linq;
    using Pulumi;
    using Cloudflare = Pulumi.Cloudflare;
    
    return await Deployment.RunAsync(() => 
    {
        var main = new Cloudflare.EmailRoutingRule("main", new()
        {
            ZoneId = "0da42c8d2132a9ddaf714f9e7c920711",
            Name = "terraform rule",
            Enabled = true,
            Matchers = new[]
            {
                new Cloudflare.Inputs.EmailRoutingRuleMatcherArgs
                {
                    Type = "literal",
                    Field = "to",
                    Value = "test@example.com",
                },
            },
            Actions = new[]
            {
                new Cloudflare.Inputs.EmailRoutingRuleActionArgs
                {
                    Type = "forward",
                    Values = new[]
                    {
                        "destinationaddress@example.net",
                    },
                },
            },
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.cloudflare.EmailRoutingRule;
    import com.pulumi.cloudflare.EmailRoutingRuleArgs;
    import com.pulumi.cloudflare.inputs.EmailRoutingRuleMatcherArgs;
    import com.pulumi.cloudflare.inputs.EmailRoutingRuleActionArgs;
    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 main = new EmailRoutingRule("main", EmailRoutingRuleArgs.builder()
                .zoneId("0da42c8d2132a9ddaf714f9e7c920711")
                .name("terraform rule")
                .enabled(true)
                .matchers(EmailRoutingRuleMatcherArgs.builder()
                    .type("literal")
                    .field("to")
                    .value("test@example.com")
                    .build())
                .actions(EmailRoutingRuleActionArgs.builder()
                    .type("forward")
                    .values("destinationaddress@example.net")
                    .build())
                .build());
    
        }
    }
    
    resources:
      main:
        type: cloudflare:EmailRoutingRule
        properties:
          zoneId: 0da42c8d2132a9ddaf714f9e7c920711
          name: terraform rule
          enabled: true
          matchers:
            - type: literal
              field: to
              value: test@example.com
          actions:
            - type: forward
              values:
                - destinationaddress@example.net
    

    Create EmailRoutingRule Resource

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

    Constructor syntax

    new EmailRoutingRule(name: string, args: EmailRoutingRuleArgs, opts?: CustomResourceOptions);
    @overload
    def EmailRoutingRule(resource_name: str,
                         args: EmailRoutingRuleArgs,
                         opts: Optional[ResourceOptions] = None)
    
    @overload
    def EmailRoutingRule(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         name: Optional[str] = None,
                         zone_id: Optional[str] = None,
                         actions: Optional[Sequence[EmailRoutingRuleActionArgs]] = None,
                         enabled: Optional[bool] = None,
                         matchers: Optional[Sequence[EmailRoutingRuleMatcherArgs]] = None,
                         priority: Optional[int] = None)
    func NewEmailRoutingRule(ctx *Context, name string, args EmailRoutingRuleArgs, opts ...ResourceOption) (*EmailRoutingRule, error)
    public EmailRoutingRule(string name, EmailRoutingRuleArgs args, CustomResourceOptions? opts = null)
    public EmailRoutingRule(String name, EmailRoutingRuleArgs args)
    public EmailRoutingRule(String name, EmailRoutingRuleArgs args, CustomResourceOptions options)
    
    type: cloudflare:EmailRoutingRule
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args EmailRoutingRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args EmailRoutingRuleArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args EmailRoutingRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args EmailRoutingRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args EmailRoutingRuleArgs
    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 emailRoutingRuleResource = new Cloudflare.EmailRoutingRule("emailRoutingRuleResource", new()
    {
        Name = "string",
        ZoneId = "string",
        Actions = new[]
        {
            new Cloudflare.Inputs.EmailRoutingRuleActionArgs
            {
                Type = "string",
                Values = new[]
                {
                    "string",
                },
            },
        },
        Enabled = false,
        Matchers = new[]
        {
            new Cloudflare.Inputs.EmailRoutingRuleMatcherArgs
            {
                Type = "string",
                Field = "string",
                Value = "string",
            },
        },
        Priority = 0,
    });
    
    example, err := cloudflare.NewEmailRoutingRule(ctx, "emailRoutingRuleResource", &cloudflare.EmailRoutingRuleArgs{
    	Name:   pulumi.String("string"),
    	ZoneId: pulumi.String("string"),
    	Actions: cloudflare.EmailRoutingRuleActionArray{
    		&cloudflare.EmailRoutingRuleActionArgs{
    			Type: pulumi.String("string"),
    			Values: pulumi.StringArray{
    				pulumi.String("string"),
    			},
    		},
    	},
    	Enabled: pulumi.Bool(false),
    	Matchers: cloudflare.EmailRoutingRuleMatcherArray{
    		&cloudflare.EmailRoutingRuleMatcherArgs{
    			Type:  pulumi.String("string"),
    			Field: pulumi.String("string"),
    			Value: pulumi.String("string"),
    		},
    	},
    	Priority: pulumi.Int(0),
    })
    
    var emailRoutingRuleResource = new EmailRoutingRule("emailRoutingRuleResource", EmailRoutingRuleArgs.builder()
        .name("string")
        .zoneId("string")
        .actions(EmailRoutingRuleActionArgs.builder()
            .type("string")
            .values("string")
            .build())
        .enabled(false)
        .matchers(EmailRoutingRuleMatcherArgs.builder()
            .type("string")
            .field("string")
            .value("string")
            .build())
        .priority(0)
        .build());
    
    email_routing_rule_resource = cloudflare.EmailRoutingRule("emailRoutingRuleResource",
        name="string",
        zone_id="string",
        actions=[cloudflare.EmailRoutingRuleActionArgs(
            type="string",
            values=["string"],
        )],
        enabled=False,
        matchers=[cloudflare.EmailRoutingRuleMatcherArgs(
            type="string",
            field="string",
            value="string",
        )],
        priority=0)
    
    const emailRoutingRuleResource = new cloudflare.EmailRoutingRule("emailRoutingRuleResource", {
        name: "string",
        zoneId: "string",
        actions: [{
            type: "string",
            values: ["string"],
        }],
        enabled: false,
        matchers: [{
            type: "string",
            field: "string",
            value: "string",
        }],
        priority: 0,
    });
    
    type: cloudflare:EmailRoutingRule
    properties:
        actions:
            - type: string
              values:
                - string
        enabled: false
        matchers:
            - field: string
              type: string
              value: string
        name: string
        priority: 0
        zoneId: string
    

    EmailRoutingRule Resource Properties

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

    Inputs

    The EmailRoutingRule resource accepts the following input properties:

    Name string
    Routing rule name.
    ZoneId string
    The zone identifier to target for the resource.
    Actions List<EmailRoutingRuleAction>
    Actions to take when a match is found.
    Enabled bool
    Whether the email routing rule is enabled.
    Matchers List<EmailRoutingRuleMatcher>
    Matching patterns to forward to your actions.
    Priority int
    The priority of the email routing rule.
    Name string
    Routing rule name.
    ZoneId string
    The zone identifier to target for the resource.
    Actions []EmailRoutingRuleActionArgs
    Actions to take when a match is found.
    Enabled bool
    Whether the email routing rule is enabled.
    Matchers []EmailRoutingRuleMatcherArgs
    Matching patterns to forward to your actions.
    Priority int
    The priority of the email routing rule.
    name String
    Routing rule name.
    zoneId String
    The zone identifier to target for the resource.
    actions List<EmailRoutingRuleAction>
    Actions to take when a match is found.
    enabled Boolean
    Whether the email routing rule is enabled.
    matchers List<EmailRoutingRuleMatcher>
    Matching patterns to forward to your actions.
    priority Integer
    The priority of the email routing rule.
    name string
    Routing rule name.
    zoneId string
    The zone identifier to target for the resource.
    actions EmailRoutingRuleAction[]
    Actions to take when a match is found.
    enabled boolean
    Whether the email routing rule is enabled.
    matchers EmailRoutingRuleMatcher[]
    Matching patterns to forward to your actions.
    priority number
    The priority of the email routing rule.
    name str
    Routing rule name.
    zone_id str
    The zone identifier to target for the resource.
    actions Sequence[EmailRoutingRuleActionArgs]
    Actions to take when a match is found.
    enabled bool
    Whether the email routing rule is enabled.
    matchers Sequence[EmailRoutingRuleMatcherArgs]
    Matching patterns to forward to your actions.
    priority int
    The priority of the email routing rule.
    name String
    Routing rule name.
    zoneId String
    The zone identifier to target for the resource.
    actions List<Property Map>
    Actions to take when a match is found.
    enabled Boolean
    Whether the email routing rule is enabled.
    matchers List<Property Map>
    Matching patterns to forward to your actions.
    priority Number
    The priority of the email routing rule.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Tag string
    The tag of the email routing rule.
    Id string
    The provider-assigned unique ID for this managed resource.
    Tag string
    The tag of the email routing rule.
    id String
    The provider-assigned unique ID for this managed resource.
    tag String
    The tag of the email routing rule.
    id string
    The provider-assigned unique ID for this managed resource.
    tag string
    The tag of the email routing rule.
    id str
    The provider-assigned unique ID for this managed resource.
    tag str
    The tag of the email routing rule.
    id String
    The provider-assigned unique ID for this managed resource.
    tag String
    The tag of the email routing rule.

    Look up Existing EmailRoutingRule Resource

    Get an existing EmailRoutingRule 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?: EmailRoutingRuleState, opts?: CustomResourceOptions): EmailRoutingRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            actions: Optional[Sequence[EmailRoutingRuleActionArgs]] = None,
            enabled: Optional[bool] = None,
            matchers: Optional[Sequence[EmailRoutingRuleMatcherArgs]] = None,
            name: Optional[str] = None,
            priority: Optional[int] = None,
            tag: Optional[str] = None,
            zone_id: Optional[str] = None) -> EmailRoutingRule
    func GetEmailRoutingRule(ctx *Context, name string, id IDInput, state *EmailRoutingRuleState, opts ...ResourceOption) (*EmailRoutingRule, error)
    public static EmailRoutingRule Get(string name, Input<string> id, EmailRoutingRuleState? state, CustomResourceOptions? opts = null)
    public static EmailRoutingRule get(String name, Output<String> id, EmailRoutingRuleState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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<EmailRoutingRuleAction>
    Actions to take when a match is found.
    Enabled bool
    Whether the email routing rule is enabled.
    Matchers List<EmailRoutingRuleMatcher>
    Matching patterns to forward to your actions.
    Name string
    Routing rule name.
    Priority int
    The priority of the email routing rule.
    Tag string
    The tag of the email routing rule.
    ZoneId string
    The zone identifier to target for the resource.
    Actions []EmailRoutingRuleActionArgs
    Actions to take when a match is found.
    Enabled bool
    Whether the email routing rule is enabled.
    Matchers []EmailRoutingRuleMatcherArgs
    Matching patterns to forward to your actions.
    Name string
    Routing rule name.
    Priority int
    The priority of the email routing rule.
    Tag string
    The tag of the email routing rule.
    ZoneId string
    The zone identifier to target for the resource.
    actions List<EmailRoutingRuleAction>
    Actions to take when a match is found.
    enabled Boolean
    Whether the email routing rule is enabled.
    matchers List<EmailRoutingRuleMatcher>
    Matching patterns to forward to your actions.
    name String
    Routing rule name.
    priority Integer
    The priority of the email routing rule.
    tag String
    The tag of the email routing rule.
    zoneId String
    The zone identifier to target for the resource.
    actions EmailRoutingRuleAction[]
    Actions to take when a match is found.
    enabled boolean
    Whether the email routing rule is enabled.
    matchers EmailRoutingRuleMatcher[]
    Matching patterns to forward to your actions.
    name string
    Routing rule name.
    priority number
    The priority of the email routing rule.
    tag string
    The tag of the email routing rule.
    zoneId string
    The zone identifier to target for the resource.
    actions Sequence[EmailRoutingRuleActionArgs]
    Actions to take when a match is found.
    enabled bool
    Whether the email routing rule is enabled.
    matchers Sequence[EmailRoutingRuleMatcherArgs]
    Matching patterns to forward to your actions.
    name str
    Routing rule name.
    priority int
    The priority of the email routing rule.
    tag str
    The tag of the email routing rule.
    zone_id str
    The zone identifier to target for the resource.
    actions List<Property Map>
    Actions to take when a match is found.
    enabled Boolean
    Whether the email routing rule is enabled.
    matchers List<Property Map>
    Matching patterns to forward to your actions.
    name String
    Routing rule name.
    priority Number
    The priority of the email routing rule.
    tag String
    The tag of the email routing rule.
    zoneId String
    The zone identifier to target for the resource.

    Supporting Types

    EmailRoutingRuleAction, EmailRoutingRuleActionArgs

    Type string
    Type of action. Available values: forward, worker, drop
    Values List<string>
    Value to match on. Required for type of literal.
    Type string
    Type of action. Available values: forward, worker, drop
    Values []string
    Value to match on. Required for type of literal.
    type String
    Type of action. Available values: forward, worker, drop
    values List<String>
    Value to match on. Required for type of literal.
    type string
    Type of action. Available values: forward, worker, drop
    values string[]
    Value to match on. Required for type of literal.
    type str
    Type of action. Available values: forward, worker, drop
    values Sequence[str]
    Value to match on. Required for type of literal.
    type String
    Type of action. Available values: forward, worker, drop
    values List<String>
    Value to match on. Required for type of literal.

    EmailRoutingRuleMatcher, EmailRoutingRuleMatcherArgs

    Type string
    Type of matcher. Available values: literal, all
    Field string
    Field to match on. Required for type of literal.
    Value string
    Value to match on. Required for type of literal.
    Type string
    Type of matcher. Available values: literal, all
    Field string
    Field to match on. Required for type of literal.
    Value string
    Value to match on. Required for type of literal.
    type String
    Type of matcher. Available values: literal, all
    field String
    Field to match on. Required for type of literal.
    value String
    Value to match on. Required for type of literal.
    type string
    Type of matcher. Available values: literal, all
    field string
    Field to match on. Required for type of literal.
    value string
    Value to match on. Required for type of literal.
    type str
    Type of matcher. Available values: literal, all
    field str
    Field to match on. Required for type of literal.
    value str
    Value to match on. Required for type of literal.
    type String
    Type of matcher. Available values: literal, all
    field String
    Field to match on. Required for type of literal.
    value String
    Value to match on. Required for type of literal.

    Import

    $ pulumi import cloudflare:index/emailRoutingRule:EmailRoutingRule example <zone_id>/<email_routing_rule_id>
    

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

    Package Details

    Repository
    Cloudflare pulumi/pulumi-cloudflare
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the cloudflare Terraform Provider.
    cloudflare logo
    Cloudflare v5.33.1 published on Wednesday, Jun 26, 2024 by Pulumi