databricks.getTables
Retrieves a list of managed or external table full names in Unity Catalog, that were created by Pulumi or manually. Use databricks.getViews for retrieving a list of views.
This data source can only be used with a workspace-level provider!
Example Usage
Granting SELECT and MODIFY to sensitive group on all tables a things databricks.Schema from sandbox databricks_catalog:
import * as pulumi from "@pulumi/pulumi";
import * as databricks from "@pulumi/databricks";
export = async () => {
const things = await databricks.getTables({
catalogName: "sandbox",
schemaName: "things",
});
const thingsGrants: databricks.Grants[] = [];
for (const range of things.ids.map((v, k) => ({key: k, value: v}))) {
thingsGrants.push(new databricks.Grants(`things-${range.key}`, {
table: range.value,
grants: [{
principal: "sensitive",
privileges: [
"SELECT",
"MODIFY",
],
}],
}));
}
}
import pulumi
import pulumi_databricks as databricks
things = databricks.get_tables(catalog_name="sandbox",
schema_name="things")
things_grants = []
for range in [{"key": k, "value": v} for [k, v] in enumerate(things.ids)]:
things_grants.append(databricks.Grants(f"things-{range['key']}",
table=range["value"],
grants=[{
"principal": "sensitive",
"privileges": [
"SELECT",
"MODIFY",
],
}]))
package main
import (
"github.com/pulumi/pulumi-databricks/sdk/go/databricks"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
things, err := databricks.GetTables(ctx, &databricks.GetTablesArgs{
CatalogName: "sandbox",
SchemaName: "things",
}, nil)
if err != nil {
return err
}
var thingsGrants []*databricks.Grants
for key0, val0 := range things.Ids {
__res, err := databricks.NewGrants(ctx, fmt.Sprintf("things-%v", key0), &databricks.GrantsArgs{
Table: pulumi.String(val0),
Grants: databricks.GrantsGrantArray{
&databricks.GrantsGrantArgs{
Principal: pulumi.String("sensitive"),
Privileges: pulumi.StringArray{
pulumi.String("SELECT"),
pulumi.String("MODIFY"),
},
},
},
})
if err != nil {
return err
}
thingsGrants = append(thingsGrants, __res)
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Pulumi;
using Databricks = Pulumi.Databricks;
return await Deployment.RunAsync(async() =>
{
var things = await Databricks.GetTables.InvokeAsync(new()
{
CatalogName = "sandbox",
SchemaName = "things",
});
var thingsGrants = new List<Databricks.Grants>();
foreach (var range in )
{
thingsGrants.Add(new Databricks.Grants($"things-{range.Key}", new()
{
Table = range.Value,
GrantDetails = new[]
{
new Databricks.Inputs.GrantsGrantArgs
{
Principal = "sensitive",
Privileges = new[]
{
"SELECT",
"MODIFY",
},
},
},
}));
}
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.databricks.DatabricksFunctions;
import com.pulumi.databricks.inputs.GetTablesArgs;
import com.pulumi.databricks.Grants;
import com.pulumi.databricks.GrantsArgs;
import com.pulumi.databricks.inputs.GrantsGrantArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var things = DatabricksFunctions.getTables(GetTablesArgs.builder()
.catalogName("sandbox")
.schemaName("things")
.build());
final var thingsGrants = things.applyValue(getTablesResult -> {
final var resources = new ArrayList<Grants>();
for (var range : KeyedValue.of(getTablesResult.ids())) {
var resource = new Grants("thingsGrants-" + range.key(), GrantsArgs.builder()
.table(range.value())
.grants(GrantsGrantArgs.builder()
.principal("sensitive")
.privileges(
"SELECT",
"MODIFY")
.build())
.build());
resources.add(resource);
}
return resources;
});
}
}
resources:
thingsGrants:
type: databricks:Grants
name: things
properties:
table: ${range.value}
grants:
- principal: sensitive
privileges:
- SELECT
- MODIFY
options: {}
variables:
things:
fn::invoke:
function: databricks:getTables
arguments:
catalogName: sandbox
schemaName: things
Related Resources
The following resources are used in the same context:
* databricks.Schema to manage schemas within Unity Catalog. * databricks.Catalog to manage catalogs within Unity Catalog.
Using getTables
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getTables(args: GetTablesArgs, opts?: InvokeOptions): Promise<GetTablesResult>
function getTablesOutput(args: GetTablesOutputArgs, opts?: InvokeOptions): Output<GetTablesResult>def get_tables(catalog_name: Optional[str] = None,
ids: Optional[Sequence[str]] = None,
provider_config: Optional[GetTablesProviderConfig] = None,
schema_name: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetTablesResult
def get_tables_output(catalog_name: Optional[pulumi.Input[str]] = None,
ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
provider_config: Optional[pulumi.Input[GetTablesProviderConfigArgs]] = None,
schema_name: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetTablesResult]func GetTables(ctx *Context, args *GetTablesArgs, opts ...InvokeOption) (*GetTablesResult, error)
func GetTablesOutput(ctx *Context, args *GetTablesOutputArgs, opts ...InvokeOption) GetTablesResultOutput> Note: This function is named GetTables in the Go SDK.
public static class GetTables
{
public static Task<GetTablesResult> InvokeAsync(GetTablesArgs args, InvokeOptions? opts = null)
public static Output<GetTablesResult> Invoke(GetTablesInvokeArgs args, InvokeOptions? opts = null)
}public static CompletableFuture<GetTablesResult> getTables(GetTablesArgs args, InvokeOptions options)
public static Output<GetTablesResult> getTables(GetTablesArgs args, InvokeOptions options)
fn::invoke:
function: databricks:index/getTables:getTables
arguments:
# arguments dictionaryThe following arguments are supported:
- Catalog
Name string - Name of databricks_catalog
- Schema
Name string - Name of databricks_schema
- Ids List<string>
- set of databricks.Table full names:
catalog.schema.table - Provider
Config GetTables Provider Config - Configure the provider for management through account provider. This block consists of the following fields:
- Catalog
Name string - Name of databricks_catalog
- Schema
Name string - Name of databricks_schema
- Ids []string
- set of databricks.Table full names:
catalog.schema.table - Provider
Config GetTables Provider Config - Configure the provider for management through account provider. This block consists of the following fields:
- catalog
Name String - Name of databricks_catalog
- schema
Name String - Name of databricks_schema
- ids List<String>
- set of databricks.Table full names:
catalog.schema.table - provider
Config GetTables Provider Config - Configure the provider for management through account provider. This block consists of the following fields:
- catalog
Name string - Name of databricks_catalog
- schema
Name string - Name of databricks_schema
- ids string[]
- set of databricks.Table full names:
catalog.schema.table - provider
Config GetTables Provider Config - Configure the provider for management through account provider. This block consists of the following fields:
- catalog_
name str - Name of databricks_catalog
- schema_
name str - Name of databricks_schema
- ids Sequence[str]
- set of databricks.Table full names:
catalog.schema.table - provider_
config GetTables Provider Config - Configure the provider for management through account provider. This block consists of the following fields:
- catalog
Name String - Name of databricks_catalog
- schema
Name String - Name of databricks_schema
- ids List<String>
- set of databricks.Table full names:
catalog.schema.table - provider
Config Property Map - Configure the provider for management through account provider. This block consists of the following fields:
getTables Result
The following output properties are available:
- Catalog
Name string - Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- set of databricks.Table full names:
catalog.schema.table - Schema
Name string - Provider
Config GetTables Provider Config
- Catalog
Name string - Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- set of databricks.Table full names:
catalog.schema.table - Schema
Name string - Provider
Config GetTables Provider Config
- catalog
Name String - id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- set of databricks.Table full names:
catalog.schema.table - schema
Name String - provider
Config GetTables Provider Config
- catalog
Name string - id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- set of databricks.Table full names:
catalog.schema.table - schema
Name string - provider
Config GetTables Provider Config
- catalog_
name str - id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- set of databricks.Table full names:
catalog.schema.table - schema_
name str - provider_
config GetTables Provider Config
- catalog
Name String - id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- set of databricks.Table full names:
catalog.schema.table - schema
Name String - provider
Config Property Map
Supporting Types
GetTablesProviderConfig
- Workspace
Id string - Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.
- Workspace
Id string - Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.
- workspace
Id String - Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.
- workspace
Id string - Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.
- workspace_
id str - Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.
- workspace
Id String - Workspace ID which the resource belongs to. This workspace must be part of the account which the provider is configured with.
Package Details
- Repository
- databricks pulumi/pulumi-databricks
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
databricksTerraform Provider.
