createDistribution method
- required String bundleId,
- required CacheBehavior defaultCacheBehavior,
- required String distributionName,
- required InputOrigin origin,
- CacheSettings? cacheBehaviorSettings,
- List<
CacheBehaviorPerPath> ? cacheBehaviors, - String? certificateName,
- IpAddressType? ipAddressType,
- List<
Tag> ? tags, - ViewerMinimumTlsProtocolVersionEnum? viewerMinimumTlsProtocolVersion,
Creates an Amazon Lightsail content delivery network (CDN) distribution.
A distribution is a globally distributed network of caching servers that improve the performance of your website or web application hosted on a Lightsail instance. For more information, see Content delivery networks in Amazon Lightsail.
May throw AccessDeniedException.
May throw InvalidInputException.
May throw NotFoundException.
May throw OperationFailureException.
May throw ServiceException.
May throw UnauthenticatedException.
Parameter bundleId :
The bundle ID to use for the distribution.
A distribution bundle describes the specifications of your distribution, such as the monthly cost and monthly network transfer quota.
Use the GetDistributionBundles action to get a list of
distribution bundle IDs that you can specify.
Parameter defaultCacheBehavior :
An object that describes the default cache behavior for the distribution.
Parameter distributionName :
The name for the distribution.
Parameter origin :
An object that describes the origin resource for the distribution, such as
a Lightsail instance, bucket, or load balancer.
The distribution pulls, caches, and serves content from the origin.
Parameter cacheBehaviorSettings :
An object that describes the cache behavior settings for the distribution.
Parameter cacheBehaviors :
An array of objects that describe the per-path cache behavior for the
distribution.
Parameter certificateName :
The name of the SSL/TLS certificate that you want to attach to the
distribution.
Use the GetCertificates action to get a list of certificate names that you can specify.
Parameter ipAddressType :
The IP address type for the distribution.
The possible values are ipv4 for IPv4 only, and
dualstack for IPv4 and IPv6.
The default value is dualstack.
Parameter tags :
The tag keys and optional values to add to the distribution during create.
Use the TagResource action to tag a resource after it's
created.
Parameter viewerMinimumTlsProtocolVersion :
The minimum TLS protocol version for the SSL/TLS certificate.
Implementation
Future<CreateDistributionResult> createDistribution({
required String bundleId,
required CacheBehavior defaultCacheBehavior,
required String distributionName,
required InputOrigin origin,
CacheSettings? cacheBehaviorSettings,
List<CacheBehaviorPerPath>? cacheBehaviors,
String? certificateName,
IpAddressType? ipAddressType,
List<Tag>? tags,
ViewerMinimumTlsProtocolVersionEnum? viewerMinimumTlsProtocolVersion,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target': 'Lightsail_20161128.CreateDistribution'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'bundleId': bundleId,
'defaultCacheBehavior': defaultCacheBehavior,
'distributionName': distributionName,
'origin': origin,
if (cacheBehaviorSettings != null)
'cacheBehaviorSettings': cacheBehaviorSettings,
if (cacheBehaviors != null) 'cacheBehaviors': cacheBehaviors,
if (certificateName != null) 'certificateName': certificateName,
if (ipAddressType != null) 'ipAddressType': ipAddressType.value,
if (tags != null) 'tags': tags,
if (viewerMinimumTlsProtocolVersion != null)
'viewerMinimumTlsProtocolVersion':
viewerMinimumTlsProtocolVersion.value,
},
);
return CreateDistributionResult.fromJson(jsonResponse.body);
}