RoutingRule class

Resource for managing an AWS API Gateway V2 Routing Rule.

Example Usage

Basic Usage

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

const example = new aws.apigatewayv2.RoutingRule("example", {
    actions: [{
        invokeApi: {
            apiId: "example-api-id",
            stage: "example-stage",
            stripBasePath: true,
        },
    }],
    conditions: [{
        matchHeaders: {
            anyOf: {
                header: "X-Example-Header",
                valueGlob: "example-value-*",
            },
        },
        matchBasePaths: {
            anyOfs: [
                "example-path",
                "another-path",
            ],
        },
    }],
    domainName: "test.example.com",
    priority: 1,
});
import pulumi
import pulumi_aws as aws

example = aws.apigatewayv2.RoutingRule("example",
    actions=[{
        "invoke_api": {
            "api_id": "example-api-id",
            "stage": "example-stage",
            "strip_base_path": True,
        },
    }],
    conditions=[{
        "match_headers": {
            "any_of": {
                "header": "X-Example-Header",
                "value_glob": "example-value-*",
            },
        },
        "match_base_paths": {
            "any_ofs": [
                "example-path",
                "another-path",
            ],
        },
    }],
    domain_name="test.example.com",
    priority=1)
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() =>
{
    var example = new Aws.ApiGatewayV2.RoutingRule("example", new()
    {
        Actions = new[]
        {
            new Aws.ApiGatewayV2.Inputs.RoutingRuleActionArgs
            {
                InvokeApi = new Aws.ApiGatewayV2.Inputs.RoutingRuleActionInvokeApiArgs
                {
                    ApiId = "example-api-id",
                    Stage = "example-stage",
                    StripBasePath = true,
                },
            },
        },
        Conditions = new[]
        {
            new Aws.ApiGatewayV2.Inputs.RoutingRuleConditionArgs
            {
                MatchHeaders = new Aws.ApiGatewayV2.Inputs.RoutingRuleConditionMatchHeadersArgs
                {
                    AnyOf = new Aws.ApiGatewayV2.Inputs.RoutingRuleConditionMatchHeadersAnyOfArgs
                    {
                        Header = "X-Example-Header",
                        ValueGlob = "example-value-*",
                    },
                },
                MatchBasePaths = new Aws.ApiGatewayV2.Inputs.RoutingRuleConditionMatchBasePathsArgs
                {
                    AnyOfs = new[]
                    {
                        "example-path",
                        "another-path",
                    },
                },
            },
        },
        DomainName = "test.example.com",
        Priority = 1,
    });

});
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/apigatewayv2"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := apigatewayv2.NewRoutingRule(ctx, "example", &apigatewayv2.RoutingRuleArgs{
			Actions: apigatewayv2.RoutingRuleActionArray{
				&apigatewayv2.RoutingRuleActionArgs{
					InvokeApi: &apigatewayv2.RoutingRuleActionInvokeApiArgs{
						ApiId:         pulumi.String("example-api-id"),
						Stage:         pulumi.String("example-stage"),
						StripBasePath: pulumi.Bool(true),
					},
				},
			},
			Conditions: apigatewayv2.RoutingRuleConditionArray{
				&apigatewayv2.RoutingRuleConditionArgs{
					MatchHeaders: &apigatewayv2.RoutingRuleConditionMatchHeadersArgs{
						AnyOf: &apigatewayv2.RoutingRuleConditionMatchHeadersAnyOfArgs{
							Header:    pulumi.String("X-Example-Header"),
							ValueGlob: pulumi.String("example-value-*"),
						},
					},
					MatchBasePaths: &apigatewayv2.RoutingRuleConditionMatchBasePathsArgs{
						AnyOfs: pulumi.StringArray{
							pulumi.String("example-path"),
							pulumi.String("another-path"),
						},
					},
				},
			},
			DomainName: pulumi.String("test.example.com"),
			Priority:   pulumi.Int(1),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
pulumi {
  required_providers {
    aws = {
      source = "pulumi/aws"
    }
  }
}

