1. Packages
  2. AWS Classic
  3. API Docs
  4. apigateway
  5. BasePathMapping

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.13.0 published on Saturday, Dec 2, 2023 by Pulumi

aws.apigateway.BasePathMapping

Explore with Pulumi AI

aws logo

Try AWS Native preview for resources not in the classic version.

AWS Classic v6.13.0 published on Saturday, Dec 2, 2023 by Pulumi

    Connects a custom domain name registered via aws.apigateway.DomainName with a deployed API so that its methods can be called via the custom domain name.

    Example Usage

    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using Pulumi;
    using Aws = Pulumi.Aws;
    
    return await Deployment.RunAsync(() => 
    {
        var exampleStage = new Aws.ApiGateway.Stage("exampleStage", new()
        {
            Deployment = aws_api_gateway_deployment.Example.Id,
            RestApi = aws_api_gateway_rest_api.Example.Id,
            StageName = "example",
        });
    
        var exampleDomainName = new Aws.ApiGateway.DomainName("exampleDomainName", new()
        {
            Domain = "example.com",
            CertificateName = "example-api",
            CertificateBody = File.ReadAllText($"{path.Module}/example.com/example.crt"),
            CertificateChain = File.ReadAllText($"{path.Module}/example.com/ca.crt"),
            CertificatePrivateKey = File.ReadAllText($"{path.Module}/example.com/example.key"),
        });
    
        var exampleBasePathMapping = new Aws.ApiGateway.BasePathMapping("exampleBasePathMapping", new()
        {
            RestApi = aws_api_gateway_rest_api.Example.Id,
            StageName = exampleStage.StageName,
            DomainName = exampleDomainName.Domain,
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    	"os"
    
    	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/apigateway"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func readFileOrPanic(path string) pulumi.StringPtrInput {
    	data, err := os.ReadFile(path)
    	if err != nil {
    		panic(err.Error())
    	}
    	return pulumi.String(string(data))
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		exampleStage, err := apigateway.NewStage(ctx, "exampleStage", &apigateway.StageArgs{
    			Deployment: pulumi.Any(aws_api_gateway_deployment.Example.Id),
    			RestApi:    pulumi.Any(aws_api_gateway_rest_api.Example.Id),
    			StageName:  pulumi.String("example"),
    		})
    		if err != nil {
    			return err
    		}
    		exampleDomainName, err := apigateway.NewDomainName(ctx, "exampleDomainName", &apigateway.DomainNameArgs{
    			DomainName:            pulumi.String("example.com"),
    			CertificateName:       pulumi.String("example-api"),
    			CertificateBody:       readFileOrPanic(fmt.Sprintf("%v/example.com/example.crt", path.Module)),
    			CertificateChain:      readFileOrPanic(fmt.Sprintf("%v/example.com/ca.crt", path.Module)),
    			CertificatePrivateKey: readFileOrPanic(fmt.Sprintf("%v/example.com/example.key", path.Module)),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = apigateway.NewBasePathMapping(ctx, "exampleBasePathMapping", &apigateway.BasePathMappingArgs{
    			RestApi:    pulumi.Any(aws_api_gateway_rest_api.Example.Id),
    			StageName:  exampleStage.StageName,
    			DomainName: exampleDomainName.DomainName,
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.aws.apigateway.Stage;
    import com.pulumi.aws.apigateway.StageArgs;
    import com.pulumi.aws.apigateway.DomainName;
    import com.pulumi.aws.apigateway.DomainNameArgs;
    import com.pulumi.aws.apigateway.BasePathMapping;
    import com.pulumi.aws.apigateway.BasePathMappingArgs;
    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 exampleStage = new Stage("exampleStage", StageArgs.builder()        
                .deployment(aws_api_gateway_deployment.example().id())
                .restApi(aws_api_gateway_rest_api.example().id())
                .stageName("example")
                .build());
    
            var exampleDomainName = new DomainName("exampleDomainName", DomainNameArgs.builder()        
                .domainName("example.com")
                .certificateName("example-api")
                .certificateBody(Files.readString(Paths.get(String.format("%s/example.com/example.crt", path.module()))))
                .certificateChain(Files.readString(Paths.get(String.format("%s/example.com/ca.crt", path.module()))))
                .certificatePrivateKey(Files.readString(Paths.get(String.format("%s/example.com/example.key", path.module()))))
                .build());
    
            var exampleBasePathMapping = new BasePathMapping("exampleBasePathMapping", BasePathMappingArgs.builder()        
                .restApi(aws_api_gateway_rest_api.example().id())
                .stageName(exampleStage.stageName())
                .domainName(exampleDomainName.domainName())
                .build());
    
        }
    }
    
    import pulumi
    import pulumi_aws as aws
    
    example_stage = aws.apigateway.Stage("exampleStage",
        deployment=aws_api_gateway_deployment["example"]["id"],
        rest_api=aws_api_gateway_rest_api["example"]["id"],
        stage_name="example")
    example_domain_name = aws.apigateway.DomainName("exampleDomainName",
        domain_name="example.com",
        certificate_name="example-api",
        certificate_body=(lambda path: open(path).read())(f"{path['module']}/example.com/example.crt"),
        certificate_chain=(lambda path: open(path).read())(f"{path['module']}/example.com/ca.crt"),
        certificate_private_key=(lambda path: open(path).read())(f"{path['module']}/example.com/example.key"))
    example_base_path_mapping = aws.apigateway.BasePathMapping("exampleBasePathMapping",
        rest_api=aws_api_gateway_rest_api["example"]["id"],
        stage_name=example_stage.stage_name,
        domain_name=example_domain_name.domain_name)
    
    import * as pulumi from "@pulumi/pulumi";
    import * as aws from "@pulumi/aws";
    import * as fs from "fs";
    
    const exampleStage = new aws.apigateway.Stage("exampleStage", {
        deployment: aws_api_gateway_deployment.example.id,
        restApi: aws_api_gateway_rest_api.example.id,
        stageName: "example",
    });
    const exampleDomainName = new aws.apigateway.DomainName("exampleDomainName", {
        domainName: "example.com",
        certificateName: "example-api",
        certificateBody: fs.readFileSync(`${path.module}/example.com/example.crt`),
        certificateChain: fs.readFileSync(`${path.module}/example.com/ca.crt`),
        certificatePrivateKey: fs.readFileSync(`${path.module}/example.com/example.key`),
    });
    const exampleBasePathMapping = new aws.apigateway.BasePathMapping("exampleBasePathMapping", {
        restApi: aws_api_gateway_rest_api.example.id,
        stageName: exampleStage.stageName,
        domainName: exampleDomainName.domainName,
    });
    
    resources:
      exampleStage:
        type: aws:apigateway:Stage
        properties:
          deployment: ${aws_api_gateway_deployment.example.id}
          restApi: ${aws_api_gateway_rest_api.example.id}
          stageName: example
      exampleDomainName:
        type: aws:apigateway:DomainName
        properties:
          domainName: example.com
          certificateName: example-api
          certificateBody:
            fn::readFile: ${path.module}/example.com/example.crt
          certificateChain:
            fn::readFile: ${path.module}/example.com/ca.crt
          certificatePrivateKey:
            fn::readFile: ${path.module}/example.com/example.key
      exampleBasePathMapping:
        type: aws:apigateway:BasePathMapping
        properties:
          restApi: ${aws_api_gateway_rest_api.example.id}
          stageName: ${exampleStage.stageName}
          domainName: ${exampleDomainName.domainName}
    

    Create BasePathMapping Resource

    new BasePathMapping(name: string, args: BasePathMappingArgs, opts?: CustomResourceOptions);
    @overload
    def BasePathMapping(resource_name: str,
                        opts: Optional[ResourceOptions] = None,
                        base_path: Optional[str] = None,
                        domain_name: Optional[str] = None,
                        rest_api: Optional[str] = None,
                        stage_name: Optional[str] = None)
    @overload
    def BasePathMapping(resource_name: str,
                        args: BasePathMappingArgs,
                        opts: Optional[ResourceOptions] = None)
    func NewBasePathMapping(ctx *Context, name string, args BasePathMappingArgs, opts ...ResourceOption) (*BasePathMapping, error)
    public BasePathMapping(string name, BasePathMappingArgs args, CustomResourceOptions? opts = null)
    public BasePathMapping(String name, BasePathMappingArgs args)
    public BasePathMapping(String name, BasePathMappingArgs args, CustomResourceOptions options)
    
    type: aws:apigateway:BasePathMapping
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    
    name string
    The unique name of the resource.
    args BasePathMappingArgs
    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 BasePathMappingArgs
    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 BasePathMappingArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args BasePathMappingArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args BasePathMappingArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

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

    DomainName string

    Already-registered domain name to connect the API to.

    RestApi string | string

    ID of the API to connect.

    BasePath string

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    StageName string

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    DomainName string

    Already-registered domain name to connect the API to.

    RestApi string | string

    ID of the API to connect.

    BasePath string

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    StageName string

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    domainName String

    Already-registered domain name to connect the API to.

    restApi String | String

    ID of the API to connect.

    basePath String

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    stageName String

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    domainName string

    Already-registered domain name to connect the API to.

    restApi string | RestApi

    ID of the API to connect.

    basePath string

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    stageName string

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    domain_name str

    Already-registered domain name to connect the API to.

    rest_api str | str

    ID of the API to connect.

    base_path str

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    stage_name str

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    domainName String

    Already-registered domain name to connect the API to.

    restApi String |

    ID of the API to connect.

    basePath String

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    stageName String

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    Outputs

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

    Get an existing BasePathMapping 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?: BasePathMappingState, opts?: CustomResourceOptions): BasePathMapping
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            base_path: Optional[str] = None,
            domain_name: Optional[str] = None,
            rest_api: Optional[str] = None,
            stage_name: Optional[str] = None) -> BasePathMapping
    func GetBasePathMapping(ctx *Context, name string, id IDInput, state *BasePathMappingState, opts ...ResourceOption) (*BasePathMapping, error)
    public static BasePathMapping Get(string name, Input<string> id, BasePathMappingState? state, CustomResourceOptions? opts = null)
    public static BasePathMapping get(String name, Output<String> id, BasePathMappingState 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:
    BasePath string

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    DomainName string

    Already-registered domain name to connect the API to.

    RestApi string | string

    ID of the API to connect.

    StageName string

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    BasePath string

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    DomainName string

    Already-registered domain name to connect the API to.

    RestApi string | string

    ID of the API to connect.

    StageName string

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    basePath String

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    domainName String

    Already-registered domain name to connect the API to.

    restApi String | String

    ID of the API to connect.

    stageName String

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    basePath string

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    domainName string

    Already-registered domain name to connect the API to.

    restApi string | RestApi

    ID of the API to connect.

    stageName string

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    base_path str

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    domain_name str

    Already-registered domain name to connect the API to.

    rest_api str | str

    ID of the API to connect.

    stage_name str

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    basePath String

    Path segment that must be prepended to the path when accessing the API via this mapping. If omitted, the API is exposed at the root of the given domain.

    domainName String

    Already-registered domain name to connect the API to.

    restApi String |

    ID of the API to connect.

    stageName String

    Name of a specific deployment stage to expose at the given path. If omitted, callers may select any stage by including its name as a path element after the base path.

    Import

    For a non-root base_path:

    Using pulumi import, import aws_api_gateway_base_path_mapping using the domain name and base path. For example:

    For an empty base_path or, in other words, a root path (/):

     $ pulumi import aws:apigateway/basePathMapping:BasePathMapping example example.com/
    

    For a non-root base_path:

     $ pulumi import aws:apigateway/basePathMapping:BasePathMapping example example.com/base-path
    

    Package Details

    Repository
    AWS Classic pulumi/pulumi-aws
    License
    Apache-2.0
    Notes

    This Pulumi package is based on the aws Terraform Provider.

    aws logo

    Try AWS Native preview for resources not in the classic version.

    AWS Classic v6.13.0 published on Saturday, Dec 2, 2023 by Pulumi