1. Packages
  2. AWS
  3. API Docs
  4. apigatewayv2
  5. ApiMapping
AWS v6.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

aws.apigatewayv2.ApiMapping

Explore with Pulumi AI

Manages an Amazon API Gateway Version 2 API mapping. More information can be found in the Amazon API Gateway Developer Guide.

Example Usage

Basic

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

const example = new aws.apigatewayv2.ApiMapping("example", {
    apiId: exampleAwsApigatewayv2Api.id,
    domainName: exampleAwsApigatewayv2DomainName.id,
    stage: exampleAwsApigatewayv2Stage.id,
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.apigatewayv2.ApiMapping("example",
    api_id=example_aws_apigatewayv2_api["id"],
    domain_name=example_aws_apigatewayv2_domain_name["id"],
    stage=example_aws_apigatewayv2_stage["id"])
Copy
package main

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

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := apigatewayv2.NewApiMapping(ctx, "example", &apigatewayv2.ApiMappingArgs{
			ApiId:      pulumi.Any(exampleAwsApigatewayv2Api.Id),
			DomainName: pulumi.Any(exampleAwsApigatewayv2DomainName.Id),
			Stage:      pulumi.Any(exampleAwsApigatewayv2Stage.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.ApiGatewayV2.ApiMapping("example", new()
    {
        ApiId = exampleAwsApigatewayv2Api.Id,
        DomainName = exampleAwsApigatewayv2DomainName.Id,
        Stage = exampleAwsApigatewayv2Stage.Id,
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigatewayv2.ApiMapping;
import com.pulumi.aws.apigatewayv2.ApiMappingArgs;
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 example = new ApiMapping("example", ApiMappingArgs.builder()
            .apiId(exampleAwsApigatewayv2Api.id())
            .domainName(exampleAwsApigatewayv2DomainName.id())
            .stage(exampleAwsApigatewayv2Stage.id())
            .build());

    }
}
Copy
resources:
  example:
    type: aws:apigatewayv2:ApiMapping
    properties:
      apiId: ${exampleAwsApigatewayv2Api.id}
      domainName: ${exampleAwsApigatewayv2DomainName.id}
      stage: ${exampleAwsApigatewayv2Stage.id}
Copy

Create ApiMapping Resource

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

Constructor syntax

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

@overload
def ApiMapping(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               api_id: Optional[str] = None,
               domain_name: Optional[str] = None,
               stage: Optional[str] = None,
               api_mapping_key: Optional[str] = None)
func NewApiMapping(ctx *Context, name string, args ApiMappingArgs, opts ...ResourceOption) (*ApiMapping, error)
public ApiMapping(string name, ApiMappingArgs args, CustomResourceOptions? opts = null)
public ApiMapping(String name, ApiMappingArgs args)
public ApiMapping(String name, ApiMappingArgs args, CustomResourceOptions options)
type: aws:apigatewayv2:ApiMapping
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. ApiMappingArgs
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. ApiMappingArgs
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. ApiMappingArgs
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. ApiMappingArgs
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. ApiMappingArgs
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 apiMappingResource = new Aws.ApiGatewayV2.ApiMapping("apiMappingResource", new()
{
    ApiId = "string",
    DomainName = "string",
    Stage = "string",
    ApiMappingKey = "string",
});
Copy
example, err := apigatewayv2.NewApiMapping(ctx, "apiMappingResource", &apigatewayv2.ApiMappingArgs{
	ApiId:         pulumi.String("string"),
	DomainName:    pulumi.String("string"),
	Stage:         pulumi.String("string"),
	ApiMappingKey: pulumi.String("string"),
})
Copy
var apiMappingResource = new ApiMapping("apiMappingResource", ApiMappingArgs.builder()
    .apiId("string")
    .domainName("string")
    .stage("string")
    .apiMappingKey("string")
    .build());
Copy
api_mapping_resource = aws.apigatewayv2.ApiMapping("apiMappingResource",
    api_id="string",
    domain_name="string",
    stage="string",
    api_mapping_key="string")
Copy
const apiMappingResource = new aws.apigatewayv2.ApiMapping("apiMappingResource", {
    apiId: "string",
    domainName: "string",
    stage: "string",
    apiMappingKey: "string",
});
Copy
type: aws:apigatewayv2:ApiMapping
properties:
    apiId: string
    apiMappingKey: string
    domainName: string
    stage: string
Copy

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

ApiId
This property is required.
Changes to this property will trigger replacement.
string
API identifier.
DomainName
This property is required.
Changes to this property will trigger replacement.
string
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
Stage This property is required. string
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
ApiMappingKey string
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
ApiId
This property is required.
Changes to this property will trigger replacement.
string
API identifier.
DomainName
This property is required.
Changes to this property will trigger replacement.
string
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
Stage This property is required. string
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
ApiMappingKey string
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
apiId
This property is required.
Changes to this property will trigger replacement.
String
API identifier.
domainName
This property is required.
Changes to this property will trigger replacement.
String
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage This property is required. String
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
apiMappingKey String
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
apiId
This property is required.
Changes to this property will trigger replacement.
string
API identifier.
domainName
This property is required.
Changes to this property will trigger replacement.
string
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage This property is required. string
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
apiMappingKey string
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
api_id
This property is required.
Changes to this property will trigger replacement.
str
API identifier.
domain_name
This property is required.
Changes to this property will trigger replacement.
str
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage This property is required. str
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
api_mapping_key str
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
apiId
This property is required.
Changes to this property will trigger replacement.
String
API identifier.
domainName
This property is required.
Changes to this property will trigger replacement.
String
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage This property is required. String
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
apiMappingKey String
The API mapping key. Refer to REST API, HTTP API or WebSocket API.

Outputs

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

Get an existing ApiMapping 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?: ApiMappingState, opts?: CustomResourceOptions): ApiMapping
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        api_id: Optional[str] = None,
        api_mapping_key: Optional[str] = None,
        domain_name: Optional[str] = None,
        stage: Optional[str] = None) -> ApiMapping
func GetApiMapping(ctx *Context, name string, id IDInput, state *ApiMappingState, opts ...ResourceOption) (*ApiMapping, error)
public static ApiMapping Get(string name, Input<string> id, ApiMappingState? state, CustomResourceOptions? opts = null)
public static ApiMapping get(String name, Output<String> id, ApiMappingState state, CustomResourceOptions options)
resources:  _:    type: aws:apigatewayv2:ApiMapping    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:
ApiId Changes to this property will trigger replacement. string
API identifier.
ApiMappingKey string
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
DomainName Changes to this property will trigger replacement. string
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
Stage string
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
ApiId Changes to this property will trigger replacement. string
API identifier.
ApiMappingKey string
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
DomainName Changes to this property will trigger replacement. string
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
Stage string
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
apiId Changes to this property will trigger replacement. String
API identifier.
apiMappingKey String
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
domainName Changes to this property will trigger replacement. String
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage String
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
apiId Changes to this property will trigger replacement. string
API identifier.
apiMappingKey string
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
domainName Changes to this property will trigger replacement. string
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage string
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
api_id Changes to this property will trigger replacement. str
API identifier.
api_mapping_key str
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
domain_name Changes to this property will trigger replacement. str
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage str
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.
apiId Changes to this property will trigger replacement. String
API identifier.
apiMappingKey String
The API mapping key. Refer to REST API, HTTP API or WebSocket API.
domainName Changes to this property will trigger replacement. String
Domain name. Use the aws.apigatewayv2.DomainName resource to configure a domain name.
stage String
API stage. Use the aws.apigatewayv2.Stage resource to configure an API stage.

Import

Using pulumi import, import aws_apigatewayv2_api_mapping using the API mapping identifier and domain name. For example:

$ pulumi import aws:apigatewayv2/apiMapping:ApiMapping example 1122334/ws-api.example.com
Copy

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

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.