Base Path Mapping
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
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());
}
}
Content copied to clipboard
Import
aws_api_gateway_base_path_mapping
can be imported by using the domain name and base path, e.g., For empty base_path
(e.g., root path (/
))
$ pulumi import aws:apigateway/basePathMapping:BasePathMapping example example.com/
Content copied to clipboard
Otherwise
$ pulumi import aws:apigateway/basePathMapping:BasePathMapping example example.com/base-path
Content copied to clipboard