-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #342 from subsquid/sorted-layout
Sorted layout
- Loading branch information
Showing
82 changed files
with
423 additions
and
298 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
sdk/resources/subsquid-vs-thegraph.md -> sdk/subsquid-vs-thegraph.md | ||
sdk/reference/processors/architecture.mdx -> sdk/resources/processor/architecture.mdx | ||
sdk/resources/evm -> sdk/resources/processor/evm | ||
sdk/resources/evm/factory-contracts.md -> sdk/resources/processor/evm/factory-contracts.md | ||
sdk/resources/evm/proxy-contracts.md -> sdk/resources/processor/evm/proxy-contracts.md | ||
sdk/resources/substrate -> sdk/resources/processor/substrate | ||
sdk/resources/substrate/data-sourcing-miniguide.md -> sdk/resources/processor/substrate/data-sourcing-miniguide.md | ||
sdk/resources/substrate/frontier-evm.md -> sdk/resources/processor/substrate/frontier-evm.md | ||
sdk/resources/substrate/gear.md -> sdk/resources/processor/substrate/gear.md | ||
sdk/resources/substrate/ink.md -> sdk/resources/processor/substrate/ink.md | ||
sdk/resources/persisting-data -> sdk/resources/store | ||
sdk/resources/persisting-data/bigquery.md -> sdk/resources/store/bigquery.md | ||
sdk/resources/persisting-data/file.md -> sdk/resources/store/file.md | ||
sdk/resources/persisting-data/overview.md -> sdk/resources/store/overview.md | ||
sdk/resources/persisting-data/typeorm.md -> sdk/resources/store/typeorm.md | ||
sdk/resources/unfinalized-blocks.mdx -> sdk/resources/processor/unfinalized-blocks.mdx | ||
sdk/resources/multichain.md -> sdk/resources/integration/multichain.md | ||
sdk/resources/batch-processing.md -> sdk/resources/integration/batch-processing.md | ||
sdk/resources/squid-gen.md -> sdk/resources/integration/squid-gen.md | ||
sdk/resources/external-api.md -> sdk/resources/processor/external-api.md | ||
sdk/resources/self-hosting.md -> sdk/resources/integration/self-hosting.md | ||
sdk/resources/migrate -> sdk/resources/integration/migrate | ||
sdk/resources/migrate/migrate-subgraph.md -> sdk/resources/integration/migrate/migrate-subgraph.md | ||
sdk/resources/migrate/migrate-to-arrowsquid-on-substrate.md -> sdk/resources/integration/migrate/migrate-to-arrowsquid-on-substrate.md | ||
sdk/resources/migrate/migrate-to-arrowsquid.md -> sdk/resources/integration/migrate/migrate-to-arrowsquid.md | ||
sdk/troubleshooting/persisting-data.md -> sdk/troubleshooting/store.md |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,91 @@ | ||
--- | ||
sidebar_position: 80 | ||
sidebar_position: 20 | ||
title: Environment variables | ||
description: |- | ||
Add secrets and custom env variables | ||
Variables, namespaces, secrets | ||
--- | ||
|
||
# Environment variables | ||
:::info | ||
Store all your sensitive inputs (API keys, passwords etc) as [secrets](#secrets). | ||
::: | ||
|
||
Subsquid Cloud supports adding environment variables to squid deployments. The variables can be defined as key-value pairs at any of the `env:` sections of the [manifest](/cloud/reference/manifest). | ||
|
||
For example, here is how to add a variable that will be visible only to the [squid processor](/cloud/reference/manifest/#processor): | ||
```yaml title="squid.yaml" | ||
deploy: | ||
processor: | ||
env: | ||
MY_PROCESSOR_VAR: string_value | ||
``` | ||
You can also add variables visible only to the [GraphQL server](/cloud/reference/manifest/#api) or to the [migration script](/cloud/reference/manifest/#migrate). | ||
There is also an option to add variables [for all services](/cloud/reference/manifest/#env): | ||
```yaml title="squid.yaml" | ||
deploy: | ||
env: | ||
MY_SQUIDWIDE_VAR: string_value | ||
``` | ||
Variables can be assigned either to strings, or to member variables of [namespaces](#namespaces) provided by the service. For example, to make a processor-scoped `API_KEY` variable and populate it with the value of `secrets.API_KEY`, do this: | ||
```yaml title="squid.yaml" | ||
deploy: | ||
processor: | ||
env: | ||
RPC_ENDPOINT: ${{ secrets.API_KEY }} | ||
``` | ||
|
||
Subsquid Cloud supports adding environment variables to the squid deployments. There are two kinds: **secrets** and **environment variables**. The crucial difference is that the secrets are injected to all squids, while environments variables are set only to a specific version deployment. Environment variables are stored in plain text so **all the sensitive input (e.g. API keys) must be set as a secret**. | ||
## Database variables shadowing | ||
|
||
Secrets are set using the special command [`sqd secrets`](/squid-cli/secrets), while environment variables are set in the [deployment manifest](/cloud/reference/manifest). | ||
There is one special case in which the variables defined in the manifest will get overwritten by the Cloud: [database connection settings](/sdk/reference/store/typeorm/#database-connection-parameters) are shadowed by the system-defined values whenever the [`postgres` addon](/cloud/reference/pg) is enabled. For example, in the snippet below all the `DB_*` variable definitions will be ignored: | ||
```yaml title="squid.yaml" | ||
deploy: | ||
addons: | ||
postgres: | ||
env: | ||
DB_HOST: mypostgreshost.xyz | ||
DB_PORT: 5432 | ||
DB_NAME: squid-tests | ||
DB_USER: me | ||
DB_PASS: ${{ secrets.DATABASE_PASSWORD }} | ||
DB_SSL: true | ||
``` | ||
|
||
## Secrets | ||
## Namespaces | ||
|
||
Secrets are designed to store sensitive data that all the squids can access as an environment variable with the given name. A typical usage is an API key or a private URL for a chain gRPC endpoint. The secrets are defined at the Cloud [organization](/cloud/resources/organizations) level and are exposed to all organization squids that [request them in their manifest](/cloud/reference/manifest/#secrets). | ||
### Secrets | ||
|
||
Secrets are designed to store sensitive data, such as API keys or private URLs for chain RPC endpoints. They are defined at the [organization](/cloud/resources/organizations) level and are exposed to all organization squids that request them in their environment variable definitions. | ||
|
||
To add a secret: | ||
1. Create it in the Cloud: | ||
|
||
1. Create it in the Cloud. You can do it at the [secrets page](https://app.subsquid.io/secrets) or with [`sqd secrets`](/squid-cli/secrets): | ||
```bash | ||
sqd secrets set MOONRIVER_GRPC_ENDPOINT wss://moonriver.my-endpoint.com/ws/my-secret-key | ||
``` | ||
2. Add it to the [manifest](/cloud/reference/manifest): | ||
2. At your squid's [manifest](/cloud/reference/manifest), add an environment variable and assign it to the secret: | ||
```yaml | ||
deploy: | ||
secrets: | ||
- MOONRIVER_GRPC_ENDPOINT | ||
env: | ||
RPC_ENDPOINT: ${{ secrets.MOONRIVER_GRPC_ENDPOINT }} | ||
``` | ||
Note: a deployment requesting a secret unknown to the Cloud will fail. | ||
3. Access in the squid with `process.env`: | ||
Note: **a deployment requesting a secret unknown to the Cloud will fail**. | ||
3. Access the value in the squid with `process.env`, e.g. | ||
```ts | ||
const processor = new EvmBatchProcessor() | ||
.setDataSource({ | ||
archive: lookupArchive("moonriver", { type: 'EVM' }), | ||
chain: { | ||
url: process.env.MOONRIVER_GRPC_ENDPOINT, | ||
rateLimit: 1000rps | ||
} | ||
}) | ||
.setDataSource({ | ||
archive: lookupArchive('moonriver', { type: 'EVM' }), | ||
chain: { | ||
url: process.env.RPC_ENDPOINT, | ||
rateLimit: 1000rps | ||
} | ||
}) | ||
``` | ||
|
||
Inspect, remove and update the secrets using the [`sqd secrets`](/squid-cli/secrets) command. | ||
|
||
:::info | ||
Any changes to secrets will take effect only when the squid is restarted with [`sqd deploy`](/squid-cli/deploy). | ||
::: | ||
|
||
## Environment variables | ||
|
||
Squid-specific environment variables should be defined in the [deployment manifest](/cloud/reference/manifest). | ||
|
||
**Example** | ||
|
||
```yaml title="squid.yaml" | ||
# ... | ||
deploy: | ||
# ... | ||
processor: | ||
env: | ||
SQD_DEBUG: | ||
sqd:mapping | ||
cmd: [ "sqd", "process:prod" ] | ||
# .... | ||
Any changes to secrets will take effect only when the squid is restarted, e.g. with | ||
```bash | ||
sqd deploy . | ||
``` | ||
|
||
|
||
|
||
::: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 50 | ||
sidebar_position: 30 | ||
title: Inspect logs | ||
description: Inspect the deployment logs | ||
--- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
--- | ||
sidebar_position: 15 | ||
sidebar_position: 50 | ||
title: Organizations | ||
description: |- | ||
Grouping squids | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.