使用Terraform工具在10分钟内构建UnityCatalog环境

首先

Unity Catalog虽然具有出色的功能,但是创建新的IAM Role、创建S3 Bucket、向工作空间添加元数据存储或者对元数据存储进行管理组配置等初始设置实在有点繁琐。

在Databricks中,我们提供了Terraform提供者来支持自动化构建。当然,我们也支持Unity目录,并且这次尝试使用了它。

這次使用的原始模板在這裡。我們稍作更改以進行使用,包括使用者建立的部分。

https://github.com/databricks/unity-catalog-setup

使用模板进行自动化的内容

使用这次的Terraform模板,可以构建以下环境的设置。

    • [AWS] S3 Bucket for metastore

[AWS] IAM role and policy for metastore

[Databricks Account Console] Metastore管理グループ作成

[Databricks Account Console] Metastore の登録

[Databricks Account Console] WorkspaceへのMetastore Assign

[Workspace] Storage Credentialの登録

[Workspace] Catalog作成

[Workspace] Schema作成

0.准备工作

我会预先设置以下环境。

    • terraform CLI —download from terraform

AWS CLI — download, setup

假设您已经有Databricks Workspace环境。

    • Databricks Account User (Admin権限あり)

 

    Workspace (Unity Catalogを利用するWorkspaceを予め準備しておく)

这次我们从上述环境已经齐备的状态开始。。

1. 下载模板

这次使用的terraform模板是这个。

git clone https://github.com/maroon-spec/unity_setup_aws.git

2. 设置变量参数

在構建本次環境時,以下的信息將會是必需的。
打開unity_catalog.auto.tfvars文件,並指定以下參數以進行覆蓋。

パラメータ例説明aws_region”ap-northeast-1″AWS Regionaws_profile”default”AWS CLI profilecreate_aws_resourcestruetrueのみunity_metastore_bucket”databricks-uc-tf-metastore”metastore用S3bucket名unity_metastore_iam”uc-tf-role” metastore用IAM Role名databricks_workspace_ids[“19710001324″,”17899832448″] WorkspaceIDリストunity_admin_group”tf_admin_group” metastore Ownerグループ名databricks_account_id”xxx-xxxxx-xxxx-xxx”
databricks_workspace_host”https://dbc-xxdfdes.cloud.databricks.com“Workspace namedatabricks_account_username”hoge.hoge@databricks.com“Admin権限をもつユーザ
image.png

3. 运行terraform。

只需要按照以下3个步骤执行terraform即可。

a) 初始化 Terraform

只需进行一次,但请在所选目录上执行上述命令。

terraform init

b) 進行Terraform計劃

如果init成功,则继续执行plan,并检查部署计划是否存在问题。

terraform plan
image.png
image.png

进行土壤改造应用

如果部署计划没有问题,最后我们会进行申请。

terraform apply
image.png

如果最后出现“申请完成”的消息,那就算成功了。

顺便说一下,如果要恢复环境,只需执行terraform destroy即可清理创建的对象。非常方便呢。

让我们确认一下

image.png
image.png
image.png
image.png
image.png

所以,事前准备部分除外…我能够在不登录AWS控制台、Databricks控制台或者工作区的情况下,在10分钟内完成搭建。这样很方便。

请提供资料或信息作为参考。

这里是公式手册和参考文件。

    • https://docs.databricks.com/data-governance/unity-catalog/automate.html

 

    terraform documents

请查看这里的 UnityCatalog 设置说明:https://qiita.com/maroon-db/items/57cee03cef202c839b94

bannerAds