create_distribution
¶
create_distribution(
distribution_name: ResourceName,
origin: InputOrigin,
default_cache_behavior: CacheBehavior,
bundle_id: string,
*,
config_overrides: Optional[LightsailClientConfig] = None,
cache_behavior_settings: Optional[CacheSettings] = None,
cache_behaviors: Optional[CacheBehaviorList] = None,
ip_address_type: Optional[IpAddressType] = None,
tags: Optional[TagList] = None,
certificate_name: Optional[ResourceName] = None,
viewer_minimum_tls_protocol_version: Optional[
ViewerMinimumTlsProtocolVersionEnum
] = None,
enable_private_origin_access: Optional[boolean] = None,
default_root_object: Optional[string] = None,
custom_error_responses: Optional[DistributionCustomErrorResponseList] = None,
) -> CreateDistributionResult
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.
Parameters:
-
distribution_name(ResourceName) –The name for the distribution.
-
origin(InputOrigin) –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.
-
default_cache_behavior(CacheBehavior) –An object that describes the default cache behavior for the distribution.
-
cache_behavior_settings(Optional[CacheSettings], default:None) –An object that describes the cache behavior settings for the distribution.
-
cache_behaviors(Optional[CacheBehaviorList], default:None) –An array of objects that describe the per-path cache behavior for the distribution.
-
bundle_id(string) –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
GetDistributionBundlesaction to get a list of distribution bundle IDs that you can specify. -
ip_address_type(Optional[IpAddressType], default:None) –The IP address type for the distribution.
The possible values are
ipv4for IPv4 only, anddualstackfor IPv4 and IPv6.The default value is
dualstack. -
tags(Optional[TagList], default:None) –The tag keys and optional values to add to the distribution during create.
Use the
TagResourceaction to tag a resource after it's created. -
certificate_name(Optional[ResourceName], default:None) –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.
-
viewer_minimum_tls_protocol_version(Optional[ViewerMinimumTlsProtocolVersionEnum], default:None) –The minimum TLS protocol version for the SSL/TLS certificate.
-
enable_private_origin_access(Optional[boolean], default:None) –Specifies whether to enable private origin access for the distribution. With private origin access, the distribution can serve objects that aren't publicly accessible from a Lightsail bucket.
Lightsail grants the distribution permission to read the bucket's objects. Enabling private origin access doesn't change the bucket's access settings, and you can still retrieve publicly accessible objects directly from the bucket's endpoint.
You can enable private origin access only when the distribution's origin is a Lightsail bucket. If the origin is another resource type, the request fails.
-
default_root_object(Optional[string], default:None) –The object (for example,
index.html) that the distribution returns when a viewer requests the root URL of the distribution (/) instead of a specific object. The object that you specify must be available from the origin. -
custom_error_responses(Optional[DistributionCustomErrorResponseList], default:None) –An array of objects that describe the custom error responses for the distribution. With a custom error response, you can specify the page to return when the origin responds with a given HTTP error code. You can also specify the HTTP status code to send to the viewer.
Raises:
-
AccessDeniedException–Lightsail throws this exception when the user cannot be authenticated or uses invalid credentials to access a resource.
-
InvalidInputException–Lightsail throws this exception when user input does not conform to the validation rules of an input field.
Domain and distribution APIs are only available in the N. Virginia (
us-east-1) Amazon Web Services Region. Please set your Amazon Web Services Region configuration tous-east-1to create, view, or edit these resources. -
NotFoundException–Lightsail throws this exception when it cannot find a resource.
-
OperationFailureException–Lightsail throws this exception when an operation fails to execute.
-
ServiceException–A general service exception.
-
UnauthenticatedException–Lightsail throws this exception when the user has not been authenticated.
-
UnknownServiceError–The service returned an error code this client does not model.
Source code in docs_src/capo_lightsail/_services/lightsail.py
1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 | |