Attach a resource to an app
attach_resourceAttach a resource to an app: a named set of environment variables, such as a database's connection string, that the app reads as secrets. Name the resource. When the organization has none by that name, pass a provider from list_catalog_resources and the first call creates it, returning at once with state provisioning. Call again with the same arguments, env_prefix included, until the state is attached: the call that finds the resource ready attaches it and sets its variables, restarting the app if it is running. An existing resource attaches by name alone, including one another app holds. The call is safe to repeat: one name is one resource however many times it is called, and an app can hold several under different names. Pass env_prefix when two resources would set the same variables. Read the names an attachment sets from list_catalog_resources before writing the app's code. A new database is empty, so the app creates its own tables, and its URL carries the TLS settings it needs. The app must exist, so publish it first. After the attach restarts it, get_service shows whether it is running again. Provisioning takes about a minute; call again every ten seconds. Values are never returned here. Requires connecting a Valet account.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | Required. The app's name. | |
| plan | No | The provider's plan. Omit to use its first plan. Repeat it on every call for one resource. | |
| org_name | No | The Valet organization the app belongs to. Omit to use the organization the account joined first. | |
| provider | No | The provider to create the resource from, from list_catalog_resources. Required when the organization has no resource by this name. | |
| resource | Yes | Required. The resource's name in the organization, such as shop-db: 3 to 63 lowercase letters, digits, and hyphens. Repeat it on every call for one resource. | |
| env_prefix | No | Set the resource's variables under PREFIX_NAME rather than NAME: an uppercase letter, then up to 31 uppercase letters, digits, and underscores. Omit to use the names as they are. Repeat it on every call for one resource: it applies on the call that attaches. |