CREATE ARTIFACT REPOSITORY

Creates a new artifact repository in the current or specified schema, or replaces an existing artifact repository. An artifact repository stores versioned packages that are used by downstream Snowflake objects. Two repository types are supported:

  • APPLICATION: stores packaged application builds that a CREATE APPLICATION SERVICE deploys.
  • PYPI: stores Python packages resolved from an external Python package index through an API integration.
See also:

ALTER ARTIFACT REPOSITORY, DESCRIBE ARTIFACT REPOSITORY, DROP ARTIFACT REPOSITORY, SHOW ARTIFACT REPOSITORIES

Syntax

CREATE [ OR REPLACE ] ARTIFACT REPOSITORY [ IF NOT EXISTS ] <name>
  TYPE = { APPLICATION | PYPI }
  [ API_INTEGRATION = '<integration_name>' ]
  [ INDEX_URL = '<url>' ]
  [ AUTHENTICATION_SECRET = <secret_name> ]
  [ PACKAGE_RETENTION = { ON_OBJECT_CREATION } ]
  [ [ WITH ] TAG ( <tag_name> = '<tag_value>' [ , ... ] ) ]
  [ COMMENT = '<string_literal>' ]

Note

INDEX_URL, AUTHENTICATION_SECRET, and PACKAGE_RETENTION apply to customer-hosted Python artifact repositories, which are in public preview. For details, see Integrate customer-hosted Python artifact repositories.

Required parameters

name

Specifies the identifier for the artifact repository. The identifier must be unique for the schema where the repository is created. For more details, see Identifier requirements.

TYPE = { APPLICATION | PYPI }

Specifies the type of content the repository stores.

  • APPLICATION: stores versioned application packages. Required when the repository is referenced by CREATE APPLICATION SERVICE.
  • PYPI: stores Python packages fetched from an external package index. The API_INTEGRATION parameter is required for this type.

Optional parameters

API_INTEGRATION = 'integration_name'

Specifies the API integration that provides access to the external Python package index. Required when TYPE = PYPI. Not used when TYPE = APPLICATION.

INDEX_URL = 'url'

Specifies the HTTPS URL of the PyPI-compatible package index that a customer-hosted Python artifact repository fetches packages from (for example, 'https://nexus.example.com/repository/pypi-proxy/simple/'). The host must be covered by the API_ALLOWED_PREFIXES of the referenced API integration. Used only for customer-hosted PyPI repositories.

AUTHENTICATION_SECRET = secret_name

Specifies the secret that Snowflake uses to authenticate to the customer-hosted Python artifact repository. The secret must be included in the ALLOWED_AUTHENTICATION_SECRETS of the referenced API integration. Used only for customer-hosted PyPI repositories.

PACKAGE_RETENTION = ON_OBJECT_CREATION

Controls when Snowflake retains packages downloaded from a customer-hosted Python artifact repository:

  • When not set (default), packages are retained asynchronously in the background after each CREATE FUNCTION or CREATE PROCEDURE.
  • When set to ON_OBJECT_CREATION, CREATE FUNCTION and CREATE PROCEDURE download and retain every referenced package before the statement returns.

For details, see Package retention and caching. Used only for customer-hosted PyPI repositories.

TAG ( tag_name = 'tag_value' [ , ... ] )

Assigns a tag to the repository. For more details about object tagging, see Introduction to object tagging.

COMMENT = 'string_literal'

Specifies a comment for the artifact repository.

DEFAULT: No value

Access control requirements

If your role does not own the objects in the following table, then your role must have the listed privileges on those objects:

PrivilegeObjectNotes
CREATE ARTIFACT REPOSITORYSchemaRequired to create a new artifact repository in the schema.
USAGEAPI integrationRequired only when TYPE = PYPI.

The following privileges can be granted on an artifact repository after it’s created:

PrivilegeObjectNotes
OWNERSHIPArtifact repositoryGrants full control, including publishing new package versions and dropping the repository.
READArtifact repositoryAllows downloading packages and artifacts. Grant this to any role that references the repository in CREATE APPLICATION SERVICE.

Operating on an object in a schema requires at least one privilege on the parent database and at least one privilege on the parent schema.

For instructions on creating a custom role with a specified set of privileges, see Creating custom roles.

For general information about roles and privilege grants for performing SQL actions on securable objects, see Overview of Access Control.

Usage notes

  • An APPLICATION repository holds one or more packages. Each package has one or more versions. New versions are produced by builds that target the repository. For more information, see Getting started with Snowflake App Runtime.
  • A repository’s type can’t be changed after it’s created. To switch types, drop the repository and create a new one.
  • CREATE OR REPLACE drops and recreates the repository atomically. All packages and versions in the repository are removed.
  • The OR REPLACE and IF NOT EXISTS clauses are mutually exclusive. They can’t both be used in the same statement.
  • CREATE OR REPLACE <object> statements are atomic. That is, when an object is replaced, the old object is deleted and the new object is created in a single transaction.

Examples

Create an artifact repository for application packages:

CREATE ARTIFACT REPOSITORY my_app_repo
  TYPE = APPLICATION
  COMMENT = 'Repository for my team''s apps';

Create a PyPI-backed repository that uses an existing API integration:

CREATE ARTIFACT REPOSITORY my_pypi_repo
  TYPE = PYPI
  API_INTEGRATION = pypi_integration;