Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions src/content/docs/snowflake/capabilities/accounts.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
---
title: Accounts
description: Get started with Accounts in LocalStack for Snowflake
---

## Introduction

An account is a unique identifier for a Snowflake instance within an organization. It acts as a container
for resources and operations related to data storage, processing, and management.

The Snowflake emulator lets you connect to and manage resources in different accounts.

## Getting Started

This guide explains how to start and connect to the Snowflake emulator using specific accounts.

You can specify any account name when connecting to the Snowflake emulator. If you don't, all resources
will be managed by the default `test` account.

Depending on the Snowflake Driver you choose, you can pass `account` accordingly.

### Connect using Snowflake Connection Object

If the Snowflake driver provides a connection object, you can pass the `account` parameter in the connection object.

Example using the Snowflake Connector for Python:

```python
sf_conn_obj = sf.connect(
account="your_account",
# other parameters
)
```

Example using the NodeJS Driver for Snowflake:

```javascript
var connection = snowflake.createConnection({
account: "your_account",
// other parameters
});
```

### Connect using Connection String

You can also specify the account for Snowflake drivers that let you connect with a connection string.

Example establishing a JDBC connection:

```
jdbc:snowflake://snowflake.localhost.localstack.cloud:4566/?account=your_account
```

### Check Current Account

Once successfully connected, you can verify which account you are connected to by executing the following SQL command:

```sql
SELECT CURRENT_ACCOUNT_NAME();
```

The query statement will return the name of the account you are currently connected to. Output should look like:

```sql
+------------------------------------------+
| CURRENT_ACCOUNT_NAME() |
|------------------------------------------|
| YOUR_ACCOUNT |
+------------------------------------------+
```
113 changes: 113 additions & 0 deletions src/content/docs/snowflake/capabilities/clones.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: Clones
description: Get started with Clones in LocalStack for Snowflake
---

{{< preview-notice >}}

## Introduction

Cloning in Snowflake allows you to create a quick, zero-copy duplicate of an existing database, schema, or table. This feature enables users to replicate data structures and content for testing or development without duplicating the underlying storage.

