Skip to content

create_repository

create_repository(
    repository_name: RepositoryName,
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional[RegistryId] = None,
    tags: Optional[TagList] = None,
    image_tag_mutability: Optional[ImageTagMutability] = None,
    image_tag_mutability_exclusion_filters: Optional[
        ImageTagMutabilityExclusionFilters
    ] = None,
    image_scanning_configuration: Optional[ImageScanningConfiguration] = None,
    encryption_configuration: Optional[EncryptionConfiguration] = None,
) -> CreateRepositoryResponse

Creates a repository. For more information, see Amazon ECR repositories in the Amazon Elastic Container Registry User Guide.

Parameters:

  • registry_id (Optional[RegistryId], default: None ) –

    The Amazon Web Services account ID associated with the registry to create the repository. If you do not specify a registry, the default registry is assumed.

  • repository_name (RepositoryName) –

    The name to use for the repository. The repository name may be specified on its own (such as nginx-web-app) or it can be prepended with a namespace to group the repository into a category (such as project-a/nginx-web-app).

    The repository name must start with a letter and can only contain lowercase letters, numbers, hyphens, underscores, and forward slashes.

  • tags (Optional[TagList], default: None ) –

    The metadata that you apply to the repository to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

  • image_tag_mutability (Optional[ImageTagMutability], default: None ) –

    The tag mutability setting for the repository. If this parameter is omitted, the default setting of MUTABLE will be used which will allow image tags to be overwritten. If IMMUTABLE is specified, all image tags within the repository will be immutable which will prevent them from being overwritten.

  • image_tag_mutability_exclusion_filters (Optional[ImageTagMutabilityExclusionFilters], default: None ) –

    A list of filters that specify which image tags should be excluded from the repository's image tag mutability setting.

  • image_scanning_configuration (Optional[ImageScanningConfiguration], default: None ) –

    The imageScanningConfiguration parameter is being deprecated, in favor of specifying the image scanning configuration at the registry level. For more information, see PutRegistryScanningConfiguration.

    The image scanning configuration for the repository. This determines whether images are scanned for known vulnerabilities after being pushed to the repository.

  • encryption_configuration (Optional[EncryptionConfiguration], default: None ) –

    The encryption configuration for the repository. This determines how the contents of your repository are encrypted at rest.

Raises:

  • InvalidParameterException –

    The specified parameter is invalid. Review the available parameters for the API request.

  • InvalidTagParameterException –

    An invalid parameter has been specified. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.

  • KmsException –

    The operation failed due to a KMS exception.

  • LimitExceededException –

    The operation did not succeed because it would have exceeded a service limit for your account. For more information, see Amazon ECR service quotas in the Amazon Elastic Container Registry User Guide.

  • RepositoryAlreadyExistsException –

    The specified repository already exists in the specified registry.

  • ServerException –

    These errors are usually caused by a server-side issue.

  • TooManyTagsException –

    The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50.

  • UnknownServiceError –

    The service returned an error code this client does not model.

Examples:

To create a new repository This example creates a repository called nginx-web-app inside the project-a namespace in the default registry for an account.