resource "aws_apigatewayv2_routingrule" "example" {
  actions {
    invoke_api = {
      api_id          = "example-api-id"
      stage           = "example-stage"
      strip_base_path = true
    }
  }
  conditions {
    match_headers = {
      any_of = {
        header     = "X-Example-Header"
        value_glob = "example-value-*"
      }
    }
    match_base_paths = {
      any_ofs = ["example-path", "another-path"]
    }
  }
  domain_name = "test.example.com"
  priority    = 1
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigatewayv2.RoutingRule;
import com.pulumi.aws.apigatewayv2.RoutingRuleArgs;
import com.pulumi.aws.apigatewayv2.inputs.RoutingRuleActionArgs;
import com.pulumi.aws.apigatewayv2.inputs.RoutingRuleActionInvokeApiArgs;
import com.pulumi.aws.apigatewayv2.inputs.RoutingRuleConditionArgs;
import com.pulumi.aws.apigatewayv2.inputs.RoutingRuleConditionMatchHeadersArgs;
import com.pulumi.aws.apigatewayv2.inputs.RoutingRuleConditionMatchHeadersAnyOfArgs;
import com.pulumi.aws.apigatewayv2.inputs.RoutingRuleConditionMatchBasePathsArgs;
import java.util.ArrayList;
import java.util.Arrays;
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 example = new RoutingRule("example", RoutingRuleArgs.builder()
            .actions(RoutingRuleActionArgs.builder()
                .invokeApi(RoutingRuleActionInvokeApiArgs.builder()
                    .apiId("example-api-id")
                    .stage("example-stage")
                    .stripBasePath(true)
                    .build())
                .build())
            .conditions(RoutingRuleConditionArgs.builder()
                .matchHeaders(RoutingRuleConditionMatchHeadersArgs.builder()
                    .anyOf(RoutingRuleConditionMatchHeadersAnyOfArgs.builder()
                        .header("X-Example-Header")
                        .valueGlob("example-value-*")
                        .build())
                    .build())
                .matchBasePaths(RoutingRuleConditionMatchBasePathsArgs.builder()
                    .anyOfs(
                        "example-path",
                        "another-path")
                    .build())
                .build())
            .domainName("test.example.com")
            .priority(1)
            .build());

    }
}
resources:
  example:
    type: aws:apigatewayv2:RoutingRule
    properties:
      actions:
        - invokeApi:
            apiId: example-api-id
            stage: example-stage
            stripBasePath: true
      conditions:
        - matchHeaders:
            anyOf:
              header: X-Example-Header
              valueGlob: example-value-*
          matchBasePaths:
            anyOfs:
              - example-path
              - another-path
      domainName: test.example.com
      priority: 1

Import

Using pulumi import, import API Gateway V2 Routing Rule using the routingRuleArn. For example:

$ pulumi import aws:apigatewayv2/routingRule:RoutingRule example arn:aws:apigateway:us-east-1:123456789012:/domainnames/example.com/routingrules/rule1

Constructors

RoutingRule(String name, {RoutingRuleArgs? args, CustomResourceOptions? options})
Creates a new RoutingRule. name The Pulumi resource name. args Arguments used to configure this RoutingRule. The set of arguments for RoutingRule. options Resource options controlling this resource's behavior.
RoutingRule.reference(String urn)
Creates a typed reference to an existing RoutingRule resource.

Properties

actions ↔ Output<List<RoutingRuleAction>>
Configuration of resulting action based on matching routing rules condition. See below.
latefinal
childResources → Set<Resource>
finalinherited
completionSources ↔ Map<String, IOutputCompletionSource>
latefinalinherited
conditions ↔ Output<List<RoutingRuleCondition>>
Conditions configuration. See below.
latefinal
domainName ↔ Output<String>
Domain name. Must be between 1 and 512 characters in length.
latefinal
hashCode → int
The hash code for this object.
no setterinherited
id ↔ Output<String>
getter/setter pairinherited
isCustom → bool
Returns whether this resource is provider-managed.
no setterinherited
isProtected → bool
Returns whether this resource is protected from deletion.
no setterinherited
isRemote → bool
Whether this resource is registered as remote.
no setterinherited
isResourceReference → bool
Whether this instance represents a resource value returned over RPC.
finalinherited
priority ↔ Output<int>
Order of rule evaluation. Priority is evaluated from the lowest value to the highest value. Rules can't have the same priority. Value must be between 1 and 1,000,000.
latefinal
region ↔ Output<String>
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
resourceTransforms → List<ResourceTransform>
Inherited/explicit async transforms.
no setterinherited
routingRuleArn ↔ Output<String>
ARN of the Routing Rule.
latefinal
routingRuleId ↔ Output<String>
ID of the Routing Rule.
latefinal
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
transformations → List<ResourceTransformation>
Inherited/explicit legacy transformations.
no setterinherited
urn ↔ Output<String>
latefinalinherited

Methods

failId(Object error) → void
Completes this resource ID with an error when registration fails.
inherited
failOutputs(Object error) → void
Completes all output properties with error.
inherited
failUrn(Object error) → void
Completes this resource URN with an error when registration fails.
inherited
getProvider(String moduleMember) → ProviderResource?
Returns provider for moduleMember's package, if configured.
inherited
getResourceName() → String
Returns this resource's logical name.
inherited
getResourceType() → String
Returns this resource's Pulumi type token.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerOutput<T>(String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output<T>
Registers a dynamic output property for this resource.
inherited
resolveId(String? value, {required bool isKnown}) → void
Resolves the provider-assigned ID for this resource.
inherited
resolveOutputs(Struct outputs) → void
Resolves all output properties from a monitor response payload.
inherited
resolveUrn(String value) → void
Resolves this resource's URN once assigned by the engine.
inherited
serializeProperties(Map<String, dynamic> properties) → Future<Struct>
Serializes resource properties for RPC transmission.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

get(String name, Input<String> id, {RoutingRuleState? state, CustomResourceOptions? options}) → RoutingRule
Gets an existing RoutingRule resource's state with the given name and id.