What you will be able to do
- Create a storage integration and explain how it gives external stages access to cloud storage without credentials
- Restrict where an API integration may call with API_ALLOWED_PREFIXES and API_BLOCKED_PREFIXES
- Set up a Git repository clone on top of a git_https_api API integration, with or without a secret
- Run a .sql file from a Git repository clone with EXECUTE IMMEDIATE FROM
1.Storage integrations: stage access without stored keys
An integration is a named, first-class Snowflake object that lets Snowflake reach an outside service without anyone passing explicit credentials such as secret keys or access tokens. Three kinds matter here: a storage integration for cloud storage, an API integration for HTTPS APIs, and a Git repository clone, which is built on an API integration. They differ in what they reach and how they authenticate, and a table later on this page lines them up.
An external stage is a named Snowflake object that points at a location in cloud storage. COPY statements use it to load files from that location into tables and to unload table data back to files. The storage integration is what protects that location: it holds the identity Snowflake uses to get in, so the stage definition carries no keys.
A storage integration is how an external stage reaches S3, Google Cloud Storage or Azure without holding a secret key. The integration stores an identity and access management (IAM) entity that Snowflake generates. Your cloud administrator grants that entity permissions on the buckets or containers. Stages then reference the integration by name, so no one supplies credentials when creating a stage or loading and unloading data. The integration also lists allowed (and optionally blocked) locations, and a stage URL must fall inside STORAGE_ALLOWED_LOCATIONS. A single integration can serve many stages.
CREATE STORAGE INTEGRATION <integration_name>
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = 'S3'
ENABLED = TRUE
STORAGE_AWS_ROLE_ARN = '<iam_role>'
STORAGE_ALLOWED_LOCATIONS = ('<protocol>://<bucket>/<path>/', '<protocol>://<bucket>/<path>/')
[ STORAGE_BLOCKED_LOCATIONS = ('<protocol>://<bucket>/<path>/', '<protocol>://<bucket>/<path>/') ]On AWS, Snowflake creates one IAM user per Snowflake account, and every S3 storage integration in that account refers to it. You create an IAM role whose policy covers the bucket and set its ARN as STORAGE_AWS_ROLE_ARN; the role carries the permissions, which is why you supply it while the generated user is never supplied. The role starts with a placeholder trust relationship (your own account ID and a placeholder external ID such as 0000). Once the integration exists, you modify that trust relationship to grant access to Snowflake, specifying the external ID of your storage integration. Reading needs s3:GetBucketLocation, s3:GetObject, s3:GetObjectVersion and s3:ListBucket. Unloading also needs s3:PutObject, and PURGE or REMOVE needs s3:DeleteObject. Only ACCOUNTADMIN, or a role with the global CREATE INTEGRATION privilege, can create the integration.
| Provider | Parameters | Allowed-location format |
|---|---|---|
| Amazon S3 | STORAGE_PROVIDER = 'S3', STORAGE_AWS_ROLE_ARN | s3://bucket/path/ (s3gov, s3china for those regions) |
| Google Cloud Storage | STORAGE_PROVIDER = 'GCS' | gcs://bucket/path/ |
| Microsoft Azure | STORAGE_PROVIDER = 'AZURE', AZURE_TENANT_ID | azure://account.blob.core.windows.net/container/path/ |
Revoking access in AWS is not instant either. Snowflake caches temporary credentials for up to 60 minutes, so users may still list and read files until the cache expires. Storage integrations also have a regional limit. For storage in a government region or a region in China, the Snowflake account must be hosted in that same region. Otherwise the stage has to pass credentials with the CREDENTIALS parameter of CREATE STAGE.
Checkpoint 1 of 5· Fill the gap
Your AWS administrator has created an IAM role whose policy covers the bucket. Which parameter gives that role to the storage integration, so the stages that use it need no secret keys?
CREATE STORAGE INTEGRATION <integration_name>
TYPE = EXTERNAL_STAGE
STORAGE_PROVIDER = 'S3'
ENABLED = TRUE
? = '<iam_role>'
STORAGE_ALLOWED_LOCATIONS = ('<protocol>://<bucket>/<path>/', '<protocol>://<bucket>/<path>/')
[ STORAGE_BLOCKED_LOCATIONS = ('<protocol>://<bucket>/<path>/', '<protocol>://<bucket>/<path>/') ]You give the integration the ARN of an IAM role that you create. Snowflake generates the IAM user itself, so you don't supply it. Keys and the CREDENTIALS parameter are what an integration lets you avoid.
Source: docs.snowflake.comCheckpoint 2 of 5· Check yourself
At 10:00 an AWS administrator revokes Snowflake's access to the S3 bucket behind a storage integration. At 10:20 a user runs LIST on an external stage that uses that integration. What happens?
Snowflake caches the temporary credentials for up to 60 minutes. Until that cache expires, users may still be able to list and read files after access has been revoked in AWS.
“If you revoke access from Snowflake, users might be able to list files and access data from the cloud storage location until the cache expires.”Source: docs.snowflake.com
2.API integrations: allowed HTTPS endpoints
An API integration is the object Snowflake needs before it can call a service over HTTPS. It records the provider type, the identity Snowflake uses at that provider, and the endpoints it may reach. External functions are the classic case. A query that calls a third-party API through Amazon API Gateway, Azure API Management or Google API Gateway goes through an API integration. On AWS, the role ARN in API_AWS_ROLE_ARN is both the identifier and the credential. The same object type also backs Git repositories (git_https_api) and external MCP servers (external_mcp).
CREATE [ OR REPLACE ] API INTEGRATION [ IF NOT EXISTS ] <integration_name>
API_PROVIDER = { aws_api_gateway | aws_private_api_gateway | aws_gov_api_gateway | aws_gov_private_api_gateway }
API_AWS_ROLE_ARN = '<iam_role>'
[ API_KEY = '<api_key>' ]
API_ALLOWED_PREFIXES = ('<...>')
ENABLED = { TRUE | FALSE }
[ COMMENT = '<string_literal>' ]
;Yes. Each URL in the list is a prefix, so every resource under /production/ is allowed. A call to /staging/ would be rejected.
The allow-list in the integration is what limits where Snowflake can call, not the cloud role behind it. Even if the attached IAM role could reach more of AWS, functions that use the integration can only call URLs under API_ALLOWED_PREFIXES, minus anything under API_BLOCKED_PREFIXES. Snowflake's advice is to keep those prefixes as narrow as practical. Disabling the integration breaks every external function that depends on it. On Azure, one integration authenticates to a single tenant, so all of its allowed locations must belong to that tenant.
Checkpoint 3 of 5· Check yourself
A developer's API integration uses an IAM role that can invoke every API Gateway in the AWS account. API_ALLOWED_PREFIXES lists only https://xyz.amazonaws.com/production/. The developer creates an external function that calls https://abc.amazonaws.com/v1/score through this integration. What happens?
The integration's allow-list limits where Snowflake can call, whatever the IAM role could reach. This URL is not under https://xyz.amazonaws.com/production/, so the external function can't call it.
“Explicitly limits external functions that use the integration to reference one or more HTTPS proxy service endpoints (such as Amazon API Gateway)”Source: docs.snowflake.com
Sources4
3.Git repository clones
A Git repository clone brings a remote repository into a schema. It includes every branch, tag and commit, so SQL scripts and handler code can be used where queries run. Supported platforms are GitHub, GitLab, BitBucket, Azure DevOps and AWS CodeCommit, including self-hosted instances at custom URLs. Snowflake acts as one more client of the repository, so developers keep their local clones and tools. From the clone you can fetch updates, browse branches and tags, copy file paths for procedures, UDFs and tasks, and commit and push changes back from Workspaces, Streamlit apps and Snowflake Notebooks.
A clone is built on an API integration whose provider is git_https_api. The integration lists the allowed URL prefixes and the secrets the clone is allowed to use. ORIGIN must be an HTTPS URL. GIT_CREDENTIALS is optional and names a secret. If you use one, it must also appear in the integration's ALLOWED_AUTHENTICATION_SECRETS. A secret can hold the correct token and still fail if the integration doesn't list it. Creating the clone needs CREATE GIT REPOSITORY on the schema, plus USAGE on the integration and on the secret. Repositories larger than 2 GB aren't supported.
A secret is a Snowflake object that stores credentials, so the token never appears in the clone's definition. For Git token authentication you create it with CREATE SECRET, give it TYPE = password, a username, and a token such as a personal access token as the PASSWORD value. The integration then lists its name in ALLOWED_AUTHENTICATION_SECRETS, and the clone names it in GIT_CREDENTIALS.
CREATE [ OR REPLACE ] API INTEGRATION [ IF NOT EXISTS ] <integration_name>
API_PROVIDER = git_https_api
API_ALLOWED_PREFIXES = ('<...>')
[ API_BLOCKED_PREFIXES = ('<...>') ]
[ ALLOWED_AUTHENTICATION_SECRETS = ( { <secret_name> [, <secret_name>, ... ] } ) | all | none ]
ENABLED = { TRUE | FALSE }
[ COMMENT = '<string_literal>' ]
;CREATE OR REPLACE GIT REPOSITORY snowflake_extensions
API_INTEGRATION = git_api_integration
GIT_CREDENTIALS = git_secret
ORIGIN = 'https://github.com/my-account/snowflake-extensions.git';| Method | Best for | What you configure |
|---|---|---|
| No authentication | Cloning a public repository | An API integration only, with no credentials |
| Token | Automated pipelines and ML projects | A secret with username and token, allowed by the API integration |
| OAuth | Interactive development in Workspaces | An API integration with OAuth2 authentication and no secret |
The clone is managed with ALTER, DESCRIBE and DROP GIT REPOSITORY, and inspected with SHOW GIT REPOSITORIES, SHOW GIT BRANCHES and SHOW GIT TAGS. To deploy from it, EXECUTE IMMEDIATE FROM runs the SQL statements in a file, which can be in a stage or a Git repository clone. This lets a .sql file reviewed in Git become the script that builds roles, databases and schemas. The file can also be a Jinja2 template, so one script can target different environments.
A path into a clone is addressed like a stage: the repository name, then branches/<branch> or tags/<tag>, then the file path inside the repository. Listing a branch uses the same form, for example LS @repository_name/branches/branch_name;. The statement below runs create-database.sql from the sql folder on the main branch of the clone snowflake_extensions.
EXECUTE IMMEDIATE FROM @snowflake_extensions/branches/main/sql/create-database.sql;| Integration | What Snowflake reaches | How it authenticates |
|---|---|---|
| Storage integration | S3, GCS or Azure storage behind external stages | A generated IAM entity granted permissions by your cloud admin |
| API integration | An HTTPS API such as an API gateway proxy | A provider identity such as an AWS role ARN, limited by API_ALLOWED_PREFIXES |
| Git repository (on an API integration) | A remote Git server over HTTPS | None, a token secret, or OAuth, set on the git_https_api integration |
Checkpoint 4 of 5· Fill the gap
A secret named git_secret holds a valid token, and the clone names it in GIT_CREDENTIALS. Authentication still fails. Which parameter of the git_https_api integration has to list git_secret before the clone can use it?
CREATE [ OR REPLACE ] API INTEGRATION [ IF NOT EXISTS ] <integration_name>
API_PROVIDER = git_https_api
API_ALLOWED_PREFIXES = ('<...>')
[ API_BLOCKED_PREFIXES = ('<...>') ]
[ ? = ( { <secret_name> [, <secret_name>, ... ] } ) | all | none ]
ENABLED = { TRUE | FALSE }
[ COMMENT = '<string_literal>' ]
;The clone names its secret in GIT_CREDENTIALS, but the integration must also allow that secret in ALLOWED_AUTHENTICATION_SECRETS. If it isn't listed there, authentication fails even when the token is correct.
Source: docs.snowflake.comCheckpoint 5 of 5· Match them up
Match each Git use case to the authentication method Snowflake recommends for it
Tap a term, then the definition that fits it.
Scripted processes need a stored token because no one is there to sign in. OAuth makes sign-in simpler for interactive Workspaces users. A public repository needs no credentials at all.
“Automated pipelines or ML projects: configure token-based authentication so that scripted processes can access the repository without manual sign-in.”Source: docs.snowflake.com
Practise it for real
Clone a public Git repository into Snowflake and run a SQL script from it
1.Create an API integration with API_PROVIDER = git_https_api, API_ALLOWED_PREFIXES set to the public repository's HTTPS prefix, and ENABLED = TRUE.
Why: Every Git repository clone needs a git_https_api integration that allows its URL. A public repository needs no secret.
You should see: SHOW INTEGRATIONS lists the new API integration.
2.Run CREATE GIT REPOSITORY with ORIGIN set to the repository's HTTPS URL and API_INTEGRATION set to your integration. Leave out GIT_CREDENTIALS.
Why: GIT_CREDENTIALS is optional when the repository doesn't require authentication.
You should see: The clone is created in your current schema.
3.Run SHOW GIT BRANCHES and SHOW GIT TAGS on the clone.
Why: The clone includes all branches, tags and commits from the remote repository.
You should see: The repository's branches and tags are listed.
4.Find a .sql file in the clone and build its path from the clone name, the branch (or tag) and the file path, then run EXECUTE IMMEDIATE FROM with it. For a clone named snowflake_extensions, that looks like: EXECUTE IMMEDIATE FROM @snowflake_extensions/branches/main/sql/create-database.sql;
Why: EXECUTE IMMEDIATE FROM runs the statements in a file stored in a stage or a Git repository clone, and the clone is addressed like a stage.
You should see: The script's statements run in your session.
Stuck? Get a nudge
If the CREATE GIT REPOSITORY statement is rejected, compare ORIGIN against API_ALLOWED_PREFIXES. The origin URL has to fall under one of the allowed prefixes.
Sources
(10)
Every claim above is drawn from one of these pages, quoted as it was written on the date shown.
- 1.
“This option allows users to avoid supplying credentials when creating stages or when loading or unloading data.”
↩︎ Storage integrations: stage access without stored keys“A single storage integration can support multiple external stages.”
↩︎ Storage integrations: stage access without stored keys“use the CREDENTIALS parameter in the CREATE STAGE command (rather than using a storage integration) to provide the credentials for authentication.”
↩︎ Storage integrations: stage access without stored keys“Existing stages that reference this integration cannot access the storage location in the stage definition.”
↩︎ Exam trap 1“Existing stages that reference this integration cannot access the storage location in the stage definition.”
↩︎ Prediction - 2.
“Integrations are named, first-class Snowflake objects that avoid the need for passing explicit cloud provider credentials”
↩︎ Storage integrations: stage access without stored keys“In a later step, you will modify the trust relationship for your IAM role and specify the external ID for your storage integration.”
↩︎ Storage integrations: stage access without stored keys“Snowflake creates a single IAM user that is referenced by all S3 storage integrations in your Snowflake account.”
↩︎ Storage integrations: stage access without stored keys“Only account administrators (users with the ACCOUNTADMIN role) or a role with the global CREATE INTEGRATION privilege can execute this SQL command.”
↩︎ Storage integrations: stage access without stored keys“The URL in the stage definition must align with the S3 buckets (and optional paths) specified for the STORAGE_ALLOWED_LOCATIONS parameter.”
↩︎ Storage integrations: stage access without stored keys“Snowflake caches the temporary credentials for a period that cannot exceed the 60-minute expiration time.”
↩︎ Storage integrations: stage access without stored keys“Snowflake caches the temporary credentials for a period that cannot exceed the 60-minute expiration time.”
↩︎ Exam trap 2“If you revoke access from Snowflake, users might be able to list files and access data from the cloud storage location until the cache expires.”
↩︎ Checkpoint - 3.https://docs.snowflake.com/en/sql-reference/sql-allOfficial docs
“named internal or external stage to use for loading data from files into Snowflake tables and unloading data from tables into files”
↩︎ Storage integrations: stage access without stored keys - 4.
“An API integration object stores information about a service reached via HTTPS API”
↩︎ API integrations: allowed HTTPS endpoints“An API integration object also specifies allowed (and optionally blocked) endpoints and resources on those services.”
↩︎ API integrations: allowed HTTPS endpoints“If the API integration is disabled, any external function that relies on it will not work.”
↩︎ API integrations: allowed HTTPS endpoints“To maximize security, you should restrict allowed locations as narrowly as practical.”
↩︎ API integrations: allowed HTTPS endpoints“An API integration can authenticate to only one tenant”
↩︎ API integrations: allowed HTTPS endpoints“Explicitly limits external functions that use the integration to reference one or more HTTPS proxy service endpoints (such as Amazon API Gateway)”
↩︎ Checkpoint - 5.
“The clone includes all branches, tags, and commits from the remote repository.”
↩︎ Git repository clones“Commit and push changes to the remote repository from Workspaces, Streamlit apps, and Snowflake notebooks.”
↩︎ Git repository clones - 6.
“The API integration you specify here must have an API_PROVIDER parameter whose value is set to git_https_api.”
↩︎ Git repository clones“The URL must use HTTPS.”
↩︎ Git repository clones“ALTER GIT REPOSITORY, DESCRIBE GIT REPOSITORY, DROP GIT REPOSITORY, SHOW GIT BRANCHES, SHOW GIT REPOSITORIES, SHOW GIT TAGS”
↩︎ Git repository clones“As a best practice, use a personal access token for the secret’s PASSWORD value.”
↩︎ Git repository clones“The secret you specify here must be a secret specified by the ALLOWED_AUTHENTICATION_SECRETS parameter of the API integration”
↩︎ Exam trap 3 - 7.
“A TYPE value of password A username and token, such as a personal access token (PAT)”
↩︎ Git repository clones - 8.
“EXECUTE IMMEDIATE FROM @snowflake_extensions/branches/main/sql/create-database.sql;”
↩︎ Git repository clones“LS @repository_name/tags/tag_name;”
↩︎ Git repository clones - 9.
“In this case, you don’t need to create a secret.”
↩︎ Git repository clones“Automated pipelines or ML projects: configure token-based authentication so that scripted processes can access the repository without manual sign-in.”
↩︎ Checkpoint - 10.
“EXECUTE IMMEDIATE FROM executes the SQL statements specified in a file in a stage.”
↩︎ Git repository clones“Located in a stage or Git repository clone.”
↩︎ Git repository clones