Domain Name Args
Registers a custom domain name for use with AWS API Gateway. Additional information about this functionality can be found in the API Gateway Developer Guide. This resource just establishes ownership of and the TLS settings for a particular domain name. An API can be attached to a particular path under the registered domain name using the aws.apigateway.BasePathMapping
resource. API Gateway domains can be defined as either 'edge-optimized' or 'regional'. In an edge-optimized configuration, API Gateway internally creates and manages a CloudFront distribution to route requests on the given hostname. In addition to this resource it's necessary to create a DNS record corresponding to the given domain name which is an alias (either Route53 alias or traditional CNAME) to the Cloudfront domain name exported in the cloudfront_domain_name
attribute. In a regional configuration, API Gateway does not create a CloudFront distribution to route requests to the API, though a distribution can be created if needed. In either case, it is necessary to create a DNS record corresponding to the given domain name which is an alias (either Route53 alias or traditional CNAME) to the regional domain name exported in the regional_domain_name
attribute.
Note: API Gateway requires the use of AWS Certificate Manager (ACM) certificates instead of Identity and Access Management (IAM) certificates in regions that support ACM. Regions that support ACM can be found in the Regions and Endpoints Documentation. To import an existing private key and certificate into ACM or request an ACM certificate, see the
aws.acm.Certificate
resource. Note: Theaws.apigateway.DomainName
resource expects dependency on theaws.acm.CertificateValidation
as only verified certificates can be used. This can be made either explicitly by adding thedepends_on = [aws_acm_certificate_validation.cert]
attribute. Or implicitly by referring certificate ARN from the validation resource where it will be available after the resource creation:regional_certificate_arn = aws_acm_certificate_validation.cert.certificate_arn
.
Example Usage
Edge Optimized (ACM Certificate)
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.DomainName;
import com.pulumi.aws.apigateway.DomainNameArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 exampleDomainName = new DomainName("exampleDomainName", DomainNameArgs.builder()
.certificateArn(aws_acm_certificate_validation.example().certificate_arn())
.domainName("api.example.com")
.build());
var exampleRecord = new Record("exampleRecord", RecordArgs.builder()
.name(exampleDomainName.domainName())
.type("A")
.zoneId(aws_route53_zone.example().id())
.aliases(RecordAliasArgs.builder()
.evaluateTargetHealth(true)
.name(exampleDomainName.cloudfrontDomainName())
.zoneId(exampleDomainName.cloudfrontZoneId())
.build())
.build());
}
}
Edge Optimized (IAM Certificate)
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.DomainName;
import com.pulumi.aws.apigateway.DomainNameArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 exampleDomainName = new DomainName("exampleDomainName", DomainNameArgs.builder()
.domainName("api.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 exampleRecord = new Record("exampleRecord", RecordArgs.builder()
.zoneId(aws_route53_zone.example().id())
.name(exampleDomainName.domainName())
.type("A")
.aliases(RecordAliasArgs.builder()
.name(exampleDomainName.cloudfrontDomainName())
.zoneId(exampleDomainName.cloudfrontZoneId())
.evaluateTargetHealth(true)
.build())
.build());
}
}
Regional (ACM Certificate)
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.DomainName;
import com.pulumi.aws.apigateway.DomainNameArgs;
import com.pulumi.aws.apigateway.inputs.DomainNameEndpointConfigurationArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 exampleDomainName = new DomainName("exampleDomainName", DomainNameArgs.builder()
.domainName("api.example.com")
.regionalCertificateArn(aws_acm_certificate_validation.example().certificate_arn())
.endpointConfiguration(DomainNameEndpointConfigurationArgs.builder()
.types("REGIONAL")
.build())
.build());
var exampleRecord = new Record("exampleRecord", RecordArgs.builder()
.name(exampleDomainName.domainName())
.type("A")
.zoneId(aws_route53_zone.example().id())
.aliases(RecordAliasArgs.builder()
.evaluateTargetHealth(true)
.name(exampleDomainName.regionalDomainName())
.zoneId(exampleDomainName.regionalZoneId())
.build())
.build());
}
}
Regional (IAM Certificate)
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.apigateway.DomainName;
import com.pulumi.aws.apigateway.DomainNameArgs;
import com.pulumi.aws.apigateway.inputs.DomainNameEndpointConfigurationArgs;
import com.pulumi.aws.route53.Record;
import com.pulumi.aws.route53.RecordArgs;
import com.pulumi.aws.route53.inputs.RecordAliasArgs;
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 exampleDomainName = new DomainName("exampleDomainName", DomainNameArgs.builder()
.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()))))
.domainName("api.example.com")
.regionalCertificateName("example-api")
.endpointConfiguration(DomainNameEndpointConfigurationArgs.builder()
.types("REGIONAL")
.build())
.build());
var exampleRecord = new Record("exampleRecord", RecordArgs.builder()
.name(exampleDomainName.domainName())
.type("A")
.zoneId(aws_route53_zone.example().id())
.aliases(RecordAliasArgs.builder()
.evaluateTargetHealth(true)
.name(exampleDomainName.regionalDomainName())
.zoneId(exampleDomainName.regionalZoneId())
.build())
.build());
}
}
Import
API Gateway domain names can be imported using their name
, e.g.,
$ pulumi import aws:apigateway/domainName:DomainName example dev.example.com
Constructors
Properties
ARN for an AWS-managed certificate. AWS Certificate Manager is the only supported source. Used when an edge-optimized domain name is desired. Conflicts with certificate_name
, certificate_body
, certificate_chain
, certificate_private_key
, regional_certificate_arn
, and regional_certificate_name
.
Certificate issued for the domain name being registered, in PEM format. Only valid for EDGE
endpoint configuration type. Conflicts with certificate_arn
, regional_certificate_arn
, and regional_certificate_name
.
Certificate for the CA that issued the certificate, along with any intermediate CA certificates required to create an unbroken chain to a certificate trusted by the intended API clients. Only valid for EDGE
endpoint configuration type. Conflicts with certificate_arn
, regional_certificate_arn
, and regional_certificate_name
.
Unique name to use when registering this certificate as an IAM server certificate. Conflicts with certificate_arn
, regional_certificate_arn
, and regional_certificate_name
. Required if certificate_arn
is not set.
Private key associated with the domain certificate given in certificate_body
. Only valid for EDGE
endpoint configuration type. Conflicts with certificate_arn
, regional_certificate_arn
, and regional_certificate_name
.
Fully-qualified domain name to register.
Configuration block defining API endpoint information including type. See below.
Mutual TLS authentication configuration for the domain name. See below.
ARN of the AWS-issued certificate used to validate custom domain ownership (when certificate_arn
is issued via an ACM Private CA or mutual_tls_authentication
is configured with an ACM-imported certificate.)
ARN for an AWS-managed certificate. AWS Certificate Manager is the only supported source. Used when a regional domain name is desired. Conflicts with certificate_arn
, certificate_name
, certificate_body
, certificate_chain
, and certificate_private_key
. When uploading a certificate, the following arguments are supported:
User-friendly name of the certificate that will be used by regional endpoint for this domain name. Conflicts with certificate_arn
, certificate_name
, certificate_body
, certificate_chain
, and certificate_private_key
.
Transport Layer Security (TLS) version + cipher suite for this DomainName. Valid values are TLS_1_0
and TLS_1_2
. Must be configured to perform drift detection.
Key-value map of resource tags. If configured with a provider default_tags
configuration block present, tags with matching keys will overwrite those defined at the provider-level. When referencing an AWS-managed certificate, the following arguments are supported: