From 8fac3a2f9b834558823e81eb61c2b6fb64c7f487 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s=20Mu=C3=B1oz=20Vera?= Date: Wed, 4 Dec 2024 12:51:48 +0100 Subject: [PATCH] GEN-2178 refactor to match Terraform standard module structure (#4) * GEN-2178 refactor to match Hashicorp standard module structure * GEN-2178 refactor example and module's docs * GEN-2178 remove old readme files * GEN-2178 use relative path for docs * GEN-2178 update module's path on the main readme * GEN-2178 update typo in path --- .../workflows/git-create-release-branch.yml | 2 +- .pre-commit-config.yaml | 2 +- ....terraform-docs.yml => .terraform-docs.yml | 0 README.md | 317 +++++++++++++++++- ...README_terraform.md => README_terraform.md | 4 +- .../airflow_config.tf => airflow_config.tf | 0 ...rflow_db_config.tf => airflow_db_config.tf | 0 .../airflow_secrets.tf => airflow_secrets.tf | 0 openmetadata-aws/db_config.tf => db_config.tf | 0 openmetadata-aws/defaults.tf => defaults.tf | 0 examples/README.md | 2 +- examples/{aws => }/complete/README.md | 0 examples/{aws => }/complete/datasources.tf | 0 examples/{aws => }/complete/ebs_csi_driver.tf | 0 examples/{aws => }/complete/efs_csi_driver.tf | 0 examples/{aws => }/complete/eks.tf | 0 examples/{aws => }/complete/iam.tf | 0 examples/{aws => }/complete/kms.tf | 0 examples/{aws => }/complete/main.tf | 2 +- examples/{aws => }/complete/metrics_server.tf | 0 examples/{aws => }/complete/namespace.tf | 0 examples/{aws => }/complete/outputs.tf | 0 examples/{aws => }/complete/providers.tf | 0 examples/{aws => }/complete/storage_class.tf | 0 examples/{aws => }/complete/variables.tf | 0 examples/{aws => }/complete/versions.tf | 0 examples/{aws => }/complete/vpc.tf | 0 main.tf | 79 +++++ .../airflow-efs/.terraform-docs.yml | 2 +- .../airflow-efs/docs}/README.md | 0 .../airflow-efs/helpers.tf | 0 .../modules => modules}/airflow-efs/main.tf | 0 .../airflow-efs/variables.tf | 0 .../airflow-efs/versions.tf | 0 .../.terraform-docs.yml | 2 +- .../openmetadata-dependencies/docs/README.md | 31 ++ .../helm_values.tftpl | 0 .../openmetadata-dependencies/main.tf | 0 .../openmetadata-dependencies/variables.tf | 0 .../.terraform-docs.yml | 2 +- .../openmetadata-deployment/docs/README.md | 31 ++ .../openmetadata-deployment/helm_values.tftpl | 0 .../openmetadata-deployment/main.tf | 0 .../openmetadata-deployment/variables.tf | 0 modules/opensearch/.terraform-docs.yml | 5 + .../opensearch/docs}/README.md | 0 .../modules => modules}/opensearch/main.tf | 0 .../modules => modules}/opensearch/outputs.tf | 0 .../opensearch/variables.tf | 0 .../opensearch/versions.tf | 0 modules/rds/.terraform-docs.yml | 5 + .../rds => modules/rds/docs}/README.md | 0 .../modules => modules}/rds/main.tf | 0 .../modules => modules}/rds/outputs.tf | 0 .../modules => modules}/rds/variables.tf | 0 .../modules => modules}/rds/versions.tf | 0 openmetadata-aws/LICENSE | 201 ----------- openmetadata-aws/README.md | 316 ----------------- openmetadata-aws/airflow_db_aws.tf | 12 - openmetadata-aws/airflow_efs.tf | 12 - openmetadata-aws/db_aws.tf | 12 - openmetadata-aws/openmetadata.tf | 7 - openmetadata-aws/openmetadata_dependencies.tf | 7 - openmetadata-aws/opensearch_aws.tf | 12 - ...tadata_config.tf => openmetadata_config.tf | 0 ....tf => openmetadata_dependencies_config.tf | 0 ...data_secrets.tf => openmetadata_secrets.tf | 0 ...ensearch_config.tf => opensearch_config.tf | 0 outputs.tf | 1 + openmetadata-aws/variables.tf => variables.tf | 0 openmetadata-aws/versions.tf => versions.tf | 0 71 files changed, 477 insertions(+), 589 deletions(-) rename openmetadata-aws/.terraform-docs.yml => .terraform-docs.yml (100%) rename openmetadata-aws/README_terraform.md => README_terraform.md (97%) rename openmetadata-aws/airflow_config.tf => airflow_config.tf (100%) rename openmetadata-aws/airflow_db_config.tf => airflow_db_config.tf (100%) rename openmetadata-aws/airflow_secrets.tf => airflow_secrets.tf (100%) rename openmetadata-aws/db_config.tf => db_config.tf (100%) rename openmetadata-aws/defaults.tf => defaults.tf (100%) rename examples/{aws => }/complete/README.md (100%) rename examples/{aws => }/complete/datasources.tf (100%) rename examples/{aws => }/complete/ebs_csi_driver.tf (100%) rename examples/{aws => }/complete/efs_csi_driver.tf (100%) rename examples/{aws => }/complete/eks.tf (100%) rename examples/{aws => }/complete/iam.tf (100%) rename examples/{aws => }/complete/kms.tf (100%) rename examples/{aws => }/complete/main.tf (96%) rename examples/{aws => }/complete/metrics_server.tf (100%) rename examples/{aws => }/complete/namespace.tf (100%) rename examples/{aws => }/complete/outputs.tf (100%) rename examples/{aws => }/complete/providers.tf (100%) rename examples/{aws => }/complete/storage_class.tf (100%) rename examples/{aws => }/complete/variables.tf (100%) rename examples/{aws => }/complete/versions.tf (100%) rename examples/{aws => }/complete/vpc.tf (100%) create mode 100644 main.tf rename {openmetadata-aws/modules => modules}/airflow-efs/.terraform-docs.yml (71%) rename {openmetadata-aws/modules/airflow-efs => modules/airflow-efs/docs}/README.md (100%) rename {openmetadata-aws/modules => modules}/airflow-efs/helpers.tf (100%) rename {openmetadata-aws/modules => modules}/airflow-efs/main.tf (100%) rename {openmetadata-aws/modules => modules}/airflow-efs/variables.tf (100%) rename {openmetadata-aws/modules => modules}/airflow-efs/versions.tf (100%) rename {openmetadata-aws/modules/opensearch => modules/openmetadata-dependencies}/.terraform-docs.yml (71%) create mode 100644 modules/openmetadata-dependencies/docs/README.md rename {submodules => modules}/openmetadata-dependencies/helm_values.tftpl (100%) rename {submodules => modules}/openmetadata-dependencies/main.tf (100%) rename {submodules => modules}/openmetadata-dependencies/variables.tf (100%) rename {openmetadata-aws/modules/rds => modules/openmetadata-deployment}/.terraform-docs.yml (71%) create mode 100644 modules/openmetadata-deployment/docs/README.md rename {submodules => modules}/openmetadata-deployment/helm_values.tftpl (100%) rename {submodules => modules}/openmetadata-deployment/main.tf (100%) rename {submodules => modules}/openmetadata-deployment/variables.tf (100%) create mode 100644 modules/opensearch/.terraform-docs.yml rename {openmetadata-aws/modules/opensearch => modules/opensearch/docs}/README.md (100%) rename {openmetadata-aws/modules => modules}/opensearch/main.tf (100%) rename {openmetadata-aws/modules => modules}/opensearch/outputs.tf (100%) rename {openmetadata-aws/modules => modules}/opensearch/variables.tf (100%) rename {openmetadata-aws/modules => modules}/opensearch/versions.tf (100%) create mode 100644 modules/rds/.terraform-docs.yml rename {openmetadata-aws/modules/rds => modules/rds/docs}/README.md (100%) rename {openmetadata-aws/modules => modules}/rds/main.tf (100%) rename {openmetadata-aws/modules => modules}/rds/outputs.tf (100%) rename {openmetadata-aws/modules => modules}/rds/variables.tf (100%) rename {openmetadata-aws/modules => modules}/rds/versions.tf (100%) delete mode 100644 openmetadata-aws/LICENSE delete mode 100644 openmetadata-aws/README.md delete mode 100644 openmetadata-aws/airflow_db_aws.tf delete mode 100644 openmetadata-aws/airflow_efs.tf delete mode 100644 openmetadata-aws/db_aws.tf delete mode 100644 openmetadata-aws/openmetadata.tf delete mode 100644 openmetadata-aws/openmetadata_dependencies.tf delete mode 100644 openmetadata-aws/opensearch_aws.tf rename openmetadata-aws/openmetadata_config.tf => openmetadata_config.tf (100%) rename openmetadata-aws/openmetadata_dependencies_config.tf => openmetadata_dependencies_config.tf (100%) rename openmetadata-aws/openmetadata_secrets.tf => openmetadata_secrets.tf (100%) rename openmetadata-aws/opensearch_config.tf => opensearch_config.tf (100%) create mode 100644 outputs.tf rename openmetadata-aws/variables.tf => variables.tf (100%) rename openmetadata-aws/versions.tf => versions.tf (100%) diff --git a/.github/workflows/git-create-release-branch.yml b/.github/workflows/git-create-release-branch.yml index 4af3474..7f4c4fa 100644 --- a/.github/workflows/git-create-release-branch.yml +++ b/.github/workflows/git-create-release-branch.yml @@ -23,7 +23,7 @@ jobs: fetch-depth: 0 - name: Update application versions run: | - sed -i "s/$(cat .version)/${{ inputs.release_branch_name}}/g" openmetadata-aws/openmetadata_dependencies.tf openmetadata-aws/README_terraform.md openmetadata-aws/README.md openmetadata-aws/openmetadata.tf openmetadata-aws/variables.tf examples/aws/complete/variables.tf .version + sed -i "s/$(cat .version)/${{ inputs.release_branch_name}}/g" README_terraform.md README.md variables.tf examples/aws/complete/variables.tf .version - name: Create Pull Request uses: peter-evans/create-pull-request@v7 with: diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 236b4a5..ff65c85 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -3,7 +3,7 @@ repos: rev: "v0.19.0" hooks: - id: terraform-docs-go - args: ["openmetadata-aws"] + args: ["."] - repo: local hooks: diff --git a/openmetadata-aws/.terraform-docs.yml b/.terraform-docs.yml similarity index 100% rename from openmetadata-aws/.terraform-docs.yml rename to .terraform-docs.yml diff --git a/README.md b/README.md index 18cdafd..14e729b 100644 --- a/README.md +++ b/README.md @@ -1 +1,316 @@ -# OpenMetadata Terraform modules +# OpenMetadata Terraform module for AWS + +# Usage + +The following examples show how to use the module with different provisioners. Even though each example use the same provisioner for all components, you can use different provisioners for any component if you prefer. + +## Helm - for testing + +Using `helm` as provisioner for all components: + +```hcl +module "omd" { + source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" + + # Namespace where OpenMetadata and dependencies will be deployed + app_namespace = "example" + + # Version of OpenMetadata to deploy + app_version = "1.5.12" + + # ARN of the KMS key used to encrypt the EFS volumes + kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" + + # Subnet IDs, used for the Airflow's EFS mount targets and EFS security group + subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] + + # VPC ID for the security groups of the EFS volumes + vpc_id = "vpc-1a2b3c4d" + +} +``` + +## Accessing OpenMetadata + +OpenMetadata is exposed via the `openmetadata` service. To access it, follow these steps: + +1. Run the following command to set up port forwarding: + + ```bash + kubectl port-forward service/openmetadata 8585:8585 + ``` + +2. Open your web browser and navigate to: + + ``` + http://localhost:8585 + ``` + +3. You should now see the OpenMetadata interface. + +## Provisioners + +This module enables you to choose from multiple provisioners to deploy the components and dependencies of OpenMetadata on AWS. The available provisioners for each component are: + +| | Helm | AWS | Existing | Default provisioner| +| :-------------------------- | :---: | :---: | :---: | :-----------------: | +| **OpenMetadata** | ✅ | 🟥 | 🟥 | Helm | +| **OpenMetadata database** | ✅ | ✅ | ✅ | Helm | +| **Airflow** | ✅ | 🟥 | ✅ | Helm | +| **Airflow database** | ✅ | ✅ | ✅ | Helm | +| **OpenSearch** | ✅ | ✅ | ✅ | Helm | + +> [!NOTE] +> If you select `existing` as the provisioner for Airflow, we expect the service to be fully functional, including its database. +> The Airflow database will not be deployed in this scenario. + +## AWS - production ready + +Using `aws` as provisioner for all possible components: + +```hcl +module "omd" { + source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" + + # Namespace where OpenMetadata and dependencies will be deployed + app_namespace = "example" + + # Version of OpenMetadata to deploy + app_version = "1.5.12" + + # Security group IDs assigned to the EKS nodes, the RDS instances, EFS volumes, and OpenSearch domain will allow inbound traffic from them + eks_nodes_sg_ids = ["sg-1234abcd5678efgh", "sg-8765ijkl4321mnop"] + + # ARN of the KMS key used to encrypt resources + kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" + + # Subnet IDs, used for: + # the Airflow's EFS mount targets + # the subnet group for the RDS instances + # the OpenSearch domain + subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] + + # VPC ID for the security groups of the EFS volumes, the RDS instances, and the OpenSearch domain + vpc_id = "vpc-1a2b3c4d" + + # OpenMetadata database settings + db = { + provisioner = "aws" + } + + # Airflow settings + airflow = { + db = { + provisioner = "aws" + } + } + + # OpenSearch settings + opensearch = { + provisioner = "aws" + } +} +``` + +## Existing + +Using `existing` as provisioner for all possible components: + +```hcl +module "omd" { + source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" + + # Namespace where OpenMetadata and dependencies will be deployed + app_namespace = "example" + + # Version of OpenMetadata to deploy + app_version = "1.5.12" + + # ARN of the KMS key used to encrypt resources + kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" + + # OpenMetadata database settings + db = { + provisioner = "existing" + host = "omd-db.postgres.example" + port = "5432" + db_name = "openmetadata_db" + engine = { + name = "postgres" + } + credentials = { + username = "dbadmin" + password = { + secret_ref = "db-secrets" + secret_key = "password" + } + } + } + + # Airflow settings + airflow = { + provisioner = "existing" + endpoint = "http://airflow.example:8080" + credentials = { + username = "admin" + password = { + secret_ref = "airflow-auth" + secret_key = "password" + } + } + } + + # OpenSearch settings + opensearch = { + provisioner = "existing" + host = "opensearch.example" + port = "443" + scheme = "https" + } +} +``` + +# Examples + +## AWS + +- [Complete](examples/complete) + +# Terraform docs README files + +- [OpenMetadata deployment](modules/openmetadata-deployment) +- [OpenMetadata dependencies](modules/openmetadata-dependencies) +- [Airflow EFS module](modules/airflow-efs) +- [RDS module](modules/rds) +- [OpenSearch module](modules/opensearch) + +# How we manage settings + +Components have default values for each provisioner, which are defined in the `defaults.tf` file. +The final settings for each component are determined by checking whether a value has been provided for each parameter. If a value is not provided for a parameter, the default one is used. This process is handled in the `component_conf.tf` files. + +# Adding extra environment variables +eter `extra_envs`: + +```hcl +module "omd" { + source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" + + # Namespace where OpenMetadata and dependencies will be deployed + app_namespace = "example" + + # Version of OpenMetadata to deploy + app_version = "1.5.12" + + # Subnet IDs, used for the Airflow's EFS mount targets and EFS security group + subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] + + # VPC ID for the security groups of the EFS volumes + vpc_id = "vpc-1a2b3c4d" + + # Extra environment variables for the OpenMetadata pod + extra_envs = { + "VAR_1" = "foo" + "VAR_2" = "bar" + } +} +``` + +You can also add extra environment variables from Kubernetes secrets by using the parameter `env_from`: + +```hcl +module "omd" { + source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" + + # Namespace where OpenMetadata and dependencies will be deployed + app_namespace = "example" + + # Version of OpenMetadata to deploy + app_version = "1.5.12" + + # Subnet IDs, used for the Airflow's EFS mount targets and EFS security group + subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] + + # VPC ID for the security groups of the EFS volumes + vpc_id = "vpc-1a2b3c4d" + + # Extra environment variables for the OpenMetadata pod from Kubernetes secrets + env_from = ["my-other-secret-1", "my-other-secret-2"] +} +``` + +# Accessing Airflow using port forwarding + +This section explains how to access **Airflow** running in your Kubernetes cluster using port forwarding. + +If you deployed Airflow using our Helm chart for dependencies, it will be exposed via the `openmetadata-deps-web` service. To access it, follow these steps: + +1. Run the following command to set up port forwarding: + + ```bash + kubectl port-forward service/openmetadata-deps-web 8080:8080 + ``` + +2. Open your web browser and navigate to: + + ``` + http://localhost:8080 + ``` + +3. You should now see the Airflow interface. + +## Notes + +- Ensure that the required services (`openmetadata-deps-web` and `openmetadata`) are active. +- The `kubectl port-forward` command maps a local port on your machine to the service's port in the Kubernetes cluster. This allows you to access the service as though it were running locally. +- If a service is already running on your machine using one of the ports in the examples, you can modify the local port (the first number in the mapping, e.g., 8585:8585) to an available port of your choice. +- Keep the terminal session with the `kubectl port-forward` command open while you are accessing the services. + + +# Development + +## pre-commit + +You can use [pre-commit](https://pre-commit.com/) to run checks on the code before committing. Checks are defined in the `.pre-commit-config.yaml` file and currently include: + + - terraform-docs + - terraform fmt + +To install the pre-commit hooks, run: + +```bash +devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ pre-commit install +pre-commit installed at .git/hooks/pre-commit +``` + +Then the checks will run automatically before each commit. If any check fails, the commit will be aborted and you will need to fix the issues before committing again: + +```bash +devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git add variables.tf +devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git commit -m "GEN-1521 test pre-commit" +[WARNING] Unstaged files detected. +[INFO] Stashing unstaged files to /home/devops/.cache/pre-commit/patch1732213728-159233. +terraform-docs...........................................................Passed +terraform fmt............................................................Failed +- hook id: terraform-fmt +- files were modified by this hook + +openmetadata-aws/variables.tf + +[INFO] Restored changes from /home/devops/.cache/pre-commit/patch1732213728-159233. +devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git status -sb +## GEN-1521-aws-initial-version...origin/GEN-1521-aws-initial-version [ahead 1] +MM variables.tf +devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git diff variables.tf +diff --git a/openmetadata-aws/variables.tf b/openmetadata-aws/variables.tf +index ee4af93..a3e3f57 100644 +--- a/openmetadata-aws/variables.tf ++++ b/openmetadata-aws/variables.tf +@@ -1,5 +1,5 @@ + variable "app_helm_chart_version" { +- type = string ++ type = string + description = "Version of the OpenMetadata Helm chart to deploy. If not specified, the variable `app_version` will be used." + default = null + } +``` diff --git a/openmetadata-aws/README_terraform.md b/README_terraform.md similarity index 97% rename from openmetadata-aws/README_terraform.md rename to README_terraform.md index 4f86e10..ee58e3e 100644 --- a/openmetadata-aws/README_terraform.md +++ b/README_terraform.md @@ -19,8 +19,8 @@ | [airflow\_db](#module\_airflow\_db) | ./modules/rds | n/a | | [airflow\_efs](#module\_airflow\_efs) | ./modules/airflow-efs | n/a | | [db](#module\_db) | ./modules/rds | n/a | -| [deployment](#module\_deployment) | github.com/open-metadata/openmetadata-terraform//submodules/openmetadata-deployment | 1.5.12 | -| [openmetadata\_deps](#module\_openmetadata\_deps) | github.com/open-metadata/openmetadata-terraform//submodules/openmetadata-dependencies | 1.5.12 | +| [deployment](#module\_deployment) | ./modules/openmetadata-deployment | n/a | +| [openmetadata\_deps](#module\_openmetadata\_deps) | ./modules/openmetadata-dependencies | n/a | | [opensearch](#module\_opensearch) | ./modules/opensearch | n/a | ## Resources diff --git a/openmetadata-aws/airflow_config.tf b/airflow_config.tf similarity index 100% rename from openmetadata-aws/airflow_config.tf rename to airflow_config.tf diff --git a/openmetadata-aws/airflow_db_config.tf b/airflow_db_config.tf similarity index 100% rename from openmetadata-aws/airflow_db_config.tf rename to airflow_db_config.tf diff --git a/openmetadata-aws/airflow_secrets.tf b/airflow_secrets.tf similarity index 100% rename from openmetadata-aws/airflow_secrets.tf rename to airflow_secrets.tf diff --git a/openmetadata-aws/db_config.tf b/db_config.tf similarity index 100% rename from openmetadata-aws/db_config.tf rename to db_config.tf diff --git a/openmetadata-aws/defaults.tf b/defaults.tf similarity index 100% rename from openmetadata-aws/defaults.tf rename to defaults.tf diff --git a/examples/README.md b/examples/README.md index f1b9553..adfa74a 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,4 +2,4 @@ ## AWS -- [Complete](https://github.com/open-metadata/openmetadata-terraform/tree/main/examples/aws/complete) +- [Complete](complete) diff --git a/examples/aws/complete/README.md b/examples/complete/README.md similarity index 100% rename from examples/aws/complete/README.md rename to examples/complete/README.md diff --git a/examples/aws/complete/datasources.tf b/examples/complete/datasources.tf similarity index 100% rename from examples/aws/complete/datasources.tf rename to examples/complete/datasources.tf diff --git a/examples/aws/complete/ebs_csi_driver.tf b/examples/complete/ebs_csi_driver.tf similarity index 100% rename from examples/aws/complete/ebs_csi_driver.tf rename to examples/complete/ebs_csi_driver.tf diff --git a/examples/aws/complete/efs_csi_driver.tf b/examples/complete/efs_csi_driver.tf similarity index 100% rename from examples/aws/complete/efs_csi_driver.tf rename to examples/complete/efs_csi_driver.tf diff --git a/examples/aws/complete/eks.tf b/examples/complete/eks.tf similarity index 100% rename from examples/aws/complete/eks.tf rename to examples/complete/eks.tf diff --git a/examples/aws/complete/iam.tf b/examples/complete/iam.tf similarity index 100% rename from examples/aws/complete/iam.tf rename to examples/complete/iam.tf diff --git a/examples/aws/complete/kms.tf b/examples/complete/kms.tf similarity index 100% rename from examples/aws/complete/kms.tf rename to examples/complete/kms.tf diff --git a/examples/aws/complete/main.tf b/examples/complete/main.tf similarity index 96% rename from examples/aws/complete/main.tf rename to examples/complete/main.tf index 0dccc3b..be9020b 100644 --- a/examples/aws/complete/main.tf +++ b/examples/complete/main.tf @@ -1,7 +1,7 @@ # OpenMetadata AWS module module "app" { - source = "../../../openmetadata-aws" + source = "../../" airflow = var.airflow env_from = local.env_from diff --git a/examples/aws/complete/metrics_server.tf b/examples/complete/metrics_server.tf similarity index 100% rename from examples/aws/complete/metrics_server.tf rename to examples/complete/metrics_server.tf diff --git a/examples/aws/complete/namespace.tf b/examples/complete/namespace.tf similarity index 100% rename from examples/aws/complete/namespace.tf rename to examples/complete/namespace.tf diff --git a/examples/aws/complete/outputs.tf b/examples/complete/outputs.tf similarity index 100% rename from examples/aws/complete/outputs.tf rename to examples/complete/outputs.tf diff --git a/examples/aws/complete/providers.tf b/examples/complete/providers.tf similarity index 100% rename from examples/aws/complete/providers.tf rename to examples/complete/providers.tf diff --git a/examples/aws/complete/storage_class.tf b/examples/complete/storage_class.tf similarity index 100% rename from examples/aws/complete/storage_class.tf rename to examples/complete/storage_class.tf diff --git a/examples/aws/complete/variables.tf b/examples/complete/variables.tf similarity index 100% rename from examples/aws/complete/variables.tf rename to examples/complete/variables.tf diff --git a/examples/aws/complete/versions.tf b/examples/complete/versions.tf similarity index 100% rename from examples/aws/complete/versions.tf rename to examples/complete/versions.tf diff --git a/examples/aws/complete/vpc.tf b/examples/complete/vpc.tf similarity index 100% rename from examples/aws/complete/vpc.tf rename to examples/complete/vpc.tf diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..99ab7f5 --- /dev/null +++ b/main.tf @@ -0,0 +1,79 @@ +# OpenMetadata deployment + +module "deployment" { + source = "./modules/openmetadata-deployment" + + namespace = local.omd.namespace + helm_chart_version = local.omd.helm_chart_version + helm_values = local.omd_template_vars +} + +# OpenMetadata dependencies + +module "openmetadata_deps" { + source = "./modules/openmetadata-dependencies" + + namespace = local.omd.namespace + helm_chart_version = local.omd.helm_chart_version + helm_values = local.omd_dependencies_template_vars +} + +# OpenMetadata RDS instance (optional) + +module "db" { + source = "./modules/rds" + + for_each = toset(local.db_provisioner == "aws" ? ["this"] : []) + + namespace = var.app_namespace + kms_key_id = var.kms_key_id + eks_nodes_sg_ids = var.eks_nodes_sg_ids + vpc_id = var.vpc_id + subnet_ids = var.subnet_ids + db_config = local.db +} + +# Airflow RDS instance (optional) + +module "airflow_db" { + source = "./modules/rds" + + for_each = toset(local.airflow_db_provisioner == "aws" ? ["this"] : []) + + namespace = var.app_namespace + kms_key_id = var.kms_key_id + eks_nodes_sg_ids = var.eks_nodes_sg_ids + vpc_id = var.vpc_id + subnet_ids = var.subnet_ids + db_config = local.airflow_db +} + +# Airflow EFS volumes (optional) + +module "airflow_efs" { + source = "./modules/airflow-efs" + + for_each = toset(local.airflow_provisioner == "helm" ? ["this"] : []) + + airflow = local.airflow + enable_helpers = true + eks_nodes_sg_ids = var.eks_nodes_sg_ids + namespace = var.app_namespace + subnet_ids = var.subnet_ids + vpc_id = var.vpc_id +} + +# OpenSearch domain (optional) + +module "opensearch" { + source = "./modules/opensearch" + + for_each = toset(local.opensearch_provisioner == "aws" ? ["this"] : []) + + namespace = var.app_namespace + kms_key_id = var.kms_key_id + eks_nodes_sg_ids = var.eks_nodes_sg_ids + vpc_id = var.vpc_id + subnet_ids = var.subnet_ids + opensearch = local.opensearch +} diff --git a/openmetadata-aws/modules/airflow-efs/.terraform-docs.yml b/modules/airflow-efs/.terraform-docs.yml similarity index 71% rename from openmetadata-aws/modules/airflow-efs/.terraform-docs.yml rename to modules/airflow-efs/.terraform-docs.yml index 9fab1d0..c325695 100644 --- a/openmetadata-aws/modules/airflow-efs/.terraform-docs.yml +++ b/modules/airflow-efs/.terraform-docs.yml @@ -1,5 +1,5 @@ output: - file: README.md + file: docs/README.md mode: replace template: |- {{ .Content }} diff --git a/openmetadata-aws/modules/airflow-efs/README.md b/modules/airflow-efs/docs/README.md similarity index 100% rename from openmetadata-aws/modules/airflow-efs/README.md rename to modules/airflow-efs/docs/README.md diff --git a/openmetadata-aws/modules/airflow-efs/helpers.tf b/modules/airflow-efs/helpers.tf similarity index 100% rename from openmetadata-aws/modules/airflow-efs/helpers.tf rename to modules/airflow-efs/helpers.tf diff --git a/openmetadata-aws/modules/airflow-efs/main.tf b/modules/airflow-efs/main.tf similarity index 100% rename from openmetadata-aws/modules/airflow-efs/main.tf rename to modules/airflow-efs/main.tf diff --git a/openmetadata-aws/modules/airflow-efs/variables.tf b/modules/airflow-efs/variables.tf similarity index 100% rename from openmetadata-aws/modules/airflow-efs/variables.tf rename to modules/airflow-efs/variables.tf diff --git a/openmetadata-aws/modules/airflow-efs/versions.tf b/modules/airflow-efs/versions.tf similarity index 100% rename from openmetadata-aws/modules/airflow-efs/versions.tf rename to modules/airflow-efs/versions.tf diff --git a/openmetadata-aws/modules/opensearch/.terraform-docs.yml b/modules/openmetadata-dependencies/.terraform-docs.yml similarity index 71% rename from openmetadata-aws/modules/opensearch/.terraform-docs.yml rename to modules/openmetadata-dependencies/.terraform-docs.yml index 9fab1d0..c325695 100644 --- a/openmetadata-aws/modules/opensearch/.terraform-docs.yml +++ b/modules/openmetadata-dependencies/.terraform-docs.yml @@ -1,5 +1,5 @@ output: - file: README.md + file: docs/README.md mode: replace template: |- {{ .Content }} diff --git a/modules/openmetadata-dependencies/docs/README.md b/modules/openmetadata-dependencies/docs/README.md new file mode 100644 index 0000000..6658818 --- /dev/null +++ b/modules/openmetadata-dependencies/docs/README.md @@ -0,0 +1,31 @@ +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [helm](#provider\_helm) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [helm_release.openmetadata_deps](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [helm\_chart\_version](#input\_helm\_chart\_version) | Version of the OpenMetadata dependencies Helm chart to deploy. | `string` | `null` | no | +| [helm\_values](#input\_helm\_values) | Custom values to override the default values in the OpenMetadata dependencies Helm chart. | `any` | `null` | no | +| [namespace](#input\_namespace) | The OpenMetadata application's namespace. | `string` | `"openmetadata"` | no | + +## Outputs + +No outputs. \ No newline at end of file diff --git a/submodules/openmetadata-dependencies/helm_values.tftpl b/modules/openmetadata-dependencies/helm_values.tftpl similarity index 100% rename from submodules/openmetadata-dependencies/helm_values.tftpl rename to modules/openmetadata-dependencies/helm_values.tftpl diff --git a/submodules/openmetadata-dependencies/main.tf b/modules/openmetadata-dependencies/main.tf similarity index 100% rename from submodules/openmetadata-dependencies/main.tf rename to modules/openmetadata-dependencies/main.tf diff --git a/submodules/openmetadata-dependencies/variables.tf b/modules/openmetadata-dependencies/variables.tf similarity index 100% rename from submodules/openmetadata-dependencies/variables.tf rename to modules/openmetadata-dependencies/variables.tf diff --git a/openmetadata-aws/modules/rds/.terraform-docs.yml b/modules/openmetadata-deployment/.terraform-docs.yml similarity index 71% rename from openmetadata-aws/modules/rds/.terraform-docs.yml rename to modules/openmetadata-deployment/.terraform-docs.yml index 9fab1d0..c325695 100644 --- a/openmetadata-aws/modules/rds/.terraform-docs.yml +++ b/modules/openmetadata-deployment/.terraform-docs.yml @@ -1,5 +1,5 @@ output: - file: README.md + file: docs/README.md mode: replace template: |- {{ .Content }} diff --git a/modules/openmetadata-deployment/docs/README.md b/modules/openmetadata-deployment/docs/README.md new file mode 100644 index 0000000..a93b0b4 --- /dev/null +++ b/modules/openmetadata-deployment/docs/README.md @@ -0,0 +1,31 @@ +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [helm](#provider\_helm) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [helm_release.openmetadata](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [helm\_chart\_version](#input\_helm\_chart\_version) | Version of the OpenMetadata Helm chart to deploy. | `string` | `null` | no | +| [helm\_values](#input\_helm\_values) | Custom values to override the default values in the OpenMetadata Helm chart. | `any` | `null` | no | +| [namespace](#input\_namespace) | The OpenMetadata application's namespace. | `string` | `"openmetadata"` | no | + +## Outputs + +No outputs. \ No newline at end of file diff --git a/submodules/openmetadata-deployment/helm_values.tftpl b/modules/openmetadata-deployment/helm_values.tftpl similarity index 100% rename from submodules/openmetadata-deployment/helm_values.tftpl rename to modules/openmetadata-deployment/helm_values.tftpl diff --git a/submodules/openmetadata-deployment/main.tf b/modules/openmetadata-deployment/main.tf similarity index 100% rename from submodules/openmetadata-deployment/main.tf rename to modules/openmetadata-deployment/main.tf diff --git a/submodules/openmetadata-deployment/variables.tf b/modules/openmetadata-deployment/variables.tf similarity index 100% rename from submodules/openmetadata-deployment/variables.tf rename to modules/openmetadata-deployment/variables.tf diff --git a/modules/opensearch/.terraform-docs.yml b/modules/opensearch/.terraform-docs.yml new file mode 100644 index 0000000..c325695 --- /dev/null +++ b/modules/opensearch/.terraform-docs.yml @@ -0,0 +1,5 @@ +output: + file: docs/README.md + mode: replace + template: |- + {{ .Content }} diff --git a/openmetadata-aws/modules/opensearch/README.md b/modules/opensearch/docs/README.md similarity index 100% rename from openmetadata-aws/modules/opensearch/README.md rename to modules/opensearch/docs/README.md diff --git a/openmetadata-aws/modules/opensearch/main.tf b/modules/opensearch/main.tf similarity index 100% rename from openmetadata-aws/modules/opensearch/main.tf rename to modules/opensearch/main.tf diff --git a/openmetadata-aws/modules/opensearch/outputs.tf b/modules/opensearch/outputs.tf similarity index 100% rename from openmetadata-aws/modules/opensearch/outputs.tf rename to modules/opensearch/outputs.tf diff --git a/openmetadata-aws/modules/opensearch/variables.tf b/modules/opensearch/variables.tf similarity index 100% rename from openmetadata-aws/modules/opensearch/variables.tf rename to modules/opensearch/variables.tf diff --git a/openmetadata-aws/modules/opensearch/versions.tf b/modules/opensearch/versions.tf similarity index 100% rename from openmetadata-aws/modules/opensearch/versions.tf rename to modules/opensearch/versions.tf diff --git a/modules/rds/.terraform-docs.yml b/modules/rds/.terraform-docs.yml new file mode 100644 index 0000000..c325695 --- /dev/null +++ b/modules/rds/.terraform-docs.yml @@ -0,0 +1,5 @@ +output: + file: docs/README.md + mode: replace + template: |- + {{ .Content }} diff --git a/openmetadata-aws/modules/rds/README.md b/modules/rds/docs/README.md similarity index 100% rename from openmetadata-aws/modules/rds/README.md rename to modules/rds/docs/README.md diff --git a/openmetadata-aws/modules/rds/main.tf b/modules/rds/main.tf similarity index 100% rename from openmetadata-aws/modules/rds/main.tf rename to modules/rds/main.tf diff --git a/openmetadata-aws/modules/rds/outputs.tf b/modules/rds/outputs.tf similarity index 100% rename from openmetadata-aws/modules/rds/outputs.tf rename to modules/rds/outputs.tf diff --git a/openmetadata-aws/modules/rds/variables.tf b/modules/rds/variables.tf similarity index 100% rename from openmetadata-aws/modules/rds/variables.tf rename to modules/rds/variables.tf diff --git a/openmetadata-aws/modules/rds/versions.tf b/modules/rds/versions.tf similarity index 100% rename from openmetadata-aws/modules/rds/versions.tf rename to modules/rds/versions.tf diff --git a/openmetadata-aws/LICENSE b/openmetadata-aws/LICENSE deleted file mode 100644 index 261eeb9..0000000 --- a/openmetadata-aws/LICENSE +++ /dev/null @@ -1,201 +0,0 @@ - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/openmetadata-aws/README.md b/openmetadata-aws/README.md deleted file mode 100644 index 3342848..0000000 --- a/openmetadata-aws/README.md +++ /dev/null @@ -1,316 +0,0 @@ -# OpenMetadata Terraform module for AWS - -# Usage - -The following examples show how to use the module with different provisioners. Even though each example use the same provisioner for all components, you can use different provisioners for any component if you prefer. - -## Helm - for testing - -Using `helm` as provisioner for all components: - -```hcl -module "omd" { - source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" - - # Namespace where OpenMetadata and dependencies will be deployed - app_namespace = "example" - - # Version of OpenMetadata to deploy - app_version = "1.5.12" - - # ARN of the KMS key used to encrypt the EFS volumes - kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" - - # Subnet IDs, used for the Airflow's EFS mount targets and EFS security group - subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] - - # VPC ID for the security groups of the EFS volumes - vpc_id = "vpc-1a2b3c4d" - -} -``` - -## Accessing OpenMetadata - -OpenMetadata is exposed via the `openmetadata` service. To access it, follow these steps: - -1. Run the following command to set up port forwarding: - - ```bash - kubectl port-forward service/openmetadata 8585:8585 - ``` - -2. Open your web browser and navigate to: - - ``` - http://localhost:8585 - ``` - -3. You should now see the OpenMetadata interface. - -## Provisioners - -This module enables you to choose from multiple provisioners to deploy the components and dependencies of OpenMetadata on AWS. The available provisioners for each component are: - -| | Helm | AWS | Existing | Default provisioner| -| :-------------------------- | :---: | :---: | :---: | :-----------------: | -| **OpenMetadata** | ✅ | 🟥 | 🟥 | Helm | -| **OpenMetadata database** | ✅ | ✅ | ✅ | Helm | -| **Airflow** | ✅ | 🟥 | ✅ | Helm | -| **Airflow database** | ✅ | ✅ | ✅ | Helm | -| **OpenSearch** | ✅ | ✅ | ✅ | Helm | - -> [!NOTE] -> If you select `existing` as the provisioner for Airflow, we expect the service to be fully functional, including its database. -> The Airflow database will not be deployed in this scenario. - -## AWS - production ready - -Using `aws` as provisioner for all possible components: - -```hcl -module "omd" { - source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" - - # Namespace where OpenMetadata and dependencies will be deployed - app_namespace = "example" - - # Version of OpenMetadata to deploy - app_version = "1.5.12" - - # Security group IDs assigned to the EKS nodes, the RDS instances, EFS volumes, and OpenSearch domain will allow inbound traffic from them - eks_nodes_sg_ids = ["sg-1234abcd5678efgh", "sg-8765ijkl4321mnop"] - - # ARN of the KMS key used to encrypt resources - kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" - - # Subnet IDs, used for: - # the Airflow's EFS mount targets - # the subnet group for the RDS instances - # the OpenSearch domain - subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] - - # VPC ID for the security groups of the EFS volumes, the RDS instances, and the OpenSearch domain - vpc_id = "vpc-1a2b3c4d" - - # OpenMetadata database settings - db = { - provisioner = "aws" - } - - # Airflow settings - airflow = { - db = { - provisioner = "aws" - } - } - - # OpenSearch settings - opensearch = { - provisioner = "aws" - } -} -``` - -## Existing - -Using `existing` as provisioner for all possible components: - -```hcl -module "omd" { - source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" - - # Namespace where OpenMetadata and dependencies will be deployed - app_namespace = "example" - - # Version of OpenMetadata to deploy - app_version = "1.5.12" - - # ARN of the KMS key used to encrypt resources - kms_key_id = "arn:aws:kms:us-east-1:123456789012:key/12345678-1234-1234-1234-123456789012" - - # OpenMetadata database settings - db = { - provisioner = "existing" - host = "omd-db.postgres.example" - port = "5432" - db_name = "openmetadata_db" - engine = { - name = "postgres" - } - credentials = { - username = "dbadmin" - password = { - secret_ref = "db-secrets" - secret_key = "password" - } - } - } - - # Airflow settings - airflow = { - provisioner = "existing" - endpoint = "http://airflow.example:8080" - credentials = { - username = "admin" - password = { - secret_ref = "airflow-auth" - secret_key = "password" - } - } - } - - # OpenSearch settings - opensearch = { - provisioner = "existing" - host = "opensearch.example" - port = "443" - scheme = "https" - } -} -``` - -# Examples - -## AWS - -- [Complete](https://github.com/open-metadata/openmetadata-terraform/tree/main/examples/aws/complete) - -# Terraform docs README files - -- [OpenMetadata module for AWS](https://github.com/open-metadata/openmetadata-terraform/tree/main/openmetadata-aws/README.md) -- [Airflow EFS module](https://github.com/open-metadata/openmetadata-terraform/tree/main/openmetadata-aws/modules/airflow_efs/README.md) -- [RDS module](https://github.com/open-metadata/openmetadata-terraform/tree/main/openmetadata-aws/modules/rds/README.md) -- [OpenSearch module](https://github.com/open-metadata/openmetadata-terraform/tree/main/openmetadata-aws/modules/opensearch/README.md) - -# How we manage settings - -Components have default values for each provisioner, which are defined in the `defaults.tf` file. -The final settings for each component are determined by checking whether a value has been provided for each parameter. If a value is not provided for a parameter, the default one is used. This process is handled in the `component_conf.tf` files. - -# Adding extra environment variables - -You can add extra environment variables to the OpenMetadata pod by using the parameter `extra_envs`: - -```hcl -module "omd" { - source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" - - # Namespace where OpenMetadata and dependencies will be deployed - app_namespace = "example" - - # Version of OpenMetadata to deploy - app_version = "1.5.12" - - # Subnet IDs, used for the Airflow's EFS mount targets and EFS security group - subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] - - # VPC ID for the security groups of the EFS volumes - vpc_id = "vpc-1a2b3c4d" - - # Extra environment variables for the OpenMetadata pod - extra_envs = { - "VAR_1" = "foo" - "VAR_2" = "bar" - } -} -``` - -You can also add extra environment variables from Kubernetes secrets by using the parameter `env_from`: - -```hcl -module "omd" { - source = "github.com/open-metadata/openmetadata-terraform//openmetadata-aws?ref=1.5.12" - - # Namespace where OpenMetadata and dependencies will be deployed - app_namespace = "example" - - # Version of OpenMetadata to deploy - app_version = "1.5.12" - - # Subnet IDs, used for the Airflow's EFS mount targets and EFS security group - subnet_ids = ["subnet-1a2b3c4d", "subnet-5e6f7g8h", "subnet-9i0j1k2l"] - - # VPC ID for the security groups of the EFS volumes - vpc_id = "vpc-1a2b3c4d" - - # Extra environment variables for the OpenMetadata pod from Kubernetes secrets - env_from = ["my-other-secret-1", "my-other-secret-2"] -} -``` - -# Accessing Airflow using port forwarding - -This section explains how to access **Airflow** running in your Kubernetes cluster using port forwarding. - -If you deployed Airflow using our Helm chart for dependencies, it will be exposed via the `openmetadata-deps-web` service. To access it, follow these steps: - -1. Run the following command to set up port forwarding: - - ```bash - kubectl port-forward service/openmetadata-deps-web 8080:8080 - ``` - -2. Open your web browser and navigate to: - - ``` - http://localhost:8080 - ``` - -3. You should now see the Airflow interface. - -## Notes - -- Ensure that the required services (`openmetadata-deps-web` and `openmetadata`) are active. -- The `kubectl port-forward` command maps a local port on your machine to the service's port in the Kubernetes cluster. This allows you to access the service as though it were running locally. -- If a service is already running on your machine using one of the ports in the examples, you can modify the local port (the first number in the mapping, e.g., 8585:8585) to an available port of your choice. -- Keep the terminal session with the `kubectl port-forward` command open while you are accessing the services. - - -# Development - -## pre-commit - -You can use [pre-commit](https://pre-commit.com/) to run checks on the code before committing. Checks are defined in the `.pre-commit-config.yaml` file and currently include: - - - terraform-docs - - terraform fmt - -To install the pre-commit hooks, run: - -```bash -devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ pre-commit install -pre-commit installed at .git/hooks/pre-commit -``` - -Then the checks will run automatically before each commit. If any check fails, the commit will be aborted and you will need to fix the issues before committing again: - -```bash -devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git add variables.tf -devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git commit -m "GEN-1521 test pre-commit" -[WARNING] Unstaged files detected. -[INFO] Stashing unstaged files to /home/devops/.cache/pre-commit/patch1732213728-159233. -terraform-docs...........................................................Passed -terraform fmt............................................................Failed -- hook id: terraform-fmt -- files were modified by this hook - -openmetadata-aws/variables.tf - -[INFO] Restored changes from /home/devops/.cache/pre-commit/patch1732213728-159233. -devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git status -sb -## GEN-1521-aws-initial-version...origin/GEN-1521-aws-initial-version [ahead 1] -MM variables.tf -devops@collate:~/projects/collate/openmetadata-terraform/openmetadata-aws$ git diff variables.tf -diff --git a/openmetadata-aws/variables.tf b/openmetadata-aws/variables.tf -index ee4af93..a3e3f57 100644 ---- a/openmetadata-aws/variables.tf -+++ b/openmetadata-aws/variables.tf -@@ -1,5 +1,5 @@ - variable "app_helm_chart_version" { -- type = string -+ type = string - description = "Version of the OpenMetadata Helm chart to deploy. If not specified, the variable `app_version` will be used." - default = null - } -``` diff --git a/openmetadata-aws/airflow_db_aws.tf b/openmetadata-aws/airflow_db_aws.tf deleted file mode 100644 index 7c6ceb9..0000000 --- a/openmetadata-aws/airflow_db_aws.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "airflow_db" { - source = "./modules/rds" - - for_each = toset(local.airflow_db_provisioner == "aws" ? ["this"] : []) - - namespace = var.app_namespace - kms_key_id = var.kms_key_id - eks_nodes_sg_ids = var.eks_nodes_sg_ids - vpc_id = var.vpc_id - subnet_ids = var.subnet_ids - db_config = local.airflow_db -} diff --git a/openmetadata-aws/airflow_efs.tf b/openmetadata-aws/airflow_efs.tf deleted file mode 100644 index fe60144..0000000 --- a/openmetadata-aws/airflow_efs.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "airflow_efs" { - source = "./modules/airflow-efs" - - for_each = toset(local.airflow_provisioner == "helm" ? ["this"] : []) - - airflow = local.airflow - enable_helpers = true - eks_nodes_sg_ids = var.eks_nodes_sg_ids - namespace = var.app_namespace - subnet_ids = var.subnet_ids - vpc_id = var.vpc_id -} diff --git a/openmetadata-aws/db_aws.tf b/openmetadata-aws/db_aws.tf deleted file mode 100644 index 0d1c4bf..0000000 --- a/openmetadata-aws/db_aws.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "db" { - source = "./modules/rds" - - for_each = toset(local.db_provisioner == "aws" ? ["this"] : []) - - namespace = var.app_namespace - kms_key_id = var.kms_key_id - eks_nodes_sg_ids = var.eks_nodes_sg_ids - vpc_id = var.vpc_id - subnet_ids = var.subnet_ids - db_config = local.db -} diff --git a/openmetadata-aws/openmetadata.tf b/openmetadata-aws/openmetadata.tf deleted file mode 100644 index e53b07d..0000000 --- a/openmetadata-aws/openmetadata.tf +++ /dev/null @@ -1,7 +0,0 @@ -module "deployment" { - source = "github.com/open-metadata/openmetadata-terraform//submodules/openmetadata-deployment?ref=1.5.12" - - namespace = local.omd.namespace - helm_chart_version = local.omd.helm_chart_version - helm_values = local.omd_template_vars -} diff --git a/openmetadata-aws/openmetadata_dependencies.tf b/openmetadata-aws/openmetadata_dependencies.tf deleted file mode 100644 index 9df9e5b..0000000 --- a/openmetadata-aws/openmetadata_dependencies.tf +++ /dev/null @@ -1,7 +0,0 @@ -module "openmetadata_deps" { - source = "github.com/open-metadata/openmetadata-terraform//submodules/openmetadata-dependencies?ref=1.5.12" - - namespace = local.omd.namespace - helm_chart_version = local.omd.helm_chart_version - helm_values = local.omd_dependencies_template_vars -} diff --git a/openmetadata-aws/opensearch_aws.tf b/openmetadata-aws/opensearch_aws.tf deleted file mode 100644 index 2422dfb..0000000 --- a/openmetadata-aws/opensearch_aws.tf +++ /dev/null @@ -1,12 +0,0 @@ -module "opensearch" { - source = "./modules/opensearch" - - for_each = toset(local.opensearch_provisioner == "aws" ? ["this"] : []) - - namespace = var.app_namespace - kms_key_id = var.kms_key_id - eks_nodes_sg_ids = var.eks_nodes_sg_ids - vpc_id = var.vpc_id - subnet_ids = var.subnet_ids - opensearch = local.opensearch -} diff --git a/openmetadata-aws/openmetadata_config.tf b/openmetadata_config.tf similarity index 100% rename from openmetadata-aws/openmetadata_config.tf rename to openmetadata_config.tf diff --git a/openmetadata-aws/openmetadata_dependencies_config.tf b/openmetadata_dependencies_config.tf similarity index 100% rename from openmetadata-aws/openmetadata_dependencies_config.tf rename to openmetadata_dependencies_config.tf diff --git a/openmetadata-aws/openmetadata_secrets.tf b/openmetadata_secrets.tf similarity index 100% rename from openmetadata-aws/openmetadata_secrets.tf rename to openmetadata_secrets.tf diff --git a/openmetadata-aws/opensearch_config.tf b/opensearch_config.tf similarity index 100% rename from openmetadata-aws/opensearch_config.tf rename to opensearch_config.tf diff --git a/outputs.tf b/outputs.tf new file mode 100644 index 0000000..b0d84e9 --- /dev/null +++ b/outputs.tf @@ -0,0 +1 @@ +# Outputs diff --git a/openmetadata-aws/variables.tf b/variables.tf similarity index 100% rename from openmetadata-aws/variables.tf rename to variables.tf diff --git a/openmetadata-aws/versions.tf b/versions.tf similarity index 100% rename from openmetadata-aws/versions.tf rename to versions.tf