attachCertificateToDistribution method
Attaches an SSL/TLS certificate to your Amazon Lightsail content delivery network (CDN) distribution.
After the certificate is attached, your distribution accepts HTTPS traffic for all of the domains that are associated with the certificate.
Use the CreateCertificate
action to create a certificate that
you can attach to your distribution.
May throw ServiceException. May throw InvalidInputException. May throw NotFoundException. May throw OperationFailureException. May throw AccessDeniedException. May throw UnauthenticatedException.
Parameter certificateName
:
The name of the certificate to attach to a distribution.
Only certificates with a status of ISSUED
can be attached to
a distribution.
Use the GetCertificates
action to get a list of certificate
names that you can specify.
Parameter distributionName
:
The name of the distribution that the certificate will be attached to.
Use the GetDistributions
action to get a list of distribution
names that you can specify.
Implementation
Future<AttachCertificateToDistributionResult>
attachCertificateToDistribution({
required String certificateName,
required String distributionName,
}) async {
ArgumentError.checkNotNull(certificateName, 'certificateName');
ArgumentError.checkNotNull(distributionName, 'distributionName');
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.AttachCertificateToDistribution'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'certificateName': certificateName,
'distributionName': distributionName,
},
);
return AttachCertificateToDistributionResult.fromJson(jsonResponse.body);
}