@Stability(value=Stable)
See: Description
| Interface | Description |
|---|---|
| CertificateProps |
Properties for your certificate.
|
| CertificationValidationProps |
Properties for certificate validation.
|
| CfnCertificate.DomainValidationOptionProperty | |
| CfnCertificateProps |
Properties for defining a `AWS::CertificateManager::Certificate`.
|
| DnsValidatedCertificateProps |
Properties to create a DNS validated certificate managed by AWS Certificate Manager.
|
| ICertificate |
Represents a certificate in AWS Certificate Manager.
|
| Enum | Description |
|---|---|
| ValidationMethod |
Method used to assert ownership of the domain.
|
---
This package provides Constructs for provisioning and referencing certificates which can be used in CloudFront and ELB.
The following requests a certificate for a given domain:
// Example automatically generated. See https://github.com/aws/jsii/issues/826
Certificate cert = new Certificate(this, "Certificate", new CertificateProps()
.domainName("example.com"));
After requesting a certificate, you will need to prove that you own the domain in question before the certificate will be granted. The CloudFormation deployment will wait until this verification process has been completed.
Because of this wait time, when using manual validation methods, it's better to provision your certificates either in a separate stack from your main service, or provision them manually and import them into your CDK application.
Email-validated certificates (the default) are validated by receiving an email on one of a number of predefined domains and following the instructions in the email.
See Validate with Email in the AWS Certificate Manager User Guide.
If Amazon Route 53 is your DNS provider for the requested domain, the DNS record can be created automatically:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Certificate.Builder.create(this, "Certificate")
.domainName("hello.example.com")
.validation(CertificateValidation.fromDns(myHostedZone))
.build();
Otherwise DNS records must be added manually and the stack will not complete creating until the records are added.
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
Certificate.Builder.create(this, "Certificate")
.domainName("hello.example.com")
.validation(CertificateValidation.fromDns())
.build();
See also Validate with DNS in the AWS Certificate Manager User Guide.
When working with multiple domains, use the CertificateValidation.fromDnsMultiZone():
// Example automatically generated. See https://github.com/aws/jsii/issues/826
HostedZone exampleCom = new HostedZone(this, "ExampleCom", new HostedZoneProps()
.zoneName("example.com"));
HostedZone exampleNet = new HostedZone(this, "ExampelNet", new HostedZoneProps()
.zoneName("example.net"));
Certificate cert = new Certificate(this, "Certificate", new CertificateProps()
.domainName("test.example.com")
.subjectAlternativeNames(asList("cool.example.com", "test.example.net"))
.validation(acm.CertificateValidation.fromDnsMultiZone(Map.of(
"text.example.com", exampleCom,
"cool.example.com", exampleCom,
"test.example.net", exampleNet))));
Use the DnsValidatedCertificate construct for cross-region certificate creation:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826
DnsValidatedCertificate.Builder.create(this, "CrossRegionCertificate")
.domainName("hello.example.com")
.hostedZone(myHostedZone)
.region("us-east-1")
.build();
This is useful when deploying a stack in a region other than us-east-1 with a
certificate for a CloudFront distribution.
If cross-region is not needed, the recommended solution is to use the
Certificate construct which uses a native CloudFormation implementation.
If you want to import an existing certificate, you can do so from its ARN:
// Example automatically generated without compilation. See https://github.com/aws/jsii/issues/826 String arn = "arn:aws:..."; var certificate = Certificate.fromCertificateArn(this, "Certificate", arn);
To share the certificate between stacks in the same CDK application, simply
pass the Certificate object between the stacks.
Copyright © 2020. All rights reserved.