:doc:`ECR <../../ecr>` / Client / create_pull_through_cache_rule

******************************
create_pull_through_cache_rule
******************************



.. py:method:: ECR.Client.create_pull_through_cache_rule(**kwargs)

  

  Creates a pull through cache rule. A pull through cache rule provides a way to cache images from an upstream registry source in your Amazon ECR private registry. For more information, see `Using pull through cache rules <https://docs.aws.amazon.com/AmazonECR/latest/userguide/pull-through-cache.html>`__ in the *Amazon Elastic Container Registry User Guide*.

  

  See also: `AWS API Documentation <https://docs.aws.amazon.com/goto/WebAPI/ecr-2015-09-21/CreatePullThroughCacheRule>`_  


  **Request Syntax**
  ::

    response = client.create_pull_through_cache_rule(
        ecrRepositoryPrefix='string',
        upstreamRegistryUrl='string',
        registryId='string',
        upstreamRegistry='ecr'|'ecr-public'|'quay'|'k8s'|'docker-hub'|'github-container-registry'|'azure-container-registry'|'gitlab-container-registry',
        credentialArn='string',
        customRoleArn='string',
        upstreamRepositoryPrefix='string'
    )
    
  :type ecrRepositoryPrefix: string
  :param ecrRepositoryPrefix: **[REQUIRED]** 

    The repository name prefix to use when caching images from the source registry.

     

    .. warning::

       

      There is always an assumed ``/`` applied to the end of the prefix. If you specify ``ecr-public`` as the prefix, Amazon ECR treats that as ``ecr-public/``.

      

    

  
  :type upstreamRegistryUrl: string
  :param upstreamRegistryUrl: **[REQUIRED]** 

    The registry URL of the upstream public registry to use as the source for the pull through cache rule. The following is the syntax to use for each supported upstream registry.

     

    
    * Amazon ECR ( ``ecr``) – ``<accountId>.dkr.ecr.<region>.amazonaws.com``
     
    * Amazon ECR Public ( ``ecr-public``) – ``public.ecr.aws``
     
    * Docker Hub ( ``docker-hub``) – ``registry-1.docker.io``
     
    * GitHub Container Registry ( ``github-container-registry``) – ``ghcr.io``
     
    * GitLab Container Registry ( ``gitlab-container-registry``) – ``registry.gitlab.com``
     
    * Kubernetes ( ``k8s``) – ``registry.k8s.io``
     
    * Microsoft Azure Container Registry ( ``azure-container-registry``) – ``<custom>.azurecr.io``
     
    * Quay ( ``quay``) – ``quay.io``
    

    

  
  :type registryId: string
  :param registryId: 

    The Amazon Web Services account ID associated with the registry to create the pull through cache rule for. If you do not specify a registry, the default registry is assumed.

    

  
  :type upstreamRegistry: string
  :param upstreamRegistry: 

    The name of the upstream registry.

    

  
  :type credentialArn: string
  :param credentialArn: 

    The Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager secret that identifies the credentials to authenticate to the upstream registry.

    

  
  :type customRoleArn: string
  :param customRoleArn: 

    Amazon Resource Name (ARN) of the IAM role to be assumed by Amazon ECR to authenticate to the ECR upstream registry. This role must be in the same account as the registry that you are configuring.

    

  
  :type upstreamRepositoryPrefix: string
  :param upstreamRepositoryPrefix: 

    The repository name prefix of the upstream registry to match with the upstream repository name. When this field isn't specified, Amazon ECR will use the ``ROOT``.

    

  
  
  :rtype: dict
  :returns: 
    
    **Response Syntax**

    
    ::

      {
          'ecrRepositoryPrefix': 'string',
          'upstreamRegistryUrl': 'string',
          'createdAt': datetime(2015, 1, 1),
          'registryId': 'string',
          'upstreamRegistry': 'ecr'|'ecr-public'|'quay'|'k8s'|'docker-hub'|'github-container-registry'|'azure-container-registry'|'gitlab-container-registry',
          'credentialArn': 'string',
          'customRoleArn': 'string',
          'upstreamRepositoryPrefix': 'string'
      }
      
    **Response Structure**

    

    - *(dict) --* 
      

      - **ecrRepositoryPrefix** *(string) --* 

        The Amazon ECR repository prefix associated with the pull through cache rule.

        
      

      - **upstreamRegistryUrl** *(string) --* 

        The upstream registry URL associated with the pull through cache rule.

        
      

      - **createdAt** *(datetime) --* 

        The date and time, in JavaScript date format, when the pull through cache rule was created.

        
      

      - **registryId** *(string) --* 

        The registry ID associated with the request.

        
      

      - **upstreamRegistry** *(string) --* 

        The name of the upstream registry associated with the pull through cache rule.

        
      

      - **credentialArn** *(string) --* 

        The Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager secret associated with the pull through cache rule.

        
      

      - **customRoleArn** *(string) --* 

        The ARN of the IAM role associated with the pull through cache rule.

        
      

      - **upstreamRepositoryPrefix** *(string) --* 

        The upstream repository prefix associated with the pull through cache rule.

        
  
  **Exceptions**
  
  *   :py:class:`ECR.Client.exceptions.ServerException`

  
  *   :py:class:`ECR.Client.exceptions.InvalidParameterException`

  
  *   :py:class:`ECR.Client.exceptions.ValidationException`

  
  *   :py:class:`ECR.Client.exceptions.PullThroughCacheRuleAlreadyExistsException`

  
  *   :py:class:`ECR.Client.exceptions.UnsupportedUpstreamRegistryException`

  
  *   :py:class:`ECR.Client.exceptions.LimitExceededException`

  
  *   :py:class:`ECR.Client.exceptions.UnableToAccessSecretException`

  
  *   :py:class:`ECR.Client.exceptions.SecretNotFoundException`

  
  *   :py:class:`ECR.Client.exceptions.UnableToDecryptSecretValueException`

  