The Snowflake emulator supports database cloning, enabling you to create quick duplicates of databases, schemas, or tables. Currently, [`CREATE ... CLONE`](https://docs.snowflake.com/en/sql-reference/sql/create-clone) is supported by LocalStack.

## Getting started

This guide assumes basic knowledge of SQL and Snowflake. Start your Snowflake emulator and connect to it using an SQL client to execute the queries below.

The following sections guide you through creating a database, inserting data into a table, and then cloning the database to verify data integrity.

### Create a Database

The following SQL snippet demonstrates how to create a database named `test_db`.

```sql
CREATE DATABASE test_db;`
```

The expected output is:

```sql
+--------------------------------------------+
| status |
|--------------------------------------------|
| Database TEST_DB successfully created. |
+--------------------------------------------+
0 Row(s) produced. Time Elapsed: 0.123s
```

### Create a Table

Once the database is created, you can create a table within it. The following SQL statement demonstrates how to create a table named `test_table` with columns for `id` and `name`.

```sql
CREATE TABLE test_table (id INT, name TEXT);`
```

The expected output is:

```sql
+----------------------------------------+
| status |
|----------------------------------------|
| Table TEST_TABLE successfully created. |
+----------------------------------------+
0 Row(s) produced. Time Elapsed: 0.067s
```

### Insert Data

To insert data into the `test_table`, use the `INSERT INTO` statement. This example inserts a single row with the values `(1, 'test')`.

```sql
INSERT INTO test_table VALUES (1, 'test');
```

The expected output is:

```sql
+----------------------------------------+
| status |
|----------------------------------------|
| 1 Row(s) inserted. |
+----------------------------------------+
1 Row(s) produced. Time Elapsed: 0.024s
```

### Create a Clone

With data now in `test_table`, you can create a clone of the entire `test_db` database. This will produce a new database, `test_db_clone`, containing all objects and data from the original `test_db`.

```sql
CREATE DATABASE test_db_clone CLONE test_db;
```

The expected output is:

```sql
+--------------------------------------------+
| status |
|--------------------------------------------|
| Database TEST_DB_CLONE successfully created. |
+--------------------------------------------+
0 Row(s) produced. Time Elapsed: 0.101s
```

### Verify Data in Clone

To confirm that the data has been cloned, query the `test_table` in the `test_db_clone` database.

```sql
SELECT * FROM test_db_clone.test_table;
```

The expected output is:

```sql
+----+------+
| id | name |
|----|------|
| 1 | test |
+----+------+
1 Row(s) produced. Time Elapsed: 0.012s
```
113 changes: 113 additions & 0 deletions src/content/docs/snowflake/capabilities/config.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
---
title: Configuration
description: Overview of configuration options in LocalStack for Snowflake.
template: doc
nav:
label:
---


{{< preview-notice >}}

LocalStack exposes various configuration options to control its behaviour.

These options can be passed to LocalStack as environment variables like so:

{{< command >}}
$ DEBUG=1 localstack start
{{< / command >}}

## Core

Options that affect the core Snowflake emulator functionality.

| Variable | Example Values | Description |
|----------|----------------------|-------------------------------------------------------------------------------------------------------------|
| `DEBUG` | `0` (default) \| `1` | Flag to increase log level and print more verbose logs (useful for troubleshooting issues) |
| `SF_LOG` | `trace` | Specify the log level. Currently overrides the `DEBUG` configuration. `trace` for detailed request/response |
| `SF_S3_ENDPOINT` | `s3.localhost.localstack.cloud:4566` (default) | Specify the S3 endpoint to use for the Snowflake emulator. |
| `DNS_NAME_PATTERNS_TO_RESOLVE_UPSTREAM` | `*.s3.amazonaws.com` (example) | List of domain names that should NOT be resolved to the LocalStack container, but instead always forwarded to the upstream resolver (S3 for example). this would be required when importing data into a stage from an external S3 bucket on the real AWS cloud. Comma-separated list of Python-flavored regex patterns. |
| `SF_HOSTNAME_REGEX` | `snowflake\..+` (default) | Allows you to customize the hostname used for matching the Snowflake API routes in the HTTP router. If not set, then it matches on any hostnames that contain a `snowflake.*` subdomain (e.g., `snowflake.localhost.localstack.cloud`). |
| `SF_CSV_IMPORT_MAX_ROWS` | `50000` (default) | Maximum number of rows to import from CSV files into tables |
| `SF_DEFAULT_USER` | `test` (default) | Specify the default user to be used by the Snowflake emulator. |
| `SF_DEFAULT_PASSWORD` | `test` (default) | Specify the default password to be used by the Snowflake emulator. |

## CLI

These options are applicable when using the CLI to start LocalStack.

| Variable | Example Values | Description |
| - | - | - |
| `LOCALSTACK_VOLUME_DIR` | `~/.cache/localstack/volume` (on Linux) | The location on the host of the LocalStack volume directory mount. |
| `CONFIG_PROFILE` | | The configuration profile to load. See [Profiles]({{< ref "#profiles" >}}) |
| `CONFIG_DIR` | `~/.localstack` | The path where LocalStack can find configuration profiles and other CLI-specific configuration |

## Docker

Options to configure how LocalStack interacts with Docker.

| Variable | Example Values | Description |
| - | - | - |
| `DOCKER_FLAGS` | | Allows to pass custom flags (e.g., volume mounts) to "docker run" when running LocalStack in Docker. |
| `DOCKER_SOCK` | `/var/run/docker.sock` | Path to local Docker UNIX domain socket |
| `DOCKER_BRIDGE_IP` | `172.17.0.1` | IP of the Docker bridge used to enable access between containers |
| `LEGACY_DOCKER_CLIENT` | `0`\|`1` | Whether LocalStack should use the command-line Docker client and subprocess execution to run Docker commands, rather than the Docker SDK. |
| `DOCKER_CMD` | `docker` (default), `sudo docker`| Shell command used to run Docker containers (only used in combination with `LEGACY_DOCKER_CLIENT`) |
| `FORCE_NONINTERACTIVE` | | When running with Docker, disables the `--interactive` and `--tty` flags. Useful when running headless. |

## Proxy Configuration

Options to configure Snowflake proxy settings for LocalStack.

| Variable | Example Values | Description |
| - | - | - |
| `SF_PROXY_HOST` | `proxy.example.com` | Hostname or IP address of the proxy server to be used for connecting to Snowflake. |
| `SF_PROXY_USER` | `proxy_user` | Username for authentication with the proxy server. |
| `SF_PROXY_PASSWORD` | `password123` | Password associated with the proxy user account. |

## Profiles

LocalStack supports configuration profiles which are stored in the `~/.localstack` config directory.
A configuration profile is a set of environment variables stored in a `*.env` file in the LocalStack config directory.

Here is an example of what configuration profiles might look like:

{{< command >}}
$ tree ~/.localstack
/home/username/.localstack
├── default.env
├── dev.env
└── pro.env
{{< / command >}}

Here is an example of what a specific environment profile looks like

{{< command >}}
$ cat ~/.localstack/pro-debug.env
LOCALSTACK_AUTH_TOKEN=XXXXX
SF_LOG=trace
SF_S3_ENDPOINT=s3.localhost.localstack.cloud:4566
{{< / command >}}

You can load a profile by either setting the environment variable `CONFIG_PROFILE=<profile>` or the `--profile=<profile>` CLI flag when using the CLI.
Let's take an example to load the `dev.env` profile file if it exists:

{{< command >}}
$ IMAGE_NAME=localstack/snowflake localstack --profile=dev start
{{< / command >}}

If no profile is specified, the `default.env` profile will be loaded.
If explicitly specified, any environment variables will overwrite the configurations defined in the profile.

To display the config environment variables, you can use the following command:

{{< command >}}
$ localstack --profile=dev config show
{{< / command >}}

{{< alert title="Note" >}}
The `CONFIG_PROFILE` is a CLI feature and cannot be used directly with a docker-compose setup.
You can look at [alternative means of setting environment variables](https://docs.docker.com/compose/environment-variables/set-environment-variables/) for your Docker Compose setups.
For Docker setups, we recommend passing the environment variables directly to the `docker run` command.
{{< /alert >}}

29 changes: 29 additions & 0 deletions src/content/docs/snowflake/capabilities/ephemeral-instances.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Ephemeral Instances
description: Get started with Ephemeral Instances in LocalStack for Snowflake
---

{{< preview-notice >}}

## Introduction

Ephemeral Instances allows you to run a LocalStack for Snowflake instance in the cloud. You can interact with these instances by configuring your Snowflake host with the endpoint URL of the ephemeral instance.

{{< alert title="Note" >}}
Ephemeral Instances is offered as a **preview** feature and under active development.
{{< /alert >}}

## Getting started

Navigate to the [LocalStack Ephemeral Instance Management](https://app.localstack.cloud/instances/ephemeral) page. In the form, enter the name of the new Ephemeral Instance, choose **LocalStack Snowflake (preview)**, select the lifetime of the instance by dragging the slider, and click on **Launch**.

<img src="ephemeral-instance-creation.png" alt="Creating an Ephemeral Instance" title="Creating an Ephemeral Instance" width="800" />

After the ephemeral instance is created, you can run the following command to verify the status of the instance:

{{< command >}}
$ export SNOWFLAKE_HOST=<ephemeral-instance-endpoint>
$ curl -d '{}' $SNOWFLAKE_HOST/session
{{< /command >}}

You can access the Ephemeral Instance via the SnowSQL or any alternative SQL client by configuring the Snowflake host with the endpoint URL of the Ephemeral Instance.
9 changes: 9 additions & 0 deletions src/content/docs/snowflake/capabilities/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
---
title: Capabilities
description: Capabilities
template: doc
nav:
label:
---

# Capabilities
Loading
Loading