>>> client.create_repository(repository_name='project-a/nginx-web-app')
Source code in docs_src/capo_ecr/_services/ecr.py
def create_repository(
    self,
    repository_name: "capo_ecr.types.repository_name.RepositoryName",
    *,
    config_overrides: Optional[ECRClientConfig] = None,
    registry_id: Optional["capo_ecr.types.registry_id.RegistryId"] = None,
    tags: Optional["capo_ecr.types.tag_list.TagList"] = None,
    image_tag_mutability: Optional[
        "capo_ecr.types.image_tag_mutability.ImageTagMutability"
    ] = None,
    image_tag_mutability_exclusion_filters: Optional[
        "capo_ecr.types.image_tag_mutability_exclusion_filters.ImageTagMutabilityExclusionFilters"
    ] = None,
    image_scanning_configuration: Optional[
        "capo_ecr.types.image_scanning_configuration.ImageScanningConfiguration"
    ] = None,
    encryption_configuration: Optional[
        "capo_ecr.types.encryption_configuration.EncryptionConfiguration"
    ] = None,
) -> "capo_ecr.types.create_repository_response.CreateRepositoryResponse":
    """<p>Creates a repository. For more information, see <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/Repositories.html">Amazon ECR repositories</a> in the <i>Amazon Elastic Container Registry User Guide</i>.</p>

    Args:
        registry_id: <p>The Amazon Web Services account ID associated with the registry to create the repository. If you do not specify a registry, the default registry is assumed.</p>
        repository_name: <p>The name to use for the repository. The repository name may be specified on its own (such as <code>nginx-web-app</code>) or it can be prepended with a namespace to group the repository into a category (such as <code>project-a/nginx-web-app</code>).</p> <p>The repository name must start with a letter and can only contain lowercase letters, numbers, hyphens, underscores, and forward slashes.</p>
        tags: <p>The metadata that you apply to the repository to help you categorize and organize them. Each tag consists of a key and an optional value, both of which you define. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.</p>
        image_tag_mutability: <p>The tag mutability setting for the repository. If this parameter is omitted, the default setting of <code>MUTABLE</code> will be used which will allow image tags to be overwritten. If <code>IMMUTABLE</code> is specified, all image tags within the repository will be immutable which will prevent them from being overwritten.</p>
        image_tag_mutability_exclusion_filters: <p>A list of filters that specify which image tags should be excluded from the repository's image tag mutability setting.</p>
        image_scanning_configuration: <important> <p>The <code>imageScanningConfiguration</code> parameter is being deprecated, in favor of specifying the image scanning configuration at the registry level. For more information, see <code>PutRegistryScanningConfiguration</code>.</p> </important> <p>The image scanning configuration for the repository. This determines whether images are scanned for known vulnerabilities after being pushed to the repository.</p>
        encryption_configuration: <p>The encryption configuration for the repository. This determines how the contents of your repository are encrypted at rest.</p>

    Raises:
        capo_ecr.errors.invalid_parameter_exception.InvalidParameterException: <p>The specified parameter is invalid. Review the available parameters for the API request.</p>
        capo_ecr.errors.invalid_tag_parameter_exception.InvalidTagParameterException: <p>An invalid parameter has been specified. Tag keys can have a maximum character length of 128 characters, and tag values can have a maximum length of 256 characters.</p>
        capo_ecr.errors.kms_exception.KmsException: <p>The operation failed due to a KMS exception.</p>
        capo_ecr.errors.limit_exceeded_exception.LimitExceededException: <p>The operation did not succeed because it would have exceeded a service limit for your account. For more information, see <a href="https://docs.aws.amazon.com/AmazonECR/latest/userguide/service-quotas.html">Amazon ECR service quotas</a> in the Amazon Elastic Container Registry User Guide.</p>
        capo_ecr.errors.repository_already_exists_exception.RepositoryAlreadyExistsException: <p>The specified repository already exists in the specified registry.</p>
        capo_ecr.errors.server_exception.ServerException: <p>These errors are usually caused by a server-side issue.</p>
        capo_ecr.errors.too_many_tags_exception.TooManyTagsException: <p>The list of tags on the repository is over the limit. The maximum number of tags that can be applied to a repository is 50.</p>
        capo_ecr.errors.UnknownServiceError: The service returned an error code this client does not model.

    Examples:
        To create a new repository
        This example creates a repository called nginx-web-app inside the project-a namespace in the default registry for an account.

        >>> client.create_repository(repository_name='project-a/nginx-web-app')
    """

    def _handler(
        req: "OperationRequest[capo_ecr.types.create_repository_request.CreateRepositoryRequest]",
    ) -> OperationResponse[
        "capo_ecr.types.create_repository_response.CreateRepositoryResponse"
    ]:
        import capo_ecr._operations.amazon_ec2_container_registry_v20150921.create_repository

        output, http_response = (
            capo_ecr._operations.amazon_ec2_container_registry_v20150921.create_repository.create_repository(
                req.options, req.input
            )
        )
        return OperationResponse(output=output, response=http_response)

    interceptors_, options_ = self.operation_options(
        config_overrides, OperationLogging("CreateRepository")
    )
    input_: capo_ecr.types.create_repository_request.CreateRepositoryRequest = {
        "repository_name": repository_name
    }
    if registry_id is not None:
        input_["registry_id"] = registry_id
    if tags is not None:
        input_["tags"] = tags
    if image_tag_mutability is not None:
        input_["image_tag_mutability"] = image_tag_mutability
    if image_tag_mutability_exclusion_filters is not None:
        input_["image_tag_mutability_exclusion_filters"] = (
            image_tag_mutability_exclusion_filters
        )
    if image_scanning_configuration is not None:
        input_["image_scanning_configuration"] = image_scanning_configuration
    if encryption_configuration is not None:
        input_["encryption_configuration"] = encryption_configuration

    response = execute_pipeline(
        OperationRequest(input=input_, options=options_),
        handler=_handler,
        interceptors=list(interceptors_),
    )
    response.response.close()
    return response.output