create_distribution_configuration
¶
create_distribution_configuration(
name: ResourceName,
distributions: DistributionList,
client_token: ClientToken,
*,
config_overrides: Optional[imagebuilderClientConfig] = None,
description: Optional[NonEmptyString] = None,
tags: Optional[TagMap] = None,
dry_run: Optional[Boolean] = None,
) -> CreateDistributionConfigurationResponse
Creates a new distribution configuration. Distribution configurations define and configure the outputs for your images, including the target Regions, accounts, and settings for each Region.
Parameters:
-
name(ResourceName) –The name of the distribution configuration. Distribution configuration names must be unique to your account in each Amazon Web Services Region. Image Builder generates the distribution configuration ARN from a normalized form of the name, so names that differ only in case, spaces, or underscores count as the same name.
-
description(Optional[NonEmptyString], default:None) –The description of the distribution configuration.
-
distributions(DistributionList) –The distribution settings for the configuration. Each entry defines how output images are distributed in one target Amazon Web Services Region. A Region can appear at most once in the list.
-
tags(Optional[TagMap], default:None) –The tags of the distribution configuration.
-
client_token(ClientToken) –A unique, case-sensitive identifier you provide to ensure that the operation runs no more than one time. If you retry a request with the same client token, Image Builder returns the original response without running the operation again. For more information, see Ensuring idempotency in the Amazon EC2 API Reference.
-
dry_run(Optional[Boolean], default:None) –Validates the required permissions and request parameters without performing the operation. If validation succeeds, the operation returns a
DryRunOperationExceptionerror response.
Raises:
-
CallRateLimitExceededException–You have exceeded the permitted request rate for the Amazon EC2 APIs that Image Builder calls on your behalf. Retry with an increasing or variable delay between requests.
-
ClientException–A generic client error. This error usually indicates that the request failed a validation check, such as when a downstream service rejects a configured value.
-
DryRunOperationException–The dry run operation of the resource was successful, and no resources or mutations were actually performed due to the dry run flag in the request.
-
ForbiddenException–You are not authorized to perform the requested operation.
-
IdempotentParameterMismatchException–You have specified a client token for an operation using parameter values that differ from a previous request that used the same client token.
-
InvalidParameterCombinationException–You have specified a combination of parameters that isn't valid. For example, two mutually exclusive parameters, or a parameter without its required companion parameter. Review the error message for details.
-
InvalidRequestException–The request is malformed or otherwise invalid. Verify the request and try again.
-
ResourceAlreadyExistsException–The resource that you are trying to create already exists.
-
ResourceInUseException–The resource that you are trying to operate on is currently in use. Review the message details and retry later.
-
ServiceException–An internal server error occurred while Image Builder processed the request. Retrying the request may succeed.
-
ServiceQuotaExceededException–You have exceeded the number of permitted resources or operations for this service. For service quotas, see EC2 Image Builder endpoints and quotas.
-
ServiceUnavailableException–The service is unable to process your request at this time.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Create a distribution configuration The following example creates a distribution configuration that distributes the output AMI to two Regions. The AMI name includes the build date, so that repeated builds create unique AMI names.
>>> client.create_distribution_configuration(name='my-example-distribution', description='Copies the output AMI to a second Region', distributions=[{'region': 'us-west-2', 'amiDistributionConfiguration': {'name': 'my-example-image-{{ imagebuilder:buildDate }}'}}, {'region': 'us-east-1', 'amiDistributionConfiguration': {'name': 'my-example-image-{{ imagebuilder:buildDate }}'}}], client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE44444')
Create a distribution configuration with launch permissions and a launch template update
The following example creates a distribution configuration that distributes the output AMI to two Regions. In us-east-1, it shares the AMI with another AWS account. In us-west-2, it sets the new AMI as the default version of your launch template.
>>> client.create_distribution_configuration(name='my-example-distribution', description='Distributes the output AMI to two Regions and shares it with another account', distributions=[{'region': 'us-west-2', 'amiDistributionConfiguration': {'name': 'my-example-image-{{ imagebuilder:buildDate }}'}, 'launchTemplateConfigurations': [{'launchTemplateId': 'lt-1234567890abcdef0', 'setDefaultVersion': True}]}, {'region': 'us-east-1', 'amiDistributionConfiguration': {'name': 'my-example-image-{{ imagebuilder:buildDate }}', 'launchPermission': {'userIds': ['444455556666']}}}], client_token='a1b2c3d4-5678-90ab-cdef-EXAMPLE56789')
Source code in docs_src/capo_imagebuilder/_services/imagebuilder.py
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 | |