diff --git a/.github/workflows/pull-request.yml b/.github/workflows/pull-request.yml index 35ed57f..41c73b5 100644 --- a/.github/workflows/pull-request.yml +++ b/.github/workflows/pull-request.yml @@ -8,40 +8,56 @@ jobs: outputs: directories: ${{ steps.dirs.outputs.matrix }} steps: + # Checkout the repository to the GitHub Actions runner - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} + + # Find all subdirectories within "modules/" and "examples/" - name: Get root directories id: dirs run: echo "matrix=$(ls -d {modules,examples}/* | jq -R -s -c 'split("\n")[:-1]')" >> $GITHUB_OUTPUT - - validateConfigs: - name: Validate terraform pull PR - needs: collectInputs + + validatePR: + name: Validate PR runs-on: ubuntu-latest + needs: collectInputs strategy: matrix: directory: ${{ fromJson(needs.collectInputs.outputs.directories) }} steps: + # Checkout the repository to the GitHub Actions runner - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} - - name: Validate configs - uses: dflook/terraform-validate@v1 - with: - path: ${{ matrix.directory }} + + # Install the latest version of Terraform + - name: Setup Terraform + uses: hashicorp/setup-terraform@v2 + + # Initialize terraform and validate submodules + - name: Terraform validate + working-directory: ${{ matrix.directory }} + run: | + if [[ -d ".terraform" ]]; then echo "removing exisiting .terraform directory"; rm -rf .terraform; fi + terraform workspace new ${{ github.run_id }} + terraform init + terraform validate updateDocumentation: name: Update READMEs - needs: validateConfigs + needs: validatePR runs-on: ubuntu-latest steps: + # Checkout the repository to the GitHub Actions runner - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} + + # Update READMEs using terraform-docs - name: Render terraform docs inside the README.md and push changes back to PR branch uses: terraform-docs/gh-actions@v1.2.0 with: @@ -59,18 +75,25 @@ jobs: permissions: contents: write steps: + # Checkout the repository to the GitHub Actions runner - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: ref: ${{ github.event.pull_request.head.ref }} + + # Format Terraform modules - name: Terraform fmt modules uses: dflook/terraform-fmt@v1 with: path: modules/ + + # Format Terraform examples - name: Terraform fmt examples uses: dflook/terraform-fmt@v1 with: path: examples/ + + # Push changes to PR - name: Commit changes to PR uses: stefanzweifel/git-auto-commit-action@v5 - + \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c29c8ac..3fa9a55 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## 1.0.2 (2024-07-12) + +### Features +- Amazon DocumentDB module +- Amazon Neptune module +- Amazon Neptune Slow query module +- Amazon RDS MariaDB module +- Amazon RDS MySQL module +- Amazon RDS MySQL Slow query module +- Amazon RDS Oracle (standard auditing) module +- Amazon RDS Oracle (unified auditing) module +- Amazon Redshift (via ODBC) module +- Amazon Redshift (via S3 bucket) module + ## 1.0.1 (2024-06-27) ### Bug Fixes diff --git a/DSF_VERSION_COMPATABILITY.md b/DSF_VERSION_COMPATABILITY.md index bdad240..b041104 100644 --- a/DSF_VERSION_COMPATABILITY.md +++ b/DSF_VERSION_COMPATABILITY.md @@ -7,9 +7,45 @@ The following table lists the DSF versions that each module is tested and mainta DSF Versions + + onboard-aws-docdb-cluster + 4.17+ + + + onboard-aws-rds-neptune + 4.17+ + + + onboard-aws-rds-neptune-slow-query + 4.17+ + + + onboard-aws-rds-mariadb + 4.16+ + + + onboard-aws-rds-mysql + 4.16+ + + + onboard-aws-rds-mysql-slow-query + 4.16+ + + + onboard-aws-rds-oracle-standard + 4.16+ + + + onboard-aws-rds-oracle-unified + 4.16+ + onboard-aws-rds-postgresql - 4.16 + 4.16+ + + + onboard-aws-rds-redshift + 4.17+ \ No newline at end of file diff --git a/examples/onboard-aws-docdb-cluster/README.md b/examples/onboard-aws-docdb-cluster/README.md new file mode 100644 index 0000000..53c8eee --- /dev/null +++ b/examples/onboard-aws-docdb-cluster/README.md @@ -0,0 +1,42 @@ +# Onboard Amazon DocumentDB example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-DocumentDB-Onboarding-Steps_48366944.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-docdb-cluster-1](#module\_aws-docdb-cluster-1) | ../../modules/onboard-aws-docdb-cluster | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-docdb-cluster/main.tf b/examples/onboard-aws-docdb-cluster/main.tf new file mode 100644 index 0000000..fb21732 --- /dev/null +++ b/examples/onboard-aws-docdb-cluster/main.tf @@ -0,0 +1,80 @@ +locals { + aws_region = "us-east-1" + + admin_email = "test@example.com" + apply_immediately = true + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# 1. AWS cloud account +################################################################################ +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::1234567890" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# Amazon DocumentDB Cluster 5.0.0 +################################################################################ + +module "aws-docdb-cluster-1" { + source = "../../modules/onboard-aws-docdb-cluster" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_docdb_cluster_admin_email = local.admin_email + aws_docdb_cluster_gateway_id = local.gateway_id + aws_docdb_cluster_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_docdb_cluster_region = local.aws_region + + cluster_apply_immediately = local.apply_immediately + cluster_identifier = "example-tf-docdb" + cluster_db_subnet_group_name = "default" + cluster_enabled_cloudwatch_logs_exports = ["audit"] + cluster_engine_version = "5.0.0" + cluster_master_password = "abcd1234" + cluster_master_username = "docdbadmin" + cluster_skip_final_snapshot = true + cluster_vpc_security_group_ids = ["sg-0123456789abcdefg"] + + instance_apply_immediately = local.apply_immediately + instance_count = 1 + instance_instance_class = "db.t3.medium" + + parameter_group_family = "docdb5.0" + parameter_group_name = "docdb-pg-test4" +} diff --git a/examples/onboard-aws-neptune-slow-query/README.md b/examples/onboard-aws-neptune-slow-query/README.md new file mode 100644 index 0000000..2203a6e --- /dev/null +++ b/examples/onboard-aws-neptune-slow-query/README.md @@ -0,0 +1,42 @@ +# Onboard Amazon Neptune with Slow Query example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-Neptune-Onboarding-Steps_48367003.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-neptune-slowquery-1](#module\_aws-neptune-slowquery-1) | ../../modules/onboard-aws-neptune-slow-query | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-neptune-slow-query/main.tf b/examples/onboard-aws-neptune-slow-query/main.tf new file mode 100644 index 0000000..95c1bf8 --- /dev/null +++ b/examples/onboard-aws-neptune-slow-query/main.tf @@ -0,0 +1,96 @@ +locals { + aws_region = "us-east-2" + vpc_security_group_ids = [ + "sg-12a345678912b1c2a", + "sg-34b456789c12b231e" + ] + subnet_group_name = "my-subnet-group" + admin_email = "person@example.com" + gateway_id = "a1b2c3d4-1234-5678-9123-cd1edcef7642" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# AWS cloud account +################################################################################ + +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::123456789101:role/iam-role" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# Amazon Neptune +################################################################################ +module "aws-neptune-slowquery-1" { + source = "../../modules/onboard-aws-neptune-slow-query" + + parameter_group_name = "nept-clus-group" + parameter_group_family = "neptune1.3" + parameter_group_parameters = [ + { + name = "neptune_enable_audit_log" + value = 1 + apply_method = "pending-reboot" + }, + { + name = "neptune_enable_slow_query_log" + value = "info" + }, + { + name = "neptune_slow_query_log_threshold" + value = 5000 + } + ] + + cluster_identifier = "nept-tf-cluster" + cluster_skip_final_snapshot = true + cluster_vpc_security_group_ids = local.vpc_security_group_ids + cluster_iam_database_authentication_enabled = true + cluster_engine_version = "1.3.2.0" + cluster_apply_immediately = true + cluster_storage_type = "standard" + + instance_apply_immediately = true + instance_identifier = "nept-instance" + instance_neptune_subnet_group_name = local.subnet_group_name + instance_publicly_accessible = false + instance_neptune_parameter_group_name = "default.neptune1.3" + instance_class = "db.t3.medium" + + aws_neptune_cluster_admin_email = local.admin_email + aws_neptune_cluster_gateway_id = local.gateway_id + aws_neptune_cluster_region = local.aws_region + aws_neptune_cluster_parent_asset_id = module.aws-default-account-asset.this.asset_id + + aws_log_group_audit_pull_enabled = true +} \ No newline at end of file diff --git a/examples/onboard-aws-neptune/README.md b/examples/onboard-aws-neptune/README.md new file mode 100644 index 0000000..613fd06 --- /dev/null +++ b/examples/onboard-aws-neptune/README.md @@ -0,0 +1,42 @@ +# Onboard Amazon Neptune example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-Neptune-Onboarding-Steps_48367003.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-neptune-1](#module\_aws-neptune-1) | ../../modules/onboard-aws-neptune | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-neptune/main.tf b/examples/onboard-aws-neptune/main.tf new file mode 100644 index 0000000..4c37a6c --- /dev/null +++ b/examples/onboard-aws-neptune/main.tf @@ -0,0 +1,82 @@ +locals { + aws_region = "us-east-2" + vpc_security_group_ids = [ + "sg-12a345678912b1c2a", + "sg-34b456789c12b231e" + ] + subnet_group_name = "my-subnet-group" + admin_email = "person@example.com" + gateway_id = "a1b2c3d4-1234-5678-9123-cd1edcef7642" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# AWS cloud account +################################################################################ + +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::123456789101:role/iam-role" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# Amazon Neptune +################################################################################ + +module "aws-neptune-1" { + source = "../../modules/onboard-aws-neptune" + + parameter_group_name = "nept-clus-group" + parameter_group_family = "neptune1.3" + + cluster_identifier = "nept-tf-cluster" + cluster_skip_final_snapshot = true + cluster_vpc_security_group_ids = local.vpc_security_group_ids + cluster_iam_database_authentication_enabled = true + cluster_engine_version = "1.3.2.0" + cluster_apply_immediately = true + cluster_storage_type = "standard" + + instance_apply_immediately = true + instance_identifier = "nept-instance" + instance_neptune_subnet_group_name = local.subnet_group_name + instance_publicly_accessible = false + instance_neptune_parameter_group_name = "default.neptune1.3" + instance_class = "db.t3.medium" + + aws_neptune_cluster_admin_email = local.admin_email + aws_neptune_cluster_gateway_id = local.gateway_id + aws_neptune_cluster_region = local.aws_region + aws_neptune_cluster_parent_asset_id = module.aws-default-account-asset.this.asset_id + + aws_log_group_audit_pull_enabled = true +} diff --git a/examples/onboard-aws-rds-mariadb/README.md b/examples/onboard-aws-rds-mariadb/README.md new file mode 100644 index 0000000..5f43aa6 --- /dev/null +++ b/examples/onboard-aws-rds-mariadb/README.md @@ -0,0 +1,42 @@ +# Onboard Amazon RDS for MariaDB example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-RDS-for-MariaDB-Onboarding-Steps_48367019.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-rds-mariadb-1](#module\_aws-rds-mariadb-1) | ../../modules/onboard-aws-rds-mariadb | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-rds-mariadb/main.tf b/examples/onboard-aws-rds-mariadb/main.tf new file mode 100644 index 0000000..c1eb3ea --- /dev/null +++ b/examples/onboard-aws-rds-mariadb/main.tf @@ -0,0 +1,93 @@ +locals { + aws_region = "us-east-2" + + admin_email = "test@example.com" + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# 1. AWS cloud account +################################################################################ +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::1234567890" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# AWS RDS MariaDB 10.11 +################################################################################ +module "aws-rds-mariadb-1" { + source = "../../modules/onboard-aws-rds-mariadb" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_rds_mariadb_admin_email = local.admin_email + aws_rds_mariadb_gateway_id = local.gateway_id + aws_rds_mariadb_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_rds_mariadb_region = local.aws_region + + instance_db_name = "testdb" + instance_enabled_cloudwatch_logs_exports = ["audit"] + instance_engine_version = "10.11" + instance_identifier = "example-tf-rds-mariadb" + instance_instance_class = "db.t3.small" + instance_password = "abcd1234" + instance_publicly_accessible = true + instance_skip_final_snapshot = true + instance_subnet_group_name = "default" + instance_username = "admin" + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + option_group_major_engine_version = "10.11" + option_group_name = "example-tf-mariadb-og" + option_group_options = [ + { + option_name = "MARIADB_AUDIT_PLUGIN" + option_settings = [ + { + name = "SERVER_AUDIT_EVENTS" + value = "CONNECT,QUERY,TABLE" + }, + { + name = "SERVER_AUDIT_EXCL_USERS" + value = "rdsadmin" + } + ] + } + ] +} diff --git a/examples/onboard-aws-rds-mysql-slow-query/README.md b/examples/onboard-aws-rds-mysql-slow-query/README.md new file mode 100644 index 0000000..519f2f6 --- /dev/null +++ b/examples/onboard-aws-rds-mysql-slow-query/README.md @@ -0,0 +1,42 @@ +# Onboard Amazon RDS for MySQL with Slow Query example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-RDS-for-MySQL-Onboarding-Steps_48367035.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-rds-mysql-1](#module\_aws-rds-mysql-1) | ../../modules/onboard-aws-rds-mysql-slow-query | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-rds-mysql-slow-query/main.tf b/examples/onboard-aws-rds-mysql-slow-query/main.tf new file mode 100644 index 0000000..7b51c82 --- /dev/null +++ b/examples/onboard-aws-rds-mysql-slow-query/main.tf @@ -0,0 +1,80 @@ +locals { + aws_region = "us-east-2" + + admin_email = "test@example.com" + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" + + master_user = "admin" + master_password = "abcd1234" + slow_query_threshold = 30 # seconds +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# 1. AWS cloud account +################################################################################ +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::1234567890" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# AWS RDS MySQL 8.0 +################################################################################ +module "aws-rds-mysql-1" { + source = "../../modules/onboard-aws-rds-mysql-slow-query" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_rds_mysql_admin_email = local.admin_email + aws_rds_mysql_gateway_id = local.gateway_id + aws_rds_mysql_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_rds_mysql_region = local.aws_region + + instance_engine_version = "8.0" + instance_identifier = "example-tf-mysql-8-slow-query" + instance_password = local.master_password + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + option_group_major_engine_version = "8.0" + option_group_name = "example-tf-mysql-8-slow-query-og" + + parameter_group_family = "mysql8.0" + parameter_group_name = "example-tf-mysql-8-slow-query-pg" +} diff --git a/examples/onboard-aws-rds-mysql/README.md b/examples/onboard-aws-rds-mysql/README.md new file mode 100644 index 0000000..76a5dd1 --- /dev/null +++ b/examples/onboard-aws-rds-mysql/README.md @@ -0,0 +1,43 @@ +# Onboard Amazon RDS for MySQL example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-RDS-for-MySQL-Onboarding-Steps_48367035.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-rds-mysql-1](#module\_aws-rds-mysql-1) | ../../modules/onboard-aws-rds-mysql | n/a | +| [aws-rds-mysql-2](#module\_aws-rds-mysql-2) | ../../modules/onboard-aws-rds-mysql | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-rds-mysql/main.tf b/examples/onboard-aws-rds-mysql/main.tf new file mode 100644 index 0000000..4509f5a --- /dev/null +++ b/examples/onboard-aws-rds-mysql/main.tf @@ -0,0 +1,108 @@ +locals { + aws_region = "us-east-2" + + admin_email = "test@example.com" + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" + + master_user = "admin" + master_pass = "abcd1234" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# 1. AWS cloud account +################################################################################ +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::1234567890" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# AWS RDS MySQL 8.0 +################################################################################ +module "aws-rds-mysql-1" { + source = "../../modules/onboard-aws-rds-mysql" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_rds_mysql_admin_email = local.admin_email + aws_rds_mysql_gateway_id = local.gateway_id + aws_rds_mysql_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_rds_mysql_region = local.aws_region + + instance_engine_version = "8.0" + instance_identifier = "example-tf-mysql-8" + instance_instance_class = "db.t3.small" + instance_password = local.master_pass + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + option_group_major_engine_version = "8.0" + option_group_name = "example-tf-mysql-8-og" +} + +################################################################################ +# AWS RDS MySQL 5.7 Aggregated +################################################################################ +module "aws-rds-mysql-2" { + source = "../../modules/onboard-aws-rds-mysql" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_rds_mysql_admin_email = local.admin_email + aws_rds_mysql_audit_type = "AGGREGATED" + aws_rds_mysql_gateway_id = local.gateway_id + aws_rds_mysql_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_rds_mysql_region = local.aws_region + + instance_engine_version = "5.7" + instance_identifier = "example-tf-mysql-5-7" + instance_instance_class = "db.t3.small" + instance_password = local.master_pass + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + option_group_major_engine_version = "5.7" + option_group_name = "example-tf-mysql-5-7-og" +} diff --git a/examples/onboard-aws-rds-oracle-standard/README.md b/examples/onboard-aws-rds-oracle-standard/README.md new file mode 100644 index 0000000..5a7c0f7 --- /dev/null +++ b/examples/onboard-aws-rds-oracle-standard/README.md @@ -0,0 +1,54 @@ +# Onboard Amazon RDS for Oracle (Standard Audit via CloudWatch) example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/48367051.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created CloudWatch log group. + +### Database Configuration +Part of the onboarding process involves connecting to your RDS Oracle instance and running SQL commands to create an audit policy. This module includes an example for how to connect to the instance from your local machine and create this. + +**Note:** This example requires the ``sqlplus`` client to be installed, as well as for the newly created RDS instance to be accessible from your local machine. + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [terraform](#provider\_terraform) | n/a | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-key-pair-account-asset](#module\_aws-key-pair-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-rds-oracle-standard-1](#module\_aws-rds-oracle-standard-1) | ../../modules/onboard-aws-rds-oracle-standard | n/a | +| [aws-rds-oracle-standard-2](#module\_aws-rds-oracle-standard-2) | ../../modules/onboard-aws-rds-oracle-standard | n/a | + +## Resources + +| Name | Type | +|------|------| +| [terraform_data.configure_database](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_access\_key](#input\_aws\_access\_key) | n/a | `any` | n/a | yes | +| [aws\_secret\_key](#input\_aws\_secret\_key) | n/a | `any` | n/a | yes | +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-rds-oracle-standard/configure_audit_policy.sql b/examples/onboard-aws-rds-oracle-standard/configure_audit_policy.sql new file mode 100644 index 0000000..c3c41ec --- /dev/null +++ b/examples/onboard-aws-rds-oracle-standard/configure_audit_policy.sql @@ -0,0 +1,4 @@ +AUDIT SESSION BY ACCESS; +AUDIT ALL BY ACCESS; +AUDIT ALL STATEMENTS BY ACCESS; +exit; diff --git a/examples/onboard-aws-rds-oracle-standard/configure_database.sh b/examples/onboard-aws-rds-oracle-standard/configure_database.sh new file mode 100755 index 0000000..1781c5a --- /dev/null +++ b/examples/onboard-aws-rds-oracle-standard/configure_database.sh @@ -0,0 +1,30 @@ +#!/bin/bash +# Creates an audit policy on an Oracle instance using 'sqlplus' + +# Settings +current_directory=$(dirname "$(realpath "${BASH_SOURCE[0]}")") +policy_sql_file="${current_directory}/configure_audit_policy.sql" + +# Functions +function is_pkg_installed { + local pkg="$1" + if ! command -v "${pkg}" &> /dev/null + then + echo "Package '${pkg}' is not installed." + echo "Exiting..." + exit 1 + else + return 0 + fi +} + +is_pkg_installed "sqlplus" + +# Create audit policy +if [ ! -r "${policy_sql_file}" ]; then + echo "Unable to read ${policy_sql_file}" + echo "Exiting..." + exit 1 +else + sqlplus ${ADMIN_USER}/${ADMIN_PASSWORD}@${HOSTNAME}/${SID}:${PORT} @${policy_sql_file} +fi diff --git a/examples/onboard-aws-rds-oracle-standard/main.tf b/examples/onboard-aws-rds-oracle-standard/main.tf new file mode 100644 index 0000000..601e6a1 --- /dev/null +++ b/examples/onboard-aws-rds-oracle-standard/main.tf @@ -0,0 +1,132 @@ +locals { + aws_region = "us-east-2" + + admin_email = "test@example.com" + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" + + master_user = "admin" + master_password = "abcd1234" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# 1. AWS cloud account +# 2. Method to create audit policies on Oracle instance +################################################################################ +# 1. AWS key pair variables (sourced from ENV vars) +variable "aws_access_key" {} +variable "aws_secret_key" {} + +module "aws-key-pair-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-key-pair-account-asset" + asset_id = "arn:aws:iam::0123456789" + auth_mechanism = "key" + aws_access_key = var.aws_access_key + aws_secret_key = var.aws_secret_key + gateway_id = local.gateway_id + region = local.aws_region +} + +# 2. Run shell script locally to create audit policy +resource "terraform_data" "configure_database" { + depends_on = [module.aws-rds-oracle-standard-1] + + provisioner "local-exec" { + environment = { + ADMIN_USER = local.master_user + ADMIN_PASSWORD = local.master_password + HOSTNAME = module.aws-rds-oracle-standard-1.oracle-instance.address + SID = module.aws-rds-oracle-standard-1.oracle-instance.db_name + PORT = module.aws-rds-oracle-standard-1.oracle-instance.port + } + + command = "./configure_database.sh" + + on_failure = fail + } +} + +################################################################################ +# AWS RDS Oracle 19 +################################################################################ +module "aws-rds-oracle-standard-1" { + source = "../../modules/onboard-aws-rds-oracle-standard" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_rds_oracle_admin_email = local.admin_email + aws_rds_oracle_gateway_id = local.gateway_id + aws_rds_oracle_parent_asset_id = module.aws-key-pair-account-asset.this.asset_id + aws_rds_oracle_region = local.aws_region + + instance_engine_version = "19" + instance_identifier = "example-tf-oracle-19" + instance_password = local.master_password + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + parameter_group_family = "oracle-ee-19" + parameter_group_name = "example-tf-oracle-19-pg" +} + +################################################################################ +# AWS RDS Oracle 19 Aggregated +################################################################################ +module "aws-rds-oracle-standard-2" { + source = "../../modules/onboard-aws-rds-oracle-standard" + + aws_log_group_admin_email = local.admin_email + aws_log_group_audit_pull_enabled = true + aws_log_group_gateway_id = local.gateway_id + aws_log_group_region = local.aws_region + + aws_rds_oracle_admin_email = local.admin_email + aws_rds_oracle_audit_type = "AGGREGATED" + aws_rds_oracle_gateway_id = local.gateway_id + aws_rds_oracle_parent_asset_id = module.aws-key-pair-account-asset.this.asset_id + aws_rds_oracle_region = local.aws_region + + instance_engine_version = "19" + instance_identifier = "example-tf-oracle-19" + instance_password = local.master_password + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + parameter_group_family = "oracle-ee-19" + parameter_group_name = "example-tf-oracle-19-pg" +} diff --git a/examples/onboard-aws-rds-oracle-unified/README.md b/examples/onboard-aws-rds-oracle-unified/README.md new file mode 100644 index 0000000..3190eea --- /dev/null +++ b/examples/onboard-aws-rds-oracle-unified/README.md @@ -0,0 +1,48 @@ +# Onboard Amazon RDS for Oracle (Standard Audit via CloudWatch) example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/48367067.html). + +This example creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +## Prerequisites +### Database Configuration +Part of the onboarding process involves connecting to your RDS Oracle instance and running SQL commands to create an audit pull user, as well as an audit policy. This module includes an example for how to connect to the instance from your local machine and create both of these. + +**Note:** This example requires the ``sqlplus`` client to be installed, as well as for the newly created RDS instance to be accessible from your local machine. + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [terraform](#provider\_terraform) | n/a | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-rds-oracle-unified-1](#module\_aws-rds-oracle-unified-1) | ../../modules/onboard-aws-rds-oracle-unified | n/a | +| [aws-rds-oracle-unified-2](#module\_aws-rds-oracle-unified-2) | ../../modules/onboard-aws-rds-oracle-unified | n/a | + +## Resources + +| Name | Type | +|------|------| +| [terraform_data.configure_database](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-rds-oracle-unified/configure_audit_policy.sql b/examples/onboard-aws-rds-oracle-unified/configure_audit_policy.sql new file mode 100644 index 0000000..13cece6 --- /dev/null +++ b/examples/onboard-aws-rds-oracle-unified/configure_audit_policy.sql @@ -0,0 +1,22 @@ +SET serveroutput ON; + +DECLARE + c int; + stmt varchar2(1000); +BEGIN + SELECT COUNT(*) INTO c FROM AUDIT_UNIFIED_POLICIES WHERE policy_name = UPPER('&1'); + IF c = 0 THEN + dbms_output.put_line('Creating audit policy &1...'); + stmt := 'CREATE AUDIT POLICY &1 ACTIONS ALL ONLY TOPLEVEL'; + EXECUTE IMMEDIATE stmt; + + dbms_output.put_line('Enabling audit policy &1...'); + stmt := 'AUDIT POLICY &1'; + EXECUTE IMMEDIATE stmt; + ELSE + dbms_output.put_line('Audit policy &1 already exists.'); + END IF; +END; +/ + +exit; diff --git a/examples/onboard-aws-rds-oracle-unified/configure_audit_pull_user.sql b/examples/onboard-aws-rds-oracle-unified/configure_audit_pull_user.sql new file mode 100644 index 0000000..01e8b41 --- /dev/null +++ b/examples/onboard-aws-rds-oracle-unified/configure_audit_pull_user.sql @@ -0,0 +1,24 @@ +SET serveroutput ON; + +DECLARE + c int; + stmt varchar2(1000); +BEGIN + SELECT COUNT(*) INTO c FROM DBA_USERS WHERE username = UPPER('&1'); + IF c = 0 THEN + dbms_output.put_line('Creating audit pull user &1...'); + stmt := 'CREATE USER &1 IDENTIFIED BY &2'; + EXECUTE IMMEDIATE stmt; + + dbms_output.put_line('Granting permissions to user &1...'); + stmt := 'GRANT CREATE SESSION TO &1'; + EXECUTE IMMEDIATE stmt; + stmt := 'GRANT SELECT ON UNIFIED_AUDIT_TRAIL TO &1'; + EXECUTE IMMEDIATE stmt; + ELSE + dbms_output.put_line('User &1 already exists.'); + END IF; +END; +/ + +exit; diff --git a/examples/onboard-aws-rds-oracle-unified/configure_database.sh b/examples/onboard-aws-rds-oracle-unified/configure_database.sh new file mode 100755 index 0000000..ae4b8cc --- /dev/null +++ b/examples/onboard-aws-rds-oracle-unified/configure_database.sh @@ -0,0 +1,42 @@ +#!/bin/bash +# Creates an audit pull user as well as an audit policy on an Oracle instance using 'sqlplus' + +# Settings +current_directory=$(dirname "$(realpath "${BASH_SOURCE[0]}")") +user_sql_file="${current_directory}/configure_audit_pull_user.sql" +policy_sql_file="${current_directory}/configure_audit_policy.sql" + +# Functions +function is_pkg_installed { + local pkg="$1" + if ! command -v "${pkg}" &> /dev/null + then + echo "Package '${pkg}' is not installed." + echo "Exiting..." + exit 1 + else + return 0 + fi +} + +is_pkg_installed "sqlplus" + +# Create audit policy +if [ ! -r "${policy_sql_file}" ]; then + echo "Unable to read ${policy_sql_file}" + echo "Exiting..." + exit 1 +else + sqlplus ${ADMIN_USER}/${ADMIN_PASSWORD}@${HOSTNAME}/${SID}:${PORT} \ + @${policy_sql_file} ${AUDIT_POLICY_NAME} +fi + +# Create audit pull user +if [ ! -r "${user_sql_file}" ]; then + echo "Unable to read ${user_sql_file}" + echo "Exiting..." + exit 1 +else + sqlplus ${ADMIN_USER}/${ADMIN_PASSWORD}@${HOSTNAME}/${SID}:${PORT} \ + @${user_sql_file} ${AUDIT_PULL_USERNAME} ${AUDIT_PULL_PASSWORD} +fi diff --git a/examples/onboard-aws-rds-oracle-unified/main.tf b/examples/onboard-aws-rds-oracle-unified/main.tf new file mode 100644 index 0000000..f54a317 --- /dev/null +++ b/examples/onboard-aws-rds-oracle-unified/main.tf @@ -0,0 +1,118 @@ +locals { + aws_region = "us-east-2" + + admin_email = "test@example.com" + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" + + master_user = "admin" + master_password = "abcd1234" + audit_pull_user = "sonarlogaudit" + audit_pull_password = "abcd1234" + audit_policy_name = "testpol" +} + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Prerequisites +# 1. Method to create audit pull user as well as audit policies +################################################################################ +# 1. Run shell script locally to create audit pull user and policies +resource "terraform_data" "configure_database" { + depends_on = [module.aws-rds-oracle-unified-1] + + provisioner "local-exec" { + environment = { + ADMIN_USER = local.master_user + ADMIN_PASSWORD = local.master_password + HOSTNAME = module.aws-rds-oracle-unified-1.oracle-instance.address + SID = module.aws-rds-oracle-unified-1.oracle-instance.db_name + PORT = module.aws-rds-oracle-unified-1.oracle-instance.port + + AUDIT_POLICY_NAME = local.audit_policy_name + AUDIT_PULL_USERNAME = local.audit_pull_user + AUDIT_PULL_PASSWORD = local.audit_pull_password + } + + command = "./configure_database.sh" + + on_failure = fail + } + +} + +################################################################################ +# AWS RDS Oracle 19 +################################################################################ +module "aws-rds-oracle-unified-1" { + source = "../../modules/onboard-aws-rds-oracle-unified" + + aws_rds_oracle_admin_email = local.admin_email + aws_rds_oracle_audit_pull_enabled = true + aws_rds_oracle_auth_mechanism = "password" + aws_rds_oracle_gateway_id = local.gateway_id + aws_rds_oracle_password = local.audit_pull_password + aws_rds_oracle_reason = "default" + aws_rds_oracle_username = local.audit_pull_user + + instance_engine_version = "19" + instance_identifier = "example-tf-oracle-19" + instance_password = local.master_password + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + parameter_group_family = "oracle-ee-19" + parameter_group_name = "example-tf-oracle-19-pg" +} + +################################################################################ +# AWS RDS Oracle 19 Aggregated +################################################################################ +module "aws-rds-oracle-unified-2" { + source = "../../modules/onboard-aws-rds-oracle-unified" + + aws_rds_oracle_admin_email = local.admin_email + aws_rds_oracle_audit_pull_enabled = true + aws_rds_oracle_audit_type = "UNIFIED_AGGREGATED" + aws_rds_oracle_auth_mechanism = "password" + aws_rds_oracle_gateway_id = local.gateway_id + aws_rds_oracle_password = local.audit_pull_password + aws_rds_oracle_reason = "default" + aws_rds_oracle_username = local.audit_pull_user + + instance_engine_version = "19" + instance_identifier = "example-tf-oracle-19" + instance_password = local.master_password + instance_subnet_group_name = "default" + instance_username = local.master_user + instance_vpc_security_group_ids = [ + "sg-0123456789abcdefg" + ] + + parameter_group_family = "oracle-ee-19" + parameter_group_name = "example-tf-oracle-19-pg" +} diff --git a/examples/onboard-aws-redshift/README.md b/examples/onboard-aws-redshift/README.md new file mode 100644 index 0000000..f1c1b0d --- /dev/null +++ b/examples/onboard-aws-redshift/README.md @@ -0,0 +1,66 @@ +# Onboard Amazon Redshift example +This example includes additional prerequisites that will need to be completed to fully utilize the module. More details can be found in the [onboarding documentation](https://docs.imperva.com/bundle/onboarding-databases-to-sonar-reference-guide/page/Amazon-Redshift-Onboarding-Steps_48367115.html). + +It creates both 'aws' and 'dsfhub' resources. More information regarding authentication to each one can be found in the relevant provider documentation: +- [aws](https://registry.terraform.io/providers/hashicorp/aws/latest/docs) +- [dsfhub](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs) + +Importantly, the example includes two different audit methods: auditing via the Audit Tables, or auditing via an S3 bucket. Please choose your desired audit method. + +## Option 1: Auditing via Audit Tables +### Prerequisites +#### Database Configuration +Part of the onboarding process involves connecting to your Redshift cluster and running SQL commands to create an audit pull user. This module includes an example for how to connect to the instance from your local machine and create it. + +**Note:** This example requires the ``psql`` client to be installed, as well as for the newly created Redshift cluster to be accessible from your local machine. + +## Option 2: Auditing via S3 + +### Prerequisites +#### Account Asset Permissions +An AWS account asset will need to be onboarded to your DSF hub prior to using this module. The account asset will need to be granted permissions to be able to read from the newly created S3 bucket. In addition, the cloud account should be granted these additional permissions: + +``` +s3:GetObject +s3:ListBucket +s3:ListAllMyBuckets +``` + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | +| [terraform](#provider\_terraform) | n/a | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-default-account-asset](#module\_aws-default-account-asset) | imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account | n/a | +| [aws-redshift-1](#module\_aws-redshift-1) | ../../modules/onboard-aws-redshift-s3 | n/a | +| [aws-redshift-cluster-1](#module\_aws-redshift-cluster-1) | ../../modules/onboard-aws-redshift-odbc | n/a | + +## Resources + +| Name | Type | +|------|------| +| [terraform_data.configure_database](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource | +| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [dsfhub\_host](#input\_dsfhub\_host) | n/a | `any` | n/a | yes | +| [dsfhub\_token](#input\_dsfhub\_token) | n/a | `any` | n/a | yes | + +## Outputs + +No outputs. + \ No newline at end of file diff --git a/examples/onboard-aws-redshift/configure_audit_pull_user.sql b/examples/onboard-aws-redshift/configure_audit_pull_user.sql new file mode 100644 index 0000000..36e593c --- /dev/null +++ b/examples/onboard-aws-redshift/configure_audit_pull_user.sql @@ -0,0 +1,4 @@ +CREATE USER :username PASSWORD :'password'; +ALTER USER :username WITH SYSLOG ACCESS UNRESTRICTED; +GRANT SELECT ON pg_catalog.STL_CONNECTION_LOG, pg_catalog.SVL_STATEMENTTEXT, pg_catalog.STL_SESSIONS, pg_catalog.PG_USER, pg_catalog.STV_SESSIONS TO :username; +\q \ No newline at end of file diff --git a/examples/onboard-aws-redshift/configure_database.sh b/examples/onboard-aws-redshift/configure_database.sh new file mode 100755 index 0000000..05e7965 --- /dev/null +++ b/examples/onboard-aws-redshift/configure_database.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Creates an audit pull user on a Redshift cluster using the 'psql' client + +# Settings +current_directory=$(dirname "$(realpath "${BASH_SOURCE[0]}")") +user_sql_file="${current_directory}/configure_audit_pull_user.sql" + +# Functions +function is_pkg_installed { + local pkg="$1" + if ! command -v "${pkg}" &> /dev/null + then + echo "Package '${pkg}' is not installed." + echo "Install on MacOS: brew install libpq" + echo "Install on Ubuntu: apt-get install -y libpq-dev" + echo "Install on CentOS: yum install -y libpq" + echo "Exiting..." + exit 1 + else + return 0 + fi +} + +is_pkg_installed "psql" + +# Create audit pull user +if [ ! -r "${user_sql_file}" ]; then + echo "Unable to read ${user_sql_file}" + echo "Exiting..." + exit 1 +else + echo "Creating audit pull user..." + PGPASSWORD="${ADMIN_PASSWORD}" psql -h "${HOSTNAME}" -p "${PORT}" -U "${ADMIN_USER}" -d "${DATABASE}" -v username="${AUDIT_PULL_USERNAME}" -v password="${AUDIT_PULL_PASSWORD}" -f "${user_sql_file}" +fi diff --git a/examples/onboard-aws-redshift/main.tf b/examples/onboard-aws-redshift/main.tf new file mode 100644 index 0000000..84012e6 --- /dev/null +++ b/examples/onboard-aws-redshift/main.tf @@ -0,0 +1,141 @@ +locals { + aws_region = "us-east-1" + apply_immediately = true + master_user = "admin" + master_password = "Abcd1234" + + audit_pull_user = "sonarlogaudit" + audit_pull_password = "Abcd1234" + + bucket_name = "tf-s3-bucket" + + admin_email = "test@example.com" + gateway_id = "a1b2c3d4-e5f6-g8h9-wxyz-123456790" +} + + +################################################################################ +# Providers +################################################################################ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +provider "aws" { + region = local.aws_region +} + +data "aws_caller_identity" "current" {} + +variable "dsfhub_host" {} # TF_VAR_dsfhub_host env variable +variable "dsfhub_token" {} # TF_VAR_dsfhub_token env variable + +provider "dsfhub" { + dsfhub_host = var.dsfhub_host + dsfhub_token = var.dsfhub_token +} + +################################################################################ +# Redshift via Table Prerequisites +# 1. Method to create audit pull user +################################################################################ +# Runs the shell script locally to create the audit pull user +resource "terraform_data" "configure_database" { + depends_on = [module.aws-redshift-cluster-1] + + provisioner "local-exec" { + environment = { + ADMIN_USER = local.master_user + ADMIN_PASSWORD = local.master_password + HOSTNAME = regex("(.*):", module.aws-redshift-cluster-1.redshift-cluster.endpoint)[0] + DATABASE = module.aws-redshift-cluster-1.redshift-cluster.database_name + PORT = module.aws-redshift-cluster-1.redshift-cluster.port + + AUDIT_PULL_USERNAME = local.audit_pull_user + AUDIT_PULL_PASSWORD = local.audit_pull_password + } + + command = "./configure_database.sh" + + on_failure = fail + } +} + +################################################################################ +# Amazon Redshift Cluster via Table +################################################################################ +module "aws-redshift-cluster-1" { + source = "../../modules/onboard-aws-redshift-odbc" + + aws_redshift_admin_email = local.admin_email + aws_redshift_audit_pull_enabled = true + aws_redshift_gateway_id = local.gateway_id + aws_redshift_region = local.aws_region + aws_redshift_username = local.audit_pull_user + aws_redshift_password = local.audit_pull_password + + redshift_apply_immediately = local.apply_immediately + redshift_cluster_identifier = "tf-redshift" + redshift_cluster_subnet_group_name = "default" + redshift_master_password = local.master_password + redshift_master_username = local.master_user + redshift_skip_final_snapshot = true + redshift_vpc_security_group_ids = ["sg-0123456789abcdefg"] +} + +################################################################################ +# Redshift via S3 Prerequisites +# 1. AWS cloud account +################################################################################ +# 1. AWS cloud account +# Note that the following additional privileges are required for the AWS cloud account: +# s3:GetObject +# s3:ListBucket +# s3:ListAllMyBuckets +module "aws-default-account-asset" { + source = "imperva/agentless-onboarding/dsfhub//modules/dsfhub-aws-cloud-account" + + admin_email = local.admin_email + asset_display_name = "aws-account-asset" + asset_id = "arn:aws:iam::1234567890" + auth_mechanism = "default" + gateway_id = local.gateway_id + region = local.aws_region +} + +################################################################################ +# Amazon Redshift Cluster via S3 +################################################################################ +module "aws-redshift-1" { + source = "../../modules/onboard-aws-redshift-s3" + + aws_redshift_admin_email = local.admin_email + aws_redshift_gateway_id = local.gateway_id + aws_redshift_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_redshift_region = local.aws_region + aws_redshift_bucket_account_id = data.aws_caller_identity.current.account_id + + aws_s3_admin_email = local.admin_email + aws_s3_audit_pull_enabled = true + aws_s3_asset_display_name = "tf-aws-s3-asset" + aws_s3_bucket_account_id = data.aws_caller_identity.current.account_id + aws_s3_gateway_id = local.gateway_id + aws_s3_parent_asset_id = module.aws-default-account-asset.this.asset_id + aws_s3_region = local.aws_region + + redshift_apply_immediately = local.apply_immediately + redshift_cluster_identifier = "tf-redshift-via-s3" + redshift_cluster_subnet_group_name = "default" + redshift_master_password = local.master_password + redshift_master_username = local.master_user + redshift_skip_final_snapshot = true + redshift_vpc_security_group_ids = ["sg-0123456789abcdefg"] + + parameter_group_name = "tf-redshift-s3-pg" + + s3_bucket = local.bucket_name +} diff --git a/modules/aws-docdb-cluster-instance/README.md b/modules/aws-docdb-cluster-instance/README.md new file mode 100644 index 0000000..a85081b --- /dev/null +++ b/modules/aws-docdb-cluster-instance/README.md @@ -0,0 +1,38 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_docdb_cluster_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster_instance) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | Identifier of AWS DocumentDB Cluster. | `string` | n/a | yes | +| [instance\_class](#input\_instance\_class) | The instance type of the DocumentDB cluster. Example: 'db.r5.large'. Reference: https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs | `string` | `"db.r5.large"` | no | +| [instance\_count](#input\_instance\_count) | The number of instances to create in the DocumentDB cluster. | `number` | `1` | no | +| [promotion\_tier](#input\_promotion\_tier) | Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoted to a writer in case of failover. | `number` | `0` | no | +| [tags](#input\_tags) | A map of tags to assign to the DocumentDB instance. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS DocumentDB Cluster instance | + \ No newline at end of file diff --git a/modules/aws-docdb-cluster-instance/main.tf b/modules/aws-docdb-cluster-instance/main.tf new file mode 100644 index 0000000..1830dda --- /dev/null +++ b/modules/aws-docdb-cluster-instance/main.tf @@ -0,0 +1,12 @@ +resource "aws_docdb_cluster_instance" "this" { + + apply_immediately = var.apply_immediately + + cluster_identifier = var.cluster_identifier + count = var.instance_count + engine = "docdb" + instance_class = var.instance_class + identifier = "${var.cluster_identifier}-${count.index}" + promotion_tier = var.promotion_tier + tags = var.tags +} diff --git a/modules/aws-docdb-cluster-instance/output.tf b/modules/aws-docdb-cluster-instance/output.tf new file mode 100644 index 0000000..54b3972 --- /dev/null +++ b/modules/aws-docdb-cluster-instance/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS DocumentDB Cluster instance" + value = aws_docdb_cluster_instance.this +} diff --git a/modules/aws-docdb-cluster-instance/variables.tf b/modules/aws-docdb-cluster-instance/variables.tf new file mode 100644 index 0000000..fc8ab57 --- /dev/null +++ b/modules/aws-docdb-cluster-instance/variables.tf @@ -0,0 +1,34 @@ +variable "apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "cluster_identifier" { + description = "Identifier of AWS DocumentDB Cluster." + type = string +} + +variable "instance_count" { + description = "The number of instances to create in the DocumentDB cluster." + type = number + default = 1 +} + +variable "instance_class" { + description = "The instance type of the DocumentDB cluster. Example: 'db.r5.large'. Reference: https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs" + type = string + default = "db.r5.large" +} + +variable "promotion_tier" { + description = "Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoted to a writer in case of failover." + type = number + default = 0 +} + +variable "tags" { + description = "A map of tags to assign to the DocumentDB instance." + type = map(string) + default = null +} diff --git a/modules/aws-docdb-cluster-parameter-group/README.md b/modules/aws-docdb-cluster-parameter-group/README.md new file mode 100644 index 0000000..efc4116 --- /dev/null +++ b/modules/aws-docdb-cluster-parameter-group/README.md @@ -0,0 +1,37 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_docdb_cluster_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster_parameter_group) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [description](#input\_description) | The description of the DocumentDB cluster parameter group. | `string` | `null` | no | +| [family](#input\_family) | Database family version, e.g. "docdb5.0" | `string` | `"docdb5.0"` | no | +| [name](#input\_name) | The name of the DocumentDB cluster parameter group. | `string` | `"docdb-parameter-group"` | no | +| [parameters](#input\_parameters) | List of objects containing parameters for the DocumentDB parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"apply_method": "immediate",
"name": "audit_logs",
"value": "all"
}
]
| no | +| [tags](#input\_tags) | A map of tags to assign to the cluster. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS DocumentDB Parameter Group | + \ No newline at end of file diff --git a/modules/aws-docdb-cluster-parameter-group/main.tf b/modules/aws-docdb-cluster-parameter-group/main.tf new file mode 100644 index 0000000..7bc447a --- /dev/null +++ b/modules/aws-docdb-cluster-parameter-group/main.tf @@ -0,0 +1,16 @@ +resource "aws_docdb_cluster_parameter_group" "this" { + name = var.name + family = var.family + description = var.description + tags = var.tags + + dynamic "parameter" { + for_each = var.parameters + + content { + name = parameter.value.name + value = parameter.value.value + apply_method = parameter.value.apply_method != null ? parameter.value.apply_method : null + } + } +} diff --git a/modules/aws-docdb-cluster-parameter-group/output.tf b/modules/aws-docdb-cluster-parameter-group/output.tf new file mode 100644 index 0000000..8f06c76 --- /dev/null +++ b/modules/aws-docdb-cluster-parameter-group/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS DocumentDB Parameter Group" + value = aws_docdb_cluster_parameter_group.this +} diff --git a/modules/aws-docdb-cluster-parameter-group/variables.tf b/modules/aws-docdb-cluster-parameter-group/variables.tf new file mode 100644 index 0000000..552858c --- /dev/null +++ b/modules/aws-docdb-cluster-parameter-group/variables.tf @@ -0,0 +1,38 @@ +variable "description" { + type = string + description = "The description of the DocumentDB cluster parameter group." + default = null +} +variable "family" { + description = "Database family version, e.g. \"docdb5.0\"" + type = string + default = "docdb5.0" +} + +variable "name" { + description = "The name of the DocumentDB cluster parameter group." + type = string + default = "docdb-parameter-group" +} + +variable "parameters" { + description = "List of objects containing parameters for the DocumentDB parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [{ + name = "audit_logs" + value = "all" + apply_method = "immediate" + }] +} + +variable "tags" { + description = "A map of tags to assign to the cluster." + type = map(string) + default = null +} diff --git a/modules/aws-docdb-cluster/README.md b/modules/aws-docdb-cluster/README.md new file mode 100644 index 0000000..ab6d925 --- /dev/null +++ b/modules/aws-docdb-cluster/README.md @@ -0,0 +1,47 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_docdb_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/docdb_cluster) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | Identifier of AWS DocumentDB Cluster. | `string` | n/a | yes | +| [db\_cluster\_parameter\_group\_name](#input\_db\_cluster\_parameter\_group\_name) | Name of the DocumentDB Cluster parameter group. | `string` | n/a | yes | +| [db\_subnet\_group\_name](#input\_db\_subnet\_group\_name) | A DB subnet group to associate with this DB instance. | `string` | n/a | yes | +| [deletion\_protection](#input\_deletion\_protection) | A value that indicates whether the DB cluster has deletion protection enabled. The database can't be deleted when deletion protection is enabled. | `bool` | `false` | no | +| [enabled\_cloudwatch\_logs\_exports](#input\_enabled\_cloudwatch\_logs\_exports) | List of log types to export to CloudWatch. | `list(string)` |
[
"audit"
]
| no | +| [engine\_version](#input\_engine\_version) | Database engine version, e.g. "5.0.0" | `string` | `"5.0.0"` | no | +| [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [master\_password](#input\_master\_password) | Password for the master DB user. | `string` | n/a | yes | +| [master\_username](#input\_master\_username) | Master DB username. | `string` | `"docdb"` | no | +| [port](#input\_port) | The port on which the DB accepts connections. | `number` | `27017` | no | +| [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final\_snapshot\_identifier | `bool` | `true` | no | +| [storage\_type](#input\_storage\_type) | The storage type to associate with the DB cluster. | `string` | `"standard"` | no | +| [tags](#input\_tags) | A map of tags to assign to the DB cluster. | `map(string)` | `null` | no | +| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | List of VPC security groups to associate with the Cluster | `list(string)` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS DocumentDB Cluster | + \ No newline at end of file diff --git a/modules/aws-docdb-cluster/main.tf b/modules/aws-docdb-cluster/main.tf new file mode 100644 index 0000000..b168c0a --- /dev/null +++ b/modules/aws-docdb-cluster/main.tf @@ -0,0 +1,20 @@ +resource "aws_docdb_cluster" "this" { + + apply_immediately = var.apply_immediately + + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = var.db_cluster_parameter_group_name + db_subnet_group_name = var.db_subnet_group_name + deletion_protection = var.deletion_protection + enabled_cloudwatch_logs_exports = var.enabled_cloudwatch_logs_exports + engine = "docdb" + engine_version = var.engine_version + final_snapshot_identifier = var.final_snapshot_identifier + master_password = var.master_password + master_username = var.master_username + port = var.port + skip_final_snapshot = var.skip_final_snapshot + storage_type = var.storage_type + tags = var.tags + vpc_security_group_ids = var.vpc_security_group_ids +} diff --git a/modules/aws-docdb-cluster/output.tf b/modules/aws-docdb-cluster/output.tf new file mode 100644 index 0000000..18aaeea --- /dev/null +++ b/modules/aws-docdb-cluster/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS DocumentDB Cluster" + value = aws_docdb_cluster.this +} diff --git a/modules/aws-docdb-cluster/variables.tf b/modules/aws-docdb-cluster/variables.tf new file mode 100644 index 0000000..d35b081 --- /dev/null +++ b/modules/aws-docdb-cluster/variables.tf @@ -0,0 +1,96 @@ +variable "apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "cluster_identifier" { + description = "Identifier of AWS DocumentDB Cluster." + type = string +} + +variable "db_cluster_parameter_group_name" { + description = "Name of the DocumentDB Cluster parameter group." + type = string +} + +variable "db_subnet_group_name" { + description = "A DB subnet group to associate with this DB instance." + type = string +} + +variable "deletion_protection" { + description = "A value that indicates whether the DB cluster has deletion protection enabled. The database can't be deleted when deletion protection is enabled." + type = bool + default = false +} + +variable "enabled_cloudwatch_logs_exports" { + description = "List of log types to export to CloudWatch." + type = list(string) + default = ["audit"] + validation { + condition = alltrue([for log in var.enabled_cloudwatch_logs_exports : log == "audit" || log == "profiler"]) + error_message = "Invalid value in enabled_cloudwatch_logs_exports. Allowed values are 'audit' or 'profiler'." + } + validation { + condition = length(var.enabled_cloudwatch_logs_exports) == length(distinct(var.enabled_cloudwatch_logs_exports)) + error_message = "Duplicate item in enabled_cloudwatch_logs_exports. Allowed values are 'audit' or 'profiler'. Please ensure that each log type is unique." + } +} + +variable "engine_version" { + description = "Database engine version, e.g. \"5.0.0\"" + type = string + default = "5.0.0" +} + +variable "final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "master_password" { + description = "Password for the master DB user." + type = string +} + +variable "master_username" { + description = "Master DB username." + type = string + default = "docdb" +} + +variable "port" { + description = "The port on which the DB accepts connections." + type = number + default = 27017 +} + +variable "skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier" + type = bool + default = true +} + +variable "storage_type" { + description = "The storage type to associate with the DB cluster." + type = string + default = "standard" + validation { + condition = can(regex("^(iopt1|standard)$", var.storage_type)) + error_message = "Invalid value for storage_type. Allowed values are 'iopt1' or 'standard'." + } +} + +variable "tags" { + description = "A map of tags to assign to the DB cluster." + type = map(string) + default = null +} + +variable "vpc_security_group_ids" { + description = "List of VPC security groups to associate with the Cluster" + type = list(string) +} diff --git a/modules/aws-iam-policy/README.md b/modules/aws-iam-policy/README.md new file mode 100644 index 0000000..476012c --- /dev/null +++ b/modules/aws-iam-policy/README.md @@ -0,0 +1,38 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_iam_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [description](#input\_description) | Description of the IAM policy. | `string` | `"Managed by Terraform"` | no | +| [name](#input\_name) | Name of the policy. If omitted, Terraform will assign a random, unique name. | `string` | n/a | yes | +| [name\_prefix](#input\_name\_prefix) | Creates a unique name beginning with the specified prefix. Conflicts with 'name'. | `string` | `null` | no | +| [path](#input\_path) | Path in which to create the policy. Default: '/' | `string` | `"/"` | no | +| [policy](#input\_policy) | The policy document. This is a JSON formatted string. | `string` | n/a | yes | +| [tags](#input\_tags) | A map of tags to assign to the policy. | `map(string)` | `{}` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS IAM Policy | + \ No newline at end of file diff --git a/modules/aws-iam-policy/main.tf b/modules/aws-iam-policy/main.tf new file mode 100644 index 0000000..d4c411f --- /dev/null +++ b/modules/aws-iam-policy/main.tf @@ -0,0 +1,8 @@ +resource "aws_iam_policy" "this" { + name = var.name + name_prefix = var.name_prefix + description = var.description + path = var.path + policy = var.policy + tags = var.tags +} diff --git a/modules/aws-iam-policy/output.tf b/modules/aws-iam-policy/output.tf new file mode 100644 index 0000000..3b167ac --- /dev/null +++ b/modules/aws-iam-policy/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS IAM Policy" + value = aws_iam_policy.this +} diff --git a/modules/aws-iam-policy/variables.tf b/modules/aws-iam-policy/variables.tf new file mode 100644 index 0000000..6f30ecf --- /dev/null +++ b/modules/aws-iam-policy/variables.tf @@ -0,0 +1,33 @@ +variable "name" { + description = "Name of the policy. If omitted, Terraform will assign a random, unique name." + type = string +} + +variable "name_prefix" { + description = "Creates a unique name beginning with the specified prefix. Conflicts with 'name'." + type = string + default = null +} + +variable "description" { + description = "Description of the IAM policy." + type = string + default = "Managed by Terraform" +} + +variable "path" { + description = "Path in which to create the policy. Default: '/'" + type = string + default = "/" +} + +variable "policy" { + description = "The policy document. This is a JSON formatted string." + type = string +} + +variable "tags" { + description = "A map of tags to assign to the policy." + type = map(string) + default = {} +} diff --git a/modules/aws-iam-role-policy-attachment/README.md b/modules/aws-iam-role-policy-attachment/README.md new file mode 100644 index 0000000..7d63c87 --- /dev/null +++ b/modules/aws-iam-role-policy-attachment/README.md @@ -0,0 +1,34 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_iam_role_policy_attachment.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [policy\_arn](#input\_policy\_arn) | The ARN of the IAM policy you want to apply. | `string` | n/a | yes | +| [role](#input\_role) | The IAM role to attach the policy to. | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS IAM Role Policy Attachment | + \ No newline at end of file diff --git a/modules/aws-iam-role-policy-attachment/main.tf b/modules/aws-iam-role-policy-attachment/main.tf new file mode 100644 index 0000000..4ede3d1 --- /dev/null +++ b/modules/aws-iam-role-policy-attachment/main.tf @@ -0,0 +1,4 @@ +resource "aws_iam_role_policy_attachment" "this" { + role = var.role + policy_arn = var.policy_arn +} diff --git a/modules/aws-iam-role-policy-attachment/output.tf b/modules/aws-iam-role-policy-attachment/output.tf new file mode 100644 index 0000000..4a5603f --- /dev/null +++ b/modules/aws-iam-role-policy-attachment/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS IAM Role Policy Attachment" + value = aws_iam_role_policy_attachment.this +} diff --git a/modules/aws-iam-role-policy-attachment/variables.tf b/modules/aws-iam-role-policy-attachment/variables.tf new file mode 100644 index 0000000..3660e1d --- /dev/null +++ b/modules/aws-iam-role-policy-attachment/variables.tf @@ -0,0 +1,9 @@ +variable "role" { + description = "The IAM role to attach the policy to." + type = string +} + +variable "policy_arn" { + description = "The ARN of the IAM policy you want to apply." + type = string +} diff --git a/modules/aws-iam-role/README.md b/modules/aws-iam-role/README.md new file mode 100644 index 0000000..be8b754 --- /dev/null +++ b/modules/aws-iam-role/README.md @@ -0,0 +1,42 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_iam_role.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [assume\_role\_policy](#input\_assume\_role\_policy) | The policy that grants an entity permission to assume the role. | `string` | n/a | yes | +| [description](#input\_description) | The description of the IAM role. | `string` | `null` | no | +| [force\_detach\_policies](#input\_force\_detach\_policies) | Specifies whether to force detaching any policies the role has before destroying it. Defaults to false. | `bool` | `false` | no | +| [managed\_policy\_arns](#input\_managed\_policy\_arns) | Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Terraform will ignore policy attachments to this resource. When configured, Terraform will align the role's managed policy attachments with this set by attaching or detaching managed policies. | `list(string)` | `null` | no | +| [max\_session\_duration](#input\_max\_session\_duration) | The maximum session duration (in seconds) that you want to set for the specified role. If you do not specify a value for this setting, the default maximum of one hour is applied. This setting can have a value from 1 hour to 12 hours. | `number` | `3600` | no | +| [name](#input\_name) | Friendly name of the role. If omitted, Terraform will assign a random, unique name. Forces new resource. | `string` | n/a | yes | +| [name\_prefix](#input\_name\_prefix) | Creates a unique friendly name beginning with the specified prefix. Conflicts with 'name'. Forces new resources. | `string` | `null` | no | +| [path](#input\_path) | The path to the role. For more information about paths, see IAM Identifiers in the IAM User Guide. | `string` | `"/"` | no | +| [permissions\_boundary](#input\_permissions\_boundary) | The ARN of the policy that is used to set the permissions boundary for the role. | `string` | `null` | no | +| [tags](#input\_tags) | Key-value mapping of tags for the IAM role. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS IAM Role | + \ No newline at end of file diff --git a/modules/aws-iam-role/main.tf b/modules/aws-iam-role/main.tf new file mode 100644 index 0000000..f68d733 --- /dev/null +++ b/modules/aws-iam-role/main.tf @@ -0,0 +1,12 @@ +resource "aws_iam_role" "this" { + assume_role_policy = var.assume_role_policy + name = var.name + name_prefix = var.name_prefix + description = var.description + force_detach_policies = var.force_detach_policies + managed_policy_arns = var.managed_policy_arns + max_session_duration = var.max_session_duration + path = var.path + permissions_boundary = var.permissions_boundary + tags = var.tags +} diff --git a/modules/aws-iam-role/output.tf b/modules/aws-iam-role/output.tf new file mode 100644 index 0000000..17ef393 --- /dev/null +++ b/modules/aws-iam-role/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS IAM Role" + value = aws_iam_role.this +} diff --git a/modules/aws-iam-role/variables.tf b/modules/aws-iam-role/variables.tf new file mode 100644 index 0000000..ef6bd2a --- /dev/null +++ b/modules/aws-iam-role/variables.tf @@ -0,0 +1,57 @@ +variable "assume_role_policy" { + description = "The policy that grants an entity permission to assume the role." + type = string +} + +variable "name" { + description = "Friendly name of the role. If omitted, Terraform will assign a random, unique name. Forces new resource." + type = string +} + +variable "name_prefix" { + description = "Creates a unique friendly name beginning with the specified prefix. Conflicts with 'name'. Forces new resources." + type = string + default = null +} + +variable "description" { + description = "The description of the IAM role." + type = string + default = null +} + +variable "force_detach_policies" { + description = "Specifies whether to force detaching any policies the role has before destroying it. Defaults to false." + type = bool + default = false +} + +variable "managed_policy_arns" { + description = "Set of exclusive IAM managed policy ARNs to attach to the IAM role. If this attribute is not configured, Terraform will ignore policy attachments to this resource. When configured, Terraform will align the role's managed policy attachments with this set by attaching or detaching managed policies." + type = list(string) + default = null +} + +variable "max_session_duration" { + description = "The maximum session duration (in seconds) that you want to set for the specified role. If you do not specify a value for this setting, the default maximum of one hour is applied. This setting can have a value from 1 hour to 12 hours." + type = number + default = 3600 +} + +variable "path" { + description = "The path to the role. For more information about paths, see IAM Identifiers in the IAM User Guide." + type = string + default = "/" +} + +variable "permissions_boundary" { + description = "The ARN of the policy that is used to set the permissions boundary for the role." + type = string + default = null +} + +variable "tags" { + description = "Key-value mapping of tags for the IAM role." + type = map(string) + default = null +} diff --git a/modules/aws-neptune-cluster-parameter-group/README.md b/modules/aws-neptune-cluster-parameter-group/README.md new file mode 100644 index 0000000..24ccf72 --- /dev/null +++ b/modules/aws-neptune-cluster-parameter-group/README.md @@ -0,0 +1,37 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_neptune_cluster_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/neptune_cluster_parameter_group) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [description](#input\_description) | The description of the Neptune cluster parameter group. | `string` | `null` | no | +| [family](#input\_family) | The family of the Neptune cluster parameter group. | `string` | `null` | no | +| [name](#input\_name) | The name of the Neptune cluster parameter group. | `string` | n/a | yes | +| [parameters](#input\_parameters) | List of objects containing parameters for the Neptune cluster parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
| n/a | yes | +| [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | Neptune cluster parameter group | + \ No newline at end of file diff --git a/modules/aws-neptune-cluster-parameter-group/main.tf b/modules/aws-neptune-cluster-parameter-group/main.tf new file mode 100644 index 0000000..3572119 --- /dev/null +++ b/modules/aws-neptune-cluster-parameter-group/main.tf @@ -0,0 +1,16 @@ +resource "aws_neptune_cluster_parameter_group" "this" { + name = var.name + family = var.family + description = var.description + + dynamic "parameter" { + for_each = var.parameters + + content { + name = parameter.value.name + value = parameter.value.value + apply_method = parameter.value.apply_method != null ? parameter.value.apply_method : null + } + } +} + diff --git a/modules/aws-neptune-cluster-parameter-group/outputs.tf b/modules/aws-neptune-cluster-parameter-group/outputs.tf new file mode 100644 index 0000000..c75cf51 --- /dev/null +++ b/modules/aws-neptune-cluster-parameter-group/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "Neptune cluster parameter group" + value = aws_neptune_cluster_parameter_group.this +} \ No newline at end of file diff --git a/modules/aws-neptune-cluster-parameter-group/variables.tf b/modules/aws-neptune-cluster-parameter-group/variables.tf new file mode 100644 index 0000000..deb91e0 --- /dev/null +++ b/modules/aws-neptune-cluster-parameter-group/variables.tf @@ -0,0 +1,33 @@ +variable "description" { + description = "The description of the Neptune cluster parameter group." + type = string + default = null +} + +variable "family" { + description = "The family of the Neptune cluster parameter group." + type = string + default = null +} + +variable "name" { + description = "The name of the Neptune cluster parameter group." + type = string +} + +variable "parameters" { + description = "List of objects containing parameters for the Neptune cluster parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) +} + +variable "tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} \ No newline at end of file diff --git a/modules/aws-neptune-cluster/README.md b/modules/aws-neptune-cluster/README.md new file mode 100644 index 0000000..179cd09 --- /dev/null +++ b/modules/aws-neptune-cluster/README.md @@ -0,0 +1,45 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_neptune_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/neptune_cluster) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [apply\_immediately](#input\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `null` | no | +| [backup\_retention\_period](#input\_backup\_retention\_period) | The days to retain backups for. Default is 1 | `number` | `null` | no | +| [enable\_cloudwatch\_logs\_exports](#input\_enable\_cloudwatch\_logs\_exports) | A list of the log types this DB cluster is configured to export to Cloudwatch Logs. Currently only supports audit and slowquery | `list(string)` | `null` | no | +| [engine](#input\_engine) | The name of the database engine to be used for this Neptune cluster. | `string` | `null` | no | +| [engine\_version](#input\_engine\_version) | The database engine version. | `string` | `null` | no | +| [iam\_database\_authentication\_enabled](#input\_iam\_database\_authentication\_enabled) | Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | `bool` | `null` | no | +| [identifier](#input\_identifier) | The cluster identifier | `string` | `null` | no | +| [neptune\_subnet\_group\_name](#input\_neptune\_subnet\_group\_name) | A subnet group to associate with this neptune instance. | `string` | `null` | no | +| [parameter\_group\_name](#input\_parameter\_group\_name) | cluster parameter group to associate with the cluster | `string` | `null` | no | +| [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | Weekly time range during which system maintenance can occur, in (UTC). | `string` | `null` | no | +| [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | Determines whether a final Neptune snapshot is created before the Neptune cluster is deleted. If true is specified, no Neptune snapshot is created. If false is specified, a Neptune snapshot is created before the Neptune cluster is deleted, using the value from final\_snapshot\_identifier | `bool` | `null` | no | +| [storage\_type](#input\_storage\_type) | Storage type associated with the cluster standard/iopt1. Default: standard | `string` | `null` | no | +| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | List of VPC security groups to associate with the Cluster | `list(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Neptune cluster | + \ No newline at end of file diff --git a/modules/aws-neptune-cluster/main.tf b/modules/aws-neptune-cluster/main.tf new file mode 100644 index 0000000..5acb372 --- /dev/null +++ b/modules/aws-neptune-cluster/main.tf @@ -0,0 +1,15 @@ +resource "aws_neptune_cluster" "this" { + cluster_identifier = var.identifier + engine = var.engine + engine_version = var.engine_version + backup_retention_period = var.backup_retention_period + skip_final_snapshot = var.skip_final_snapshot + enable_cloudwatch_logs_exports = var.enable_cloudwatch_logs_exports + neptune_cluster_parameter_group_name = var.parameter_group_name + iam_database_authentication_enabled = var.iam_database_authentication_enabled + vpc_security_group_ids = var.vpc_security_group_ids + neptune_subnet_group_name = var.neptune_subnet_group_name + storage_type = var.storage_type + preferred_maintenance_window = var.preferred_maintenance_window + apply_immediately = var.apply_immediately +} \ No newline at end of file diff --git a/modules/aws-neptune-cluster/outputs.tf b/modules/aws-neptune-cluster/outputs.tf new file mode 100644 index 0000000..1ec3d8b --- /dev/null +++ b/modules/aws-neptune-cluster/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS Neptune cluster" + value = aws_neptune_cluster.this +} \ No newline at end of file diff --git a/modules/aws-neptune-cluster/variables.tf b/modules/aws-neptune-cluster/variables.tf new file mode 100644 index 0000000..e71e175 --- /dev/null +++ b/modules/aws-neptune-cluster/variables.tf @@ -0,0 +1,77 @@ +variable "identifier" { + description = "The cluster identifier" + type = string + default = null +} + +variable "engine" { + description = "The name of the database engine to be used for this Neptune cluster." + type = string + default = null +} + +variable "engine_version" { + description = "The database engine version." + type = string + default = null +} + +variable "backup_retention_period" { + description = "The days to retain backups for. Default is 1" + type = number + default = null +} + +variable "skip_final_snapshot" { + description = "Determines whether a final Neptune snapshot is created before the Neptune cluster is deleted. If true is specified, no Neptune snapshot is created. If false is specified, a Neptune snapshot is created before the Neptune cluster is deleted, using the value from final_snapshot_identifier" + type = bool + default = null +} + +variable "apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. " + type = bool + default = null +} + +variable "enable_cloudwatch_logs_exports" { + description = "A list of the log types this DB cluster is configured to export to Cloudwatch Logs. Currently only supports audit and slowquery" + type = list(string) + default = null +} + +variable "parameter_group_name" { + description = "cluster parameter group to associate with the cluster" + type = string + default = null +} + +variable "iam_database_authentication_enabled" { + description = " Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled." + type = bool + default = null +} + +variable "storage_type" { + description = "Storage type associated with the cluster standard/iopt1. Default: standard" + type = string + default = null +} + +variable "preferred_maintenance_window" { + description = "Weekly time range during which system maintenance can occur, in (UTC)." + type = string + default = null +} + +variable "vpc_security_group_ids" { + description = "List of VPC security groups to associate with the Cluster" + type = list(string) + default = null +} + +variable "neptune_subnet_group_name" { + description = "A subnet group to associate with this neptune instance." + type = string + default = null +} \ No newline at end of file diff --git a/modules/aws-neptune-instance/README.md b/modules/aws-neptune-instance/README.md new file mode 100644 index 0000000..89ba511 --- /dev/null +++ b/modules/aws-neptune-instance/README.md @@ -0,0 +1,41 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_neptune_cluster_instance.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/neptune_cluster_instance) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [apply\_immediately](#input\_apply\_immediately) | Specifies whether any instance modifications are applied immediately, or during the next maintenance window. | `bool` | `null` | no | +| [auto\_minor\_version\_upgrade](#input\_auto\_minor\_version\_upgrade) | Indicates that minor engine upgrades will be applied automatically to the instance during the maintenance window. Default is true | `bool` | `null` | no | +| [class](#input\_class) | The instance class to use. | `string` | `null` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | The identifier of the aws\_neptune\_cluster in which to launch this instance. | `string` | `null` | no | +| [identifier](#input\_identifier) | The identifier for the neptune instance. | `string` | n/a | yes | +| [neptune\_parameter\_group\_name](#input\_neptune\_parameter\_group\_name) | The name of the neptune parameter group to associate with this instance | `string` | `null` | no | +| [neptune\_subnet\_group\_name](#input\_neptune\_subnet\_group\_name) | A subnet group to associate with this neptune instance. NOTE: This must match the neptune\_subnet\_group\_name of the attached aws\_neptune\_cluster | `string` | `null` | no | +| [port](#input\_port) | The port on which the DB accepts connections. Defaults to 8182 | `number` | `null` | no | +| [publicly\_accessible](#input\_publicly\_accessible) | Bool to control if instance is publicly accessible. Default is false | `bool` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Neptune cluster instance | + \ No newline at end of file diff --git a/modules/aws-neptune-instance/main.tf b/modules/aws-neptune-instance/main.tf new file mode 100644 index 0000000..6496d89 --- /dev/null +++ b/modules/aws-neptune-instance/main.tf @@ -0,0 +1,11 @@ +resource "aws_neptune_cluster_instance" "this" { + cluster_identifier = var.cluster_identifier + identifier = var.identifier + instance_class = var.class + port = var.port + publicly_accessible = var.publicly_accessible + neptune_subnet_group_name = var.neptune_subnet_group_name + neptune_parameter_group_name = var.neptune_parameter_group_name + auto_minor_version_upgrade = var.auto_minor_version_upgrade + apply_immediately = var.apply_immediately +} \ No newline at end of file diff --git a/modules/aws-neptune-instance/outputs.tf b/modules/aws-neptune-instance/outputs.tf new file mode 100644 index 0000000..5dd1b59 --- /dev/null +++ b/modules/aws-neptune-instance/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS Neptune cluster instance" + value = aws_neptune_cluster_instance.this +} \ No newline at end of file diff --git a/modules/aws-neptune-instance/variables.tf b/modules/aws-neptune-instance/variables.tf new file mode 100644 index 0000000..dd09efc --- /dev/null +++ b/modules/aws-neptune-instance/variables.tf @@ -0,0 +1,52 @@ +variable "apply_immediately" { + description = "Specifies whether any instance modifications are applied immediately, or during the next maintenance window." + type = bool + default = null +} + +variable "auto_minor_version_upgrade" { + description = "Indicates that minor engine upgrades will be applied automatically to the instance during the maintenance window. Default is true" + type = bool + default = null +} + +variable "cluster_identifier" { + description = "The identifier of the aws_neptune_cluster in which to launch this instance." + type = string + default = null +} + +variable "identifier" { + description = "The identifier for the neptune instance." + type = string +} + +variable "class" { + description = "The instance class to use." + type = string + default = null +} + +variable "neptune_subnet_group_name" { + description = "A subnet group to associate with this neptune instance. NOTE: This must match the neptune_subnet_group_name of the attached aws_neptune_cluster" + type = string + default = null +} + +variable "neptune_parameter_group_name" { + description = "The name of the neptune parameter group to associate with this instance" + type = string + default = null +} + +variable "port" { + description = "The port on which the DB accepts connections. Defaults to 8182" + type = number + default = null +} + +variable "publicly_accessible" { + description = "Bool to control if instance is publicly accessible. Default is false" + type = bool + default = null +} diff --git a/modules/aws-rds-option-group/README.md b/modules/aws-rds-option-group/README.md new file mode 100644 index 0000000..85e0fe5 --- /dev/null +++ b/modules/aws-rds-option-group/README.md @@ -0,0 +1,38 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_db_option_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/db_option_group) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [description](#input\_description) | The description of the DB option group. | `string` | `null` | no | +| [engine\_name](#input\_engine\_name) | value | `any` | n/a | yes | +| [major\_engine\_version](#input\_major\_engine\_version) | value | `any` | n/a | yes | +| [name](#input\_name) | The name of the DB option group. | `string` | n/a | yes | +| [options](#input\_options) | List of objects containing options for the DB option group. |
list(
object({
option_name = string
option_settings = optional(
list(
object({
name = string
value = string
})
),
null
)
port = optional(string, null)
version = optional(string, null)
db_security_group_memberships = optional(list(string), null)
vpc_security_group_memberships = optional(list(string), null)
})
)
| n/a | yes | +| [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | rds option group | + \ No newline at end of file diff --git a/modules/aws-rds-option-group/main.tf b/modules/aws-rds-option-group/main.tf new file mode 100644 index 0000000..3962791 --- /dev/null +++ b/modules/aws-rds-option-group/main.tf @@ -0,0 +1,28 @@ +resource "aws_db_option_group" "this" { + name = var.name + option_group_description = var.description + engine_name = var.engine_name + major_engine_version = var.major_engine_version + tags = var.tags + + dynamic "option" { + for_each = var.options + + content { + option_name = option.value.option_name + port = option.value.port != null ? option.value.port : null + version = option.value.version != null ? option.value.version : null + db_security_group_memberships = option.value.db_security_group_memberships != null ? option.value.db_security_group_memberships : null + vpc_security_group_memberships = option.value.vpc_security_group_memberships != null ? option.value.vpc_security_group_memberships : null + + dynamic "option_settings" { + for_each = option.value.option_settings != null ? option.value.option_settings : [] + + content { + name = option_settings.value.name + value = option_settings.value.value + } + } + } + } +} diff --git a/modules/aws-rds-option-group/outputs.tf b/modules/aws-rds-option-group/outputs.tf new file mode 100644 index 0000000..24edf7c --- /dev/null +++ b/modules/aws-rds-option-group/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "rds option group" + value = aws_db_option_group.this +} diff --git a/modules/aws-rds-option-group/variables.tf b/modules/aws-rds-option-group/variables.tf new file mode 100644 index 0000000..be37bb7 --- /dev/null +++ b/modules/aws-rds-option-group/variables.tf @@ -0,0 +1,48 @@ +variable "description" { + description = "The description of the DB option group." + type = string + default = null +} + +variable "engine_name" { + description = "value" + type = any +} + +variable "major_engine_version" { + description = "value" + type = any +} + +variable "name" { + description = "The name of the DB option group." + type = string +} + +variable "options" { + description = "List of objects containing options for the DB option group." + type = list( + object({ + option_name = string + option_settings = optional( + list( + object({ + name = string + value = string + }) + ), + null + ) + port = optional(string, null) + version = optional(string, null) + db_security_group_memberships = optional(list(string), null) + vpc_security_group_memberships = optional(list(string), null) + }) + ) +} + +variable "tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} diff --git a/modules/aws-redshift-cluster/README.md b/modules/aws-redshift-cluster/README.md new file mode 100644 index 0000000..c3d8909 --- /dev/null +++ b/modules/aws-redshift-cluster/README.md @@ -0,0 +1,55 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_redshift_cluster.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/redshift_cluster) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [apply\_immediately](#input\_apply\_immediately) | A boolean that indicates whether major version upgrades are applied immediately, regardless of the maintenance window. | `bool` | `true` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | Identifier of the Redshift cluster. Must be a lower case string. | `string` | n/a | yes | +| [cluster\_parameter\_group\_name](#input\_cluster\_parameter\_group\_name) | The name of the parameter group to be associated with this cluster. | `string` | `null` | no | +| [cluster\_subnet\_group\_name](#input\_cluster\_subnet\_group\_name) | The name of a cluster subnet group to be associated with this cluster. | `string` | `null` | no | +| [cluster\_type](#input\_cluster\_type) | The type of the cluster. Valid values: single-node \| multi-node. | `string` | `"single-node"` | no | +| [cluster\_version](#input\_cluster\_version) | The version of the Amazon Redshift engine software that you want to deploy on the cluster. | `string` | `"1.0"` | no | +| [database\_name](#input\_database\_name) | The name of the first database to be created when the cluster is created. | `string` | `"dev"` | no | +| [default\_iam\_role\_arn](#input\_default\_iam\_role\_arn) | The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created. | `string` | `null` | no | +| [elastic\_ip](#input\_elastic\_ip) | The Elastic IP (EIP) address for the cluster. | `string` | `null` | no | +| [final\_snapshot\_identifier](#input\_final\_snapshot\_identifier) | The identifier of the final snapshot that is to be created immediately before deleting the cluster. | `string` | `null` | no | +| [iam\_roles](#input\_iam\_roles) | A list of IAM roles to associate with the cluster. A maximum of 10 IAM roles can be associated to the cluster at any time. | `list(string)` | `null` | no | +| [master\_password](#input\_master\_password) | The password for the master database user. Must contain at least 8 characters and contain at least one uppercase letter, one lowercase letter, and one number. | `string` | n/a | yes | +| [master\_username](#input\_master\_username) | The username for the master database user. | `string` | `"admin"` | no | +| [node\_type](#input\_node\_type) | The node type to be provisioned for the cluster. | `string` | `"dc2.large"` | no | +| [number\_of\_nodes](#input\_number\_of\_nodes) | The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node. | `number` | `1` | no | +| [port](#input\_port) | The port number on which the cluster accepts incoming connections. Valid values are between 1115 and 65535 | `number` | `5439` | no | +| [preferred\_maintenance\_window](#input\_preferred\_maintenance\_window) | The weekly time range (in UTC) during which automated cluster maintenance can occur. | `string` | `null` | no | +| [publicly\_accessible](#input\_publicly\_accessible) | A boolean that indicates if the cluster is publicly accessible. If the value is true, the cluster can be accessed from a public network. | `bool` | `true` | no | +| [skip\_final\_snapshot](#input\_skip\_final\_snapshot) | A boolean that indicates whether a final snapshot is created before the cluster is deleted. | `bool` | `true` | no | +| [snapshot\_cluster\_identifier](#input\_snapshot\_cluster\_identifier) | The name of the cluster the source snapshot was created from. | `string` | `null` | no | +| [snapshot\_identifier](#input\_snapshot\_identifier) | The name of the snapshot from which to create the new cluster | `string` | `null` | no | +| [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | +| [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | A list of security group identifiers to associate with this cluster. | `list(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Redshift Cluster | + \ No newline at end of file diff --git a/modules/aws-redshift-cluster/main.tf b/modules/aws-redshift-cluster/main.tf new file mode 100644 index 0000000..110239a --- /dev/null +++ b/modules/aws-redshift-cluster/main.tf @@ -0,0 +1,25 @@ +resource "aws_redshift_cluster" "this" { + apply_immediately = var.apply_immediately + cluster_identifier = var.cluster_identifier + cluster_parameter_group_name = var.cluster_parameter_group_name + cluster_subnet_group_name = var.cluster_subnet_group_name + cluster_type = var.cluster_type + cluster_version = var.cluster_version + database_name = var.database_name + default_iam_role_arn = var.default_iam_role_arn + elastic_ip = var.elastic_ip + final_snapshot_identifier = var.final_snapshot_identifier + iam_roles = var.iam_roles + master_password = var.master_password + master_username = var.master_username + node_type = var.node_type + number_of_nodes = var.number_of_nodes + port = var.port + preferred_maintenance_window = var.preferred_maintenance_window + publicly_accessible = var.publicly_accessible + skip_final_snapshot = var.skip_final_snapshot + snapshot_cluster_identifier = var.snapshot_cluster_identifier + snapshot_identifier = var.snapshot_identifier + tags = var.tags + vpc_security_group_ids = var.vpc_security_group_ids +} diff --git a/modules/aws-redshift-cluster/output.tf b/modules/aws-redshift-cluster/output.tf new file mode 100644 index 0000000..349ffd1 --- /dev/null +++ b/modules/aws-redshift-cluster/output.tf @@ -0,0 +1,5 @@ +output "this" { + description = "AWS Redshift Cluster" + value = aws_redshift_cluster.this + sensitive = true +} diff --git a/modules/aws-redshift-cluster/variables.tf b/modules/aws-redshift-cluster/variables.tf new file mode 100644 index 0000000..8ebe24b --- /dev/null +++ b/modules/aws-redshift-cluster/variables.tf @@ -0,0 +1,135 @@ +variable "cluster_identifier" { + description = "Identifier of the Redshift cluster. Must be a lower case string." + type = string +} + +variable "database_name" { + description = "The name of the first database to be created when the cluster is created." + type = string + default = "dev" +} + +variable "default_iam_role_arn" { + description = "The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created." + type = string + default = null +} + +variable "node_type" { + description = "The node type to be provisioned for the cluster." + type = string + default = "dc2.large" +} + +variable "cluster_type" { + description = "The type of the cluster. Valid values: single-node | multi-node." + type = string + default = "single-node" +} + +variable "master_password" { + description = "The password for the master database user. Must contain at least 8 characters and contain at least one uppercase letter, one lowercase letter, and one number." + type = string +} + +variable "master_username" { + description = "The username for the master database user." + type = string + default = "admin" +} + +variable "vpc_security_group_ids" { + description = "A list of security group identifiers to associate with this cluster." + type = list(string) + default = null +} + +variable "cluster_subnet_group_name" { + description = "The name of a cluster subnet group to be associated with this cluster." + type = string + default = null +} + +variable "preferred_maintenance_window" { + description = "The weekly time range (in UTC) during which automated cluster maintenance can occur." + type = string + default = null +} + +variable "cluster_parameter_group_name" { + description = "The name of the parameter group to be associated with this cluster." + type = string + default = null +} + +variable "port" { + description = "The port number on which the cluster accepts incoming connections. Valid values are between 1115 and 65535" + type = number + default = 5439 +} + +variable "cluster_version" { + description = "The version of the Amazon Redshift engine software that you want to deploy on the cluster." + type = string + default = "1.0" +} + +variable "apply_immediately" { + description = "A boolean that indicates whether major version upgrades are applied immediately, regardless of the maintenance window." + type = bool + default = true +} + +variable "number_of_nodes" { + description = "The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node." + type = number + default = 1 +} + +variable "publicly_accessible" { + description = "A boolean that indicates if the cluster is publicly accessible. If the value is true, the cluster can be accessed from a public network." + type = bool + default = true +} + +variable "elastic_ip" { + description = "The Elastic IP (EIP) address for the cluster." + type = string + default = null +} + +variable "skip_final_snapshot" { + description = "A boolean that indicates whether a final snapshot is created before the cluster is deleted." + type = bool + default = true +} + +variable "final_snapshot_identifier" { + description = "The identifier of the final snapshot that is to be created immediately before deleting the cluster." + type = string + default = null +} + +variable "snapshot_identifier" { + description = "The name of the snapshot from which to create the new cluster" + type = string + default = null +} + +variable "snapshot_cluster_identifier" { + description = "The name of the cluster the source snapshot was created from." + type = string + default = null +} + +variable "iam_roles" { + description = "A list of IAM roles to associate with the cluster. A maximum of 10 IAM roles can be associated to the cluster at any time." + type = list(string) + default = null +} + +variable "tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} diff --git a/modules/aws-redshift-logging/README.md b/modules/aws-redshift-logging/README.md new file mode 100644 index 0000000..24c1d13 --- /dev/null +++ b/modules/aws-redshift-logging/README.md @@ -0,0 +1,36 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_redshift_logging.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/redshift_logging) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [bucket\_name](#input\_bucket\_name) | The name of an existing S3 bucket where the log files are to be stored. Must be in the same region as the cluster and the cluster must have read bucket and put object permissions. | `string` | n/a | yes | +| [cluster\_identifier](#input\_cluster\_identifier) | Identifier of the source cluster. | `string` | n/a | yes | +| [log\_destination\_type](#input\_log\_destination\_type) | The log destination type. DSFHUB only supports s3 or null (audit via ODBC tables). Default is s3. | `string` | `"s3"` | no | +| [s3\_key\_prefix](#input\_s3\_key\_prefix) | The prefix applied to the log file names. Must be 'redshift' for DSFHUB. | `string` | `"redshift"` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Redshift Logging configuration | + \ No newline at end of file diff --git a/modules/aws-redshift-logging/main.tf b/modules/aws-redshift-logging/main.tf new file mode 100644 index 0000000..173e498 --- /dev/null +++ b/modules/aws-redshift-logging/main.tf @@ -0,0 +1,7 @@ +resource "aws_redshift_logging" "this" { + cluster_identifier = var.cluster_identifier + log_destination_type = var.log_destination_type + + bucket_name = var.log_destination_type == "s3" ? var.bucket_name : null + s3_key_prefix = var.log_destination_type == "s3" ? var.s3_key_prefix : null +} diff --git a/modules/aws-redshift-logging/output.tf b/modules/aws-redshift-logging/output.tf new file mode 100644 index 0000000..276e5d8 --- /dev/null +++ b/modules/aws-redshift-logging/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS Redshift Logging configuration" + value = aws_redshift_logging.this +} diff --git a/modules/aws-redshift-logging/variables.tf b/modules/aws-redshift-logging/variables.tf new file mode 100644 index 0000000..ed40ccd --- /dev/null +++ b/modules/aws-redshift-logging/variables.tf @@ -0,0 +1,20 @@ +variable "cluster_identifier" { + description = "Identifier of the source cluster." + type = string +} + +variable "log_destination_type" { + description = "The log destination type. DSFHUB only supports s3 or null (audit via ODBC tables). Default is s3." + type = string + default = "s3" +} +variable "bucket_name" { + description = "The name of an existing S3 bucket where the log files are to be stored. Must be in the same region as the cluster and the cluster must have read bucket and put object permissions." + type = string +} + +variable "s3_key_prefix" { + description = "The prefix applied to the log file names. Must be 'redshift' for DSFHUB." + type = string + default = "redshift" +} diff --git a/modules/aws-redshift-parameter-group/README.md b/modules/aws-redshift-parameter-group/README.md new file mode 100644 index 0000000..9ba3774 --- /dev/null +++ b/modules/aws-redshift-parameter-group/README.md @@ -0,0 +1,37 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_redshift_parameter_group.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/redshift_parameter_group) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [description](#input\_description) | The description of the Redshift parameter group. | `string` | `null` | no | +| [family](#input\_family) | The family of the Redshift parameter group. | `string` | `"redshift-1.0"` | no | +| [name](#input\_name) | The name of the Redshift parameter group. | `string` | n/a | yes | +| [parameters](#input\_parameters) | A list of Redshift parameters to apply. |
list(
object({
name = string
value = any
})
)
|
[
{
"name": "enable_user_activity_logging",
"value": "true"
}
]
| no | +| [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Redshift parameter group | + \ No newline at end of file diff --git a/modules/aws-redshift-parameter-group/main.tf b/modules/aws-redshift-parameter-group/main.tf new file mode 100644 index 0000000..68af420 --- /dev/null +++ b/modules/aws-redshift-parameter-group/main.tf @@ -0,0 +1,15 @@ +resource "aws_redshift_parameter_group" "this" { + name = var.name + family = var.family + description = var.description + tags = var.tags + + dynamic "parameter" { + for_each = var.parameters + + content { + name = parameter.value.name + value = parameter.value.value + } + } +} diff --git a/modules/aws-redshift-parameter-group/output.tf b/modules/aws-redshift-parameter-group/output.tf new file mode 100644 index 0000000..d1e874c --- /dev/null +++ b/modules/aws-redshift-parameter-group/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS Redshift parameter group" + value = aws_redshift_parameter_group.this +} diff --git a/modules/aws-redshift-parameter-group/variables.tf b/modules/aws-redshift-parameter-group/variables.tf new file mode 100644 index 0000000..58ece92 --- /dev/null +++ b/modules/aws-redshift-parameter-group/variables.tf @@ -0,0 +1,36 @@ +variable "description" { + description = "The description of the Redshift parameter group." + type = string + default = null +} + +variable "family" { + description = "The family of the Redshift parameter group." + type = string + default = "redshift-1.0" +} + +variable "name" { + description = "The name of the Redshift parameter group." + type = string +} + +variable "parameters" { + description = "A list of Redshift parameters to apply." + type = list( + object({ + name = string + value = any + }) + ) + default = [{ + name = "enable_user_activity_logging" + value = "true" + }] +} + +variable "tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} diff --git a/modules/aws-s3-bucket-policy/README.md b/modules/aws-s3-bucket-policy/README.md new file mode 100644 index 0000000..2c55317 --- /dev/null +++ b/modules/aws-s3-bucket-policy/README.md @@ -0,0 +1,34 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_s3_bucket_policy.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket_policy) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [bucket](#input\_bucket) | Name of the bucket to which to apply the policy. | `string` | n/a | yes | +| [policy](#input\_policy) | Text of the policy. Although this is a bucket policy rather than an IAM policy, the aws\_iam\_policy\_document data source may be used, so long as it specifies a principal. | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS S3 bucket policy | + \ No newline at end of file diff --git a/modules/aws-s3-bucket-policy/main.tf b/modules/aws-s3-bucket-policy/main.tf new file mode 100644 index 0000000..e18cda1 --- /dev/null +++ b/modules/aws-s3-bucket-policy/main.tf @@ -0,0 +1,4 @@ +resource "aws_s3_bucket_policy" "this" { + bucket = var.bucket + policy = var.policy +} diff --git a/modules/aws-s3-bucket-policy/output.tf b/modules/aws-s3-bucket-policy/output.tf new file mode 100644 index 0000000..d123a5e --- /dev/null +++ b/modules/aws-s3-bucket-policy/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS S3 bucket policy" + value = aws_s3_bucket_policy.this +} diff --git a/modules/aws-s3-bucket-policy/variables.tf b/modules/aws-s3-bucket-policy/variables.tf new file mode 100644 index 0000000..d95222c --- /dev/null +++ b/modules/aws-s3-bucket-policy/variables.tf @@ -0,0 +1,9 @@ +variable "bucket" { + description = "Name of the bucket to which to apply the policy." + type = string +} + +variable "policy" { + description = "Text of the policy. Although this is a bucket policy rather than an IAM policy, the aws_iam_policy_document data source may be used, so long as it specifies a principal." + type = string +} diff --git a/modules/aws-s3-bucket/README.md b/modules/aws-s3-bucket/README.md new file mode 100644 index 0000000..754d3bb --- /dev/null +++ b/modules/aws-s3-bucket/README.md @@ -0,0 +1,37 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [aws_s3_bucket.this](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [bucket](#input\_bucket) | The name of the bucket. Must be lowercase and less than or equal to 63 characters in length. | `string` | n/a | yes | +| [bucket\_prefix](#input\_bucket\_prefix) | Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. Must be lowercase and less than or equal to 37 characters in length. | `string` | `null` | no | +| [force\_destroy](#input\_force\_destroy) | A boolean that indicates all objects should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. See more details in the [aws terraform documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#force_destroy). | `bool` | `false` | no | +| [object\_lock\_enabled](#input\_object\_lock\_enabled) | A boolean that indicates whether this bucket should have an Object Lock configuration enabled. | `bool` | `false` | no | +| [tags](#input\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS S3 bucket | + \ No newline at end of file diff --git a/modules/aws-s3-bucket/main.tf b/modules/aws-s3-bucket/main.tf new file mode 100644 index 0000000..f18f240 --- /dev/null +++ b/modules/aws-s3-bucket/main.tf @@ -0,0 +1,7 @@ +resource "aws_s3_bucket" "this" { + bucket = var.bucket + bucket_prefix = var.bucket_prefix + force_destroy = var.force_destroy + object_lock_enabled = var.object_lock_enabled + tags = var.tags +} diff --git a/modules/aws-s3-bucket/output.tf b/modules/aws-s3-bucket/output.tf new file mode 100644 index 0000000..b50e910 --- /dev/null +++ b/modules/aws-s3-bucket/output.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS S3 bucket" + value = aws_s3_bucket.this +} diff --git a/modules/aws-s3-bucket/variables.tf b/modules/aws-s3-bucket/variables.tf new file mode 100644 index 0000000..e22c2f9 --- /dev/null +++ b/modules/aws-s3-bucket/variables.tf @@ -0,0 +1,27 @@ +variable "bucket" { + description = "The name of the bucket. Must be lowercase and less than or equal to 63 characters in length." + type = string +} + +variable "bucket_prefix" { + description = "Creates a unique bucket name beginning with the specified prefix. Conflicts with bucket. Must be lowercase and less than or equal to 37 characters in length." + type = string + default = null +} + +variable "force_destroy" { + description = "A boolean that indicates all objects should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. See more details in the [aws terraform documentation](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#force_destroy)." + type = bool + default = false +} + +variable "object_lock_enabled" { + description = "A boolean that indicates whether this bucket should have an Object Lock configuration enabled." + type = bool + default = false +} +variable "tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} diff --git a/modules/dsfhub-aws-docdb-cluster/README.md b/modules/dsfhub-aws-docdb-cluster/README.md new file mode 100644 index 0000000..c0dafc8 --- /dev/null +++ b/modules/dsfhub-aws-docdb-cluster/README.md @@ -0,0 +1,42 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about the assets. | `string` | `"test@example.com"` | no | +| [asset\_display\_name](#input\_asset\_display\_name) | The display name of the asset. | `string` | `"AWS DocumentDB Cluster"` | no | +| [asset\_id](#input\_asset\_id) | The unique identifier of the asset, typically its arn. | `string` | n/a | yes | +| [cluster\_identifier](#input\_cluster\_identifier) | Identifier of AWS DocumentDB Cluster. | `string` | n/a | yes | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | DSFHUB Cloud Account Asset ID | `string` | n/a | yes | +| [region](#input\_region) | AWS region of the AWS DocumentDB Cluster. | `string` | n/a | yes | +| [server\_host\_name](#input\_server\_host\_name) | The endpoint of the AWS DocumentDB Cluster. | `string` | n/a | yes | +| [server\_ip](#input\_server\_ip) | The IP address of the AWS DocumentDB Cluster. | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | The port on which the DB accepts connections. | `number` | `27017` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS DocumentDB Cluster asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-docdb-cluster/main.tf b/modules/dsfhub-aws-docdb-cluster/main.tf new file mode 100644 index 0000000..82fba3d --- /dev/null +++ b/modules/dsfhub-aws-docdb-cluster/main.tf @@ -0,0 +1,22 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS DOCUMENTDB CLUSTER" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + audit_type = "LOG_GROUP" + gateway_id = var.gateway_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + server_ip = var.server_ip + server_port = var.server_port +} diff --git a/modules/dsfhub-aws-docdb-cluster/outputs.tf b/modules/dsfhub-aws-docdb-cluster/outputs.tf new file mode 100644 index 0000000..a598990 --- /dev/null +++ b/modules/dsfhub-aws-docdb-cluster/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS DocumentDB Cluster asset" + value = dsfhub_data_source.this +} diff --git a/modules/dsfhub-aws-docdb-cluster/variables.tf b/modules/dsfhub-aws-docdb-cluster/variables.tf new file mode 100644 index 0000000..82e1264 --- /dev/null +++ b/modules/dsfhub-aws-docdb-cluster/variables.tf @@ -0,0 +1,53 @@ +# DSFHUB asset variables +variable "admin_email" { + description = "The email address to notify about the assets." + type = string + default = "test@example.com" +} + +variable "asset_display_name" { + description = "The display name of the asset." + type = string + default = "AWS DocumentDB Cluster" +} + +variable "asset_id" { + description = "The unique identifier of the asset, typically its arn." + type = string +} + +variable "cluster_identifier" { + description = "Identifier of AWS DocumentDB Cluster." + type = string +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "DSFHUB Cloud Account Asset ID" + type = string +} + +variable "region" { + description = "AWS region of the AWS DocumentDB Cluster." + type = string +} + +variable "server_host_name" { + description = "The endpoint of the AWS DocumentDB Cluster." + type = string +} + +variable "server_ip" { + description = "The IP address of the AWS DocumentDB Cluster." + type = string +} + +variable "server_port" { + description = "The port on which the DB accepts connections." + type = number + default = 27017 +} diff --git a/modules/dsfhub-aws-neptune-cluster/README.md b/modules/dsfhub-aws-neptune-cluster/README.md new file mode 100644 index 0000000..c873da9 --- /dev/null +++ b/modules/dsfhub-aws-neptune-cluster/README.md @@ -0,0 +1,41 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:rds:us-east-2:123456790:cluster:cluster-name" | `string` | n/a | yes | +| [audit\_type](#input\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `null` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [region](#input\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [server\_host\_name](#input\_server\_host\_name) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Database port being used. | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Neptune cluster asset. | + \ No newline at end of file diff --git a/modules/dsfhub-aws-neptune-cluster/main.tf b/modules/dsfhub-aws-neptune-cluster/main.tf new file mode 100644 index 0000000..c0e212f --- /dev/null +++ b/modules/dsfhub-aws-neptune-cluster/main.tf @@ -0,0 +1,26 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS NEPTUNE CLUSTER" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + gateway_id = var.gateway_id + server_host_name = var.server_host_name + server_port = var.server_port + region = var.region + audit_type = var.audit_type + parent_asset_id = var.parent_asset_id + + asset_connection { + auth_mechanism = "ec2" + reason = "default" + } +} \ No newline at end of file diff --git a/modules/dsfhub-aws-neptune-cluster/outputs.tf b/modules/dsfhub-aws-neptune-cluster/outputs.tf new file mode 100644 index 0000000..7f3d10a --- /dev/null +++ b/modules/dsfhub-aws-neptune-cluster/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS Neptune cluster asset." + value = dsfhub_data_source.this +} \ No newline at end of file diff --git a/modules/dsfhub-aws-neptune-cluster/variables.tf b/modules/dsfhub-aws-neptune-cluster/variables.tf new file mode 100644 index 0000000..dd10505 --- /dev/null +++ b/modules/dsfhub-aws-neptune-cluster/variables.tf @@ -0,0 +1,45 @@ +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:rds:us-east-2:123456790:cluster:cluster-name\"" + type = string +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "region" { + description = "AWS region containing the instance." + type = string +} + +variable "server_host_name" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "server_port" { + description = "Database port being used." + type = string +} + +variable "audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = null +} diff --git a/modules/dsfhub-aws-rds-mariadb/README.md b/modules/dsfhub-aws-rds-mariadb/README.md new file mode 100644 index 0000000..cace31a --- /dev/null +++ b/modules/dsfhub-aws-rds-mariadb/README.md @@ -0,0 +1,41 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:rds:us-east-2:123456790:db:db-name" | `string` | n/a | yes | +| [database\_name](#input\_database\_name) | Specifies the name of the database you are connected to (or default DB). | `string` | `null` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [region](#input\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [server\_host\_name](#input\_server\_host\_name) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS RDS MariaDB asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-rds-mariadb/main.tf b/modules/dsfhub-aws-rds-mariadb/main.tf new file mode 100644 index 0000000..7fea5e8 --- /dev/null +++ b/modules/dsfhub-aws-rds-mariadb/main.tf @@ -0,0 +1,21 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS RDS MARIADB" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + database_name = var.database_name + gateway_id = var.gateway_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + server_port = var.server_port +} diff --git a/modules/dsfhub-aws-rds-mariadb/outputs.tf b/modules/dsfhub-aws-rds-mariadb/outputs.tf new file mode 100644 index 0000000..b8f1f03 --- /dev/null +++ b/modules/dsfhub-aws-rds-mariadb/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS RDS MariaDB asset" + value = dsfhub_data_source.this +} \ No newline at end of file diff --git a/modules/dsfhub-aws-rds-mariadb/variables.tf b/modules/dsfhub-aws-rds-mariadb/variables.tf new file mode 100644 index 0000000..752753d --- /dev/null +++ b/modules/dsfhub-aws-rds-mariadb/variables.tf @@ -0,0 +1,45 @@ +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:rds:us-east-2:123456790:db:db-name\"" + type = string +} + +variable "database_name" { + description = "Specifies the name of the database you are connected to (or default DB)." + type = string + default = null +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +variable "region" { + description = "AWS region containing the instance." + type = string +} + +variable "server_host_name" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "server_port" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} diff --git a/modules/dsfhub-aws-rds-mysql/README.md b/modules/dsfhub-aws-rds-mysql/README.md new file mode 100644 index 0000000..9221e77 --- /dev/null +++ b/modules/dsfhub-aws-rds-mysql/README.md @@ -0,0 +1,42 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:rds:us-east-2:123456790:db:db-name" | `string` | n/a | yes | +| [audit\_type](#input\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `null` | no | +| [database\_name](#input\_database\_name) | Specifies the name of the database you are connected to (or default DB). | `string` | `null` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [region](#input\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [server\_host\_name](#input\_server\_host\_name) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | aws rds mysql asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-rds-mysql/main.tf b/modules/dsfhub-aws-rds-mysql/main.tf new file mode 100644 index 0000000..c14f447 --- /dev/null +++ b/modules/dsfhub-aws-rds-mysql/main.tf @@ -0,0 +1,22 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS RDS MYSQL" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + audit_type = var.audit_type + database_name = var.database_name + gateway_id = var.gateway_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + server_port = var.server_port +} diff --git a/modules/dsfhub-aws-rds-mysql/outputs.tf b/modules/dsfhub-aws-rds-mysql/outputs.tf new file mode 100644 index 0000000..eb4111e --- /dev/null +++ b/modules/dsfhub-aws-rds-mysql/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "aws rds mysql asset" + value = dsfhub_data_source.this +} \ No newline at end of file diff --git a/modules/dsfhub-aws-rds-mysql/variables.tf b/modules/dsfhub-aws-rds-mysql/variables.tf new file mode 100644 index 0000000..b0fa617 --- /dev/null +++ b/modules/dsfhub-aws-rds-mysql/variables.tf @@ -0,0 +1,51 @@ +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:rds:us-east-2:123456790:db:db-name\"" + type = string +} + +variable "audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = null +} + +variable "database_name" { + description = "Specifies the name of the database you are connected to (or default DB)." + type = string + default = null +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +variable "region" { + description = "AWS region containing the instance." + type = string +} + +variable "server_host_name" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "server_port" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} diff --git a/modules/dsfhub-aws-rds-oracle/README.md b/modules/dsfhub-aws-rds-oracle/README.md new file mode 100644 index 0000000..7b4d7bc --- /dev/null +++ b/modules/dsfhub-aws-rds-oracle/README.md @@ -0,0 +1,49 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:rds:us-east-2:123456790:db:db-name" | `string` | n/a | yes | +| [audit\_pull\_enabled](#input\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [audit\_type](#input\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `null` | no | +| [auth\_mechanism](#input\_auth\_mechanism) | Specifies the auth mechanism used by the connection | `string` | `null` | no | +| [dsn](#input\_dsn) | Datasource name to use in odbc.ini. If using the asset for SDM, keep a dummy DSN value. | `string` | `null` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | `null` | no | +| [password](#input\_password) | Password to use to connect to Oracle database. Must not include semicolons. | `string` | `null` | no | +| [reason](#input\_reason) | Used to differentiate connections that belong to the same asset | `string` | `"default"` | no | +| [region](#input\_region) | AWS region containing the instance. | `string` | `null` | no | +| [server\_host\_name](#input\_server\_host\_name) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [service\_name](#input\_service\_name) | Oracle service name, or SID. e.g. ORCL | `string` | n/a | yes | +| [username](#input\_username) | Username to use to connect to Oracle database. | `string` | `null` | no | +| [wallet\_dir](#input\_wallet\_dir) | Path to the Oracle wallet directory | `string` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS RDS Oracle asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-rds-oracle/main.tf b/modules/dsfhub-aws-rds-oracle/main.tf new file mode 100644 index 0000000..192bdf4 --- /dev/null +++ b/modules/dsfhub-aws-rds-oracle/main.tf @@ -0,0 +1,37 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS RDS ORACLE" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + audit_pull_enabled = var.audit_pull_enabled + audit_type = var.audit_type + gateway_id = var.gateway_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + service_name = var.service_name + server_port = var.server_port + + dynamic "asset_connection" { + # If auth_mechanism is not defined, do not create a connection + for_each = var.auth_mechanism != null ? [0] : [] + + content { + auth_mechanism = var.auth_mechanism + dsn = var.auth_mechanism == "oracle_wallet" ? var.dsn : null + password = var.password + reason = var.reason + username = var.username + wallet_dir = var.auth_mechanism == "oracle_wallet" ? var.wallet_dir : null + } + } +} diff --git a/modules/dsfhub-aws-rds-oracle/outputs.tf b/modules/dsfhub-aws-rds-oracle/outputs.tf new file mode 100644 index 0000000..10e1956 --- /dev/null +++ b/modules/dsfhub-aws-rds-oracle/outputs.tf @@ -0,0 +1,4 @@ +output "this" { + description = "AWS RDS Oracle asset" + value = dsfhub_data_source.this +} diff --git a/modules/dsfhub-aws-rds-oracle/variables.tf b/modules/dsfhub-aws-rds-oracle/variables.tf new file mode 100644 index 0000000..7d23383 --- /dev/null +++ b/modules/dsfhub-aws-rds-oracle/variables.tf @@ -0,0 +1,94 @@ +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:rds:us-east-2:123456790:db:db-name\"" + type = string +} + +variable "audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = null +} + +variable "auth_mechanism" { + description = "Specifies the auth mechanism used by the connection" + type = string + default = null +} + +variable "dsn" { + description = "Datasource name to use in odbc.ini. If using the asset for SDM, keep a dummy DSN value." + type = string + default = null +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string + default = null +} + +variable "password" { + description = "Password to use to connect to Oracle database. Must not include semicolons." + type = string + default = null +} + +variable "reason" { + description = "Used to differentiate connections that belong to the same asset" + type = string + default = "default" +} + +variable "region" { + description = "AWS region containing the instance." + type = string + default = null +} + +variable "server_host_name" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "server_port" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "service_name" { + description = "Oracle service name, or SID. e.g. ORCL" + type = string +} + +variable "username" { + description = "Username to use to connect to Oracle database." + type = string + default = null +} + +variable "wallet_dir" { + description = "Path to the Oracle wallet directory" + type = string + default = null +} diff --git a/modules/dsfhub-aws-redshift-cluster/README.md b/modules/dsfhub-aws-redshift-cluster/README.md new file mode 100644 index 0000000..4c13e64 --- /dev/null +++ b/modules/dsfhub-aws-redshift-cluster/README.md @@ -0,0 +1,56 @@ + +## Requirements + +| Name | Version | +|------|---------| +| [dsfhub](#requirement\_dsfhub) | >= 1.2.46 | + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | >= 1.2.46 | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [access\_id](#input\_access\_id) | The cluster identifier. | `string` | `null` | no | +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:rds:us-east-2:123456790:cluster:cluster-name" | `string` | n/a | yes | +| [audit\_pull\_enabled](#input\_audit\_pull\_enabled) | Whether the DSFHUB should pull logs from the asset. | `bool` | `false` | no | +| [audit\_type](#input\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details. Valid values: TABLE \| REDSHIFT. | `string` | `null` | no | +| [auth\_mechanism](#input\_auth\_mechanism) | The authentication mechanism to use for the Redshift asset. | `string` | `null` | no | +| [aws\_connection\_id](#input\_aws\_connection\_id) | The stringified object ID of the AWS connection document. | `string` | `null` | no | +| [bucket\_account\_id](#input\_bucket\_account\_id) | The account\_id of the bucket owner | `string` | `null` | no | +| [database\_name](#input\_database\_name) | The database name. | `string` | `"dev"` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [logs\_destination\_asset\_id](#input\_logs\_destination\_asset\_id) | The asset\_id of the AWS S3 bucket asset when the audit\_type is set to REDSHIFT. | `string` | `null` | no | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [password](#input\_password) | The password to use for authentication. | `string` | `null` | no | +| [region](#input\_region) | AWS region containing the Redshift cluster. | `string` | n/a | yes | +| [server\_host\_name](#input\_server\_host\_name) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [server\_ip](#input\_server\_ip) | Endpoint URL, e.g. .amazon.com | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Database port being used. Default: 5439 | `number` | `5439` | no | +| [service\_name](#input\_service\_name) | The database name (see Service Name Guidelines). | `string` | `null` | no | +| [ssl](#input\_ssl) | Whether to use SSL for the connection. | `bool` | `null` | no | +| [tmp\_user](#input\_tmp\_user) | Whether the DSFHUB should create a temp user. | `bool` | `null` | no | +| [username](#input\_username) | The username to use for authentication. | `string` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS Redshift cluster asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-redshift-cluster/main.tf b/modules/dsfhub-aws-redshift-cluster/main.tf new file mode 100644 index 0000000..95190de --- /dev/null +++ b/modules/dsfhub-aws-redshift-cluster/main.tf @@ -0,0 +1,47 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + version = ">= 1.2.46" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS REDSHIFT" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + audit_pull_enabled = var.audit_pull_enabled + audit_type = var.audit_type + bucket_account_id = var.bucket_account_id + database_name = var.database_name + gateway_id = var.gateway_id + logs_destination_asset_id = var.logs_destination_asset_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + server_ip = var.server_ip + server_port = var.server_port + service_name = var.service_name + + dynamic "asset_connection" { + # If auth_mechanism is not defined, do not create a connection + for_each = var.auth_mechanism != null ? [0] : [] + + content { + auth_mechanism = var.auth_mechanism + reason = "sonargateway" + + username = var.auth_mechanism == "password" ? var.username : null + password = var.auth_mechanism == "password" ? var.password : null + database_name = var.auth_mechanism == "password" ? var.database_name : null + ssl = var.auth_mechanism == "password" ? var.ssl : null + + access_id = var.auth_mechanism == "aws_credentials" ? var.access_id : null + aws_connection_id = var.auth_mechanism == "aws_credentials" ? var.aws_connection_id : null + tmp_user = var.auth_mechanism == "aws_credentials" ? var.tmp_user : null + } + } +} diff --git a/modules/dsfhub-aws-redshift-cluster/output.tf b/modules/dsfhub-aws-redshift-cluster/output.tf new file mode 100644 index 0000000..87a7e24 --- /dev/null +++ b/modules/dsfhub-aws-redshift-cluster/output.tf @@ -0,0 +1,5 @@ +output "this" { + description = "AWS Redshift cluster asset" + value = dsfhub_data_source.this + sensitive = true +} diff --git a/modules/dsfhub-aws-redshift-cluster/variables.tf b/modules/dsfhub-aws-redshift-cluster/variables.tf new file mode 100644 index 0000000..f879ca3 --- /dev/null +++ b/modules/dsfhub-aws-redshift-cluster/variables.tf @@ -0,0 +1,125 @@ +# Asset variables +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:rds:us-east-2:123456790:cluster:cluster-name\"" + type = string +} + +variable "audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details. Valid values: TABLE | REDSHIFT." + type = string + default = null +} + +variable "audit_pull_enabled" { + description = "Whether the DSFHUB should pull logs from the asset." + type = bool + default = false +} + +variable "bucket_account_id" { + description = "The account_id of the bucket owner" + type = string + default = null +} + +variable "database_name" { + description = "The database name." + type = string + default = "dev" +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "logs_destination_asset_id" { + description = "The asset_id of the AWS S3 bucket asset when the audit_type is set to REDSHIFT." + type = string + default = null +} + +variable "parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "region" { + description = "AWS region containing the Redshift cluster." + type = string +} + +variable "server_host_name" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "server_ip" { + description = "Endpoint URL, e.g. .amazon.com" + type = string +} + +variable "server_port" { + description = "Database port being used. Default: 5439" + type = number + default = 5439 +} + +variable "service_name" { + description = "The database name (see Service Name Guidelines)." + type = string + default = null +} + +# Connection variables +variable "auth_mechanism" { + description = "The authentication mechanism to use for the Redshift asset." + type = string + default = null +} + +variable "username" { + description = "The username to use for authentication." + type = string + default = null +} + +variable "password" { + description = "The password to use for authentication." + type = string + default = null +} + +variable "access_id" { + description = "The cluster identifier." + type = string + default = null +} + +variable "aws_connection_id" { + description = "The stringified object ID of the AWS connection document." + type = string + default = null +} + +variable "tmp_user" { + description = "Whether the DSFHUB should create a temp user." + type = bool + default = null +} + +variable "ssl" { + description = "Whether to use SSL for the connection." + type = bool + default = null +} diff --git a/modules/dsfhub-aws-s3-bucket-ds/README.md b/modules/dsfhub-aws-s3-bucket-ds/README.md new file mode 100644 index 0000000..a72c65f --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-ds/README.md @@ -0,0 +1,41 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_data_source.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/data_source) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by the user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:s3:::bucket-name" | `string` | n/a | yes | +| [audit\_type](#input\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `null` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [region](#input\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [server\_host\_name](#input\_server\_host\_name) | S3 bucket name. | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Database port being used. | `number` | `443` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS S3 bucket data source asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-s3-bucket-ds/main.tf b/modules/dsfhub-aws-s3-bucket-ds/main.tf new file mode 100644 index 0000000..094b95f --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-ds/main.tf @@ -0,0 +1,26 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_data_source" "this" { + server_type = "AWS S3" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + audit_type = var.audit_type + gateway_id = var.gateway_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + server_port = var.server_port + + asset_connection { + auth_mechanism = "default" + reason = "sonargateway" + } +} diff --git a/modules/dsfhub-aws-s3-bucket-ds/output.tf b/modules/dsfhub-aws-s3-bucket-ds/output.tf new file mode 100644 index 0000000..080d602 --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-ds/output.tf @@ -0,0 +1,5 @@ +output "this" { + description = "AWS S3 bucket data source asset" + value = dsfhub_data_source.this + sensitive = true +} diff --git a/modules/dsfhub-aws-s3-bucket-ds/variables.tf b/modules/dsfhub-aws-s3-bucket-ds/variables.tf new file mode 100644 index 0000000..d51c53a --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-ds/variables.tf @@ -0,0 +1,48 @@ +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by the user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:s3:::bucket-name\"" + type = string +} + +variable "audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = null +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "region" { + description = "AWS region containing the instance." + type = string +} + +variable "server_host_name" { + description = "S3 bucket name." + type = string +} + +variable "server_port" { + description = "Database port being used." + type = number + default = 443 +} + + diff --git a/modules/dsfhub-aws-s3-bucket-la/README.md b/modules/dsfhub-aws-s3-bucket-la/README.md new file mode 100644 index 0000000..77e053e --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-la/README.md @@ -0,0 +1,45 @@ + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [dsfhub](#provider\_dsfhub) | n/a | + +## Modules + +No modules. + +## Resources + +| Name | Type | +|------|------| +| [dsfhub_log_aggregator.this](https://registry.terraform.io/providers/imperva/dsfhub/latest/docs/resources/log_aggregator) | resource | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [admin\_email](#input\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [asset\_display\_name](#input\_asset\_display\_name) | User-friendly name of the asset, defined by the user | `string` | n/a | yes | +| [asset\_id](#input\_asset\_id) | AWS ARN, e.g. "arn:aws:s3:::bucket-name" | `string` | n/a | yes | +| [audit\_pull\_enabled](#input\_audit\_pull\_enabled) | Whether the DSFHUB should pull logs from the asset. | `bool` | `false` | no | +| [audit\_type](#input\_audit\_type) | Used to indicate what type of audit will be pulled on systems supporting multiple audit types. Valid values: LOG\_GROUP (default), KINESIS, CLOUDWATCH, REDSHIFT, DYNAMODB | `string` | `"LOG_GROUP"` | no | +| [bucket\_account\_id](#input\_bucket\_account\_id) | Mandatory for audit types: REDSHIFT and DYNAMODB. Account number found in the prefix of the files we are pulling. e.g: `123456789012` out of `redshift/AWSLogs/123456789012/redshift/us-east-1/2024/06/25/my_file.gz` | `string` | `null` | no | +| [gateway\_id](#input\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [parent\_asset\_id](#input\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [region](#input\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [s3\_provider](#input\_s3\_provider) | Required only for AWS RDS MS SQL SERVER. Accepted value: 'aws-rds-mssql' | `string` | `null` | no | +| [server\_host\_name](#input\_server\_host\_name) | S3 bucket name. | `string` | n/a | yes | +| [server\_ip](#input\_server\_ip) | S3 bucket ARN. | `string` | n/a | yes | +| [server\_port](#input\_server\_port) | Database port being used. | `number` | `443` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [this](#output\_this) | AWS S3 bucket log aggregator asset | + \ No newline at end of file diff --git a/modules/dsfhub-aws-s3-bucket-la/main.tf b/modules/dsfhub-aws-s3-bucket-la/main.tf new file mode 100644 index 0000000..aec3c83 --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-la/main.tf @@ -0,0 +1,30 @@ +terraform { + required_providers { + dsfhub = { + source = "imperva/dsfhub" + } + } +} + +resource "dsfhub_log_aggregator" "this" { + server_type = "AWS S3" + + admin_email = var.admin_email + asset_display_name = var.asset_display_name + asset_id = var.asset_id + audit_pull_enabled = var.audit_pull_enabled + audit_type = var.audit_type + bucket_account_id = var.bucket_account_id + gateway_id = var.gateway_id + parent_asset_id = var.parent_asset_id + region = var.region + server_host_name = var.server_host_name + server_ip = var.server_ip + server_port = var.server_port + s3_provider = var.s3_provider + + asset_connection { + auth_mechanism = "default" + reason = "default" + } +} diff --git a/modules/dsfhub-aws-s3-bucket-la/output.tf b/modules/dsfhub-aws-s3-bucket-la/output.tf new file mode 100644 index 0000000..32693b7 --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-la/output.tf @@ -0,0 +1,5 @@ +output "this" { + description = "AWS S3 bucket log aggregator asset" + value = dsfhub_log_aggregator.this + sensitive = true +} diff --git a/modules/dsfhub-aws-s3-bucket-la/variables.tf b/modules/dsfhub-aws-s3-bucket-la/variables.tf new file mode 100644 index 0000000..5b9b7c1 --- /dev/null +++ b/modules/dsfhub-aws-s3-bucket-la/variables.tf @@ -0,0 +1,73 @@ +variable "admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "asset_display_name" { + description = "User-friendly name of the asset, defined by the user" + type = string +} + +variable "asset_id" { + description = "AWS ARN, e.g. \"arn:aws:s3:::bucket-name\"" + type = string +} + +variable "audit_pull_enabled" { + description = "Whether the DSFHUB should pull logs from the asset." + type = bool + default = false +} + +variable "audit_type" { + description = "Used to indicate what type of audit will be pulled on systems supporting multiple audit types. Valid values: LOG_GROUP (default), KINESIS, CLOUDWATCH, REDSHIFT, DYNAMODB" + type = string + default = "LOG_GROUP" + validation { + condition = can(regex("LOG_GROUP|KINESIS|CLOUDWATCH|REDSHIFT|DYNAMODB", var.audit_type)) + error_message = "audit_type must be one of LOG_GROUP, KINESIS, CLOUDWATCH, REDSHIFT, DYNAMODB" + } +} + +variable "bucket_account_id" { + description = "Mandatory for audit types: REDSHIFT and DYNAMODB. Account number found in the prefix of the files we are pulling. e.g: `123456789012` out of `redshift/AWSLogs/123456789012/redshift/us-east-1/2024/06/25/my_file.gz`" + type = string + default = null +} + +variable "gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "region" { + description = "AWS region containing the instance." + type = string +} + +variable "server_host_name" { + description = "S3 bucket name." + type = string +} + +variable "server_ip" { + description = "S3 bucket ARN." + type = string +} + +variable "server_port" { + description = "Database port being used." + type = number + default = 443 +} + +variable "s3_provider" { + description = "Required only for AWS RDS MS SQL SERVER. Accepted value: 'aws-rds-mssql'" + type = string + default = null +} diff --git a/modules/onboard-aws-docdb-cluster/README.md b/modules/onboard-aws-docdb-cluster/README.md new file mode 100644 index 0000000..49c991e --- /dev/null +++ b/modules/onboard-aws-docdb-cluster/README.md @@ -0,0 +1,83 @@ +# onboard-aws-docdb-cluster +Onboard Amazon DocumentDB to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [docdb-cluster](#module\_docdb-cluster) | ../aws-docdb-cluster | n/a | +| [docdb-cluster-asset](#module\_docdb-cluster-asset) | ../dsfhub-aws-docdb-cluster | n/a | +| [docdb-cluster-instance](#module\_docdb-cluster-instance) | ../aws-docdb-cluster-instance | n/a | +| [docdb-log-group](#module\_docdb-log-group) | ../aws-cloudwatch-log-group | n/a | +| [docdb-log-group-asset](#module\_docdb-log-group-asset) | ../dsfhub-aws-log-group | n/a | +| [docdb-param-group](#module\_docdb-param-group) | ../aws-docdb-cluster-parameter-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_docdb\_cluster\_admin\_email](#input\_aws\_docdb\_cluster\_admin\_email) | The email address to notify about the asset. | `string` | n/a | yes | +| [aws\_docdb\_cluster\_gateway\_id](#input\_aws\_docdb\_cluster\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_docdb\_cluster\_parent\_asset\_id](#input\_aws\_docdb\_cluster\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [aws\_docdb\_cluster\_region](#input\_aws\_docdb\_cluster\_region) | AWS region of the DocumentDB Cluster. | `string` | n/a | yes | +| [aws\_log\_group\_admin\_email](#input\_aws\_log\_group\_admin\_email) | The email address to notify about the asset. | `string` | n/a | yes | +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_log\_group\_gateway\_id](#input\_aws\_log\_group\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_log\_group\_reason](#input\_aws\_log\_group\_reason) | Used to differentiate connections that belong to the same asset | `string` | `"default"` | no | +| [aws\_log\_group\_region](#input\_aws\_log\_group\_region) | AWS region of the log group | `string` | n/a | yes | +| [cluster\_apply\_immediately](#input\_cluster\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [cluster\_db\_subnet\_group\_name](#input\_cluster\_db\_subnet\_group\_name) | A DB subnet group to associate with this DB instance. | `string` | n/a | yes | +| [cluster\_deletion\_protection](#input\_cluster\_deletion\_protection) | A value that indicates whether the DB cluster has deletion protection enabled. The database can't be deleted when deletion protection is enabled. | `bool` | `false` | no | +| [cluster\_enabled\_cloudwatch\_logs\_exports](#input\_cluster\_enabled\_cloudwatch\_logs\_exports) | List of log types to export to CloudWatch. | `list(string)` |
[
"audit"
]
| no | +| [cluster\_engine\_version](#input\_cluster\_engine\_version) | Database engine version, e.g. "5.0.0" | `string` | `"5.0.0"` | no | +| [cluster\_final\_snapshot\_identifier](#input\_cluster\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | Identifier of DocumentDB Cluster. | `string` | n/a | yes | +| [cluster\_master\_password](#input\_cluster\_master\_password) | Password for the master DB user. | `string` | n/a | yes | +| [cluster\_master\_username](#input\_cluster\_master\_username) | Master DB username. | `string` | `"docdb"` | no | +| [cluster\_port](#input\_cluster\_port) | The port on which the DB accepts connections. | `number` | `27017` | no | +| [cluster\_skip\_final\_snapshot](#input\_cluster\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final\_snapshot\_identifier | `bool` | `true` | no | +| [cluster\_storage\_type](#input\_cluster\_storage\_type) | The storage type to associate with the DB cluster. | `string` | `"standard"` | no | +| [cluster\_tags](#input\_cluster\_tags) | A map of tags to assign to the DB cluster. | `map(string)` | `null` | no | +| [cluster\_vpc\_security\_group\_ids](#input\_cluster\_vpc\_security\_group\_ids) | List of VPC security groups to associate with the Cluster | `list(string)` | n/a | yes | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_count](#input\_instance\_count) | The number of instances to create in the DocumentDB cluster. | `number` | `1` | no | +| [instance\_instance\_class](#input\_instance\_instance\_class) | The instance type of the DocumentDB cluster. Example: 'db.r5.large'. Reference: https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs | `string` | `"db.r5.large"` | no | +| [instance\_promotion\_tier](#input\_instance\_promotion\_tier) | Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoted to a writer in case of failover. | `number` | `0` | no | +| [instance\_tags](#input\_instance\_tags) | A map of tags to assign to the DocumentDB instance. | `map(string)` | `null` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | The number of days to retain log events. | `number` | `7` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the DocumentDB cluster parameter group. | `string` | `"Managed by Terraform"` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | Database family version, e.g. "docdb5.0" | `string` | `"docdb5.0"` | no | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the DocumentDB cluster parameter group. | `string` | `"docdb-parameter-group"` | no | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | List of objects containing parameters for the DocumentDB parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"apply_method": "immediate",
"name": "audit_logs",
"value": "all"
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the cluster. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [docdb-cluster](#output\_docdb-cluster) | docdb cluster | +| [docdb-cluster-asset](#output\_docdb-cluster-asset) | docdb cluster asset | +| [docdb-cluster-instance](#output\_docdb-cluster-instance) | docdb cluster instance | +| [docdb-log-group](#output\_docdb-log-group) | docdb log group | +| [docdb-log-group-asset](#output\_docdb-log-group-asset) | docdb log group asset | +| [docdb-param-group](#output\_docdb-param-group) | docdb parameter group | + \ No newline at end of file diff --git a/modules/onboard-aws-docdb-cluster/main.tf b/modules/onboard-aws-docdb-cluster/main.tf new file mode 100644 index 0000000..8fcdb37 --- /dev/null +++ b/modules/onboard-aws-docdb-cluster/main.tf @@ -0,0 +1,79 @@ +module "docdb-param-group" { + source = "../aws-docdb-cluster-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "docdb-cluster" { + source = "../aws-docdb-cluster" + + depends_on = [module.docdb-log-group] + + apply_immediately = var.cluster_apply_immediately + cluster_identifier = var.cluster_identifier + db_cluster_parameter_group_name = module.docdb-param-group.this.name + db_subnet_group_name = var.cluster_db_subnet_group_name + deletion_protection = var.cluster_deletion_protection + enabled_cloudwatch_logs_exports = var.cluster_enabled_cloudwatch_logs_exports + engine_version = var.cluster_engine_version + final_snapshot_identifier = var.cluster_final_snapshot_identifier + master_password = var.cluster_master_password + master_username = var.cluster_master_username + port = var.cluster_port + skip_final_snapshot = var.cluster_skip_final_snapshot + storage_type = var.cluster_storage_type + tags = var.cluster_tags + vpc_security_group_ids = var.cluster_vpc_security_group_ids +} + +module "docdb-cluster-instance" { + source = "../aws-docdb-cluster-instance" + + depends_on = [module.docdb-cluster] + + apply_immediately = var.instance_apply_immediately + cluster_identifier = var.cluster_identifier + count = var.instance_count + instance_class = var.instance_instance_class + promotion_tier = var.instance_promotion_tier + tags = var.instance_tags +} + +module "docdb-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/docdb/${var.cluster_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "docdb-cluster-asset" { + source = "../dsfhub-aws-docdb-cluster" + + admin_email = var.aws_docdb_cluster_admin_email + asset_display_name = module.docdb-cluster.this.cluster_identifier + asset_id = module.docdb-cluster.this.arn + cluster_identifier = module.docdb-cluster.this.cluster_identifier + gateway_id = var.aws_docdb_cluster_gateway_id + parent_asset_id = var.aws_docdb_cluster_parent_asset_id + region = var.aws_docdb_cluster_region + server_host_name = module.docdb-cluster.this.endpoint + server_ip = module.docdb-cluster.this.arn + server_port = module.docdb-cluster.this.port +} + +module "docdb-log-group-asset" { + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_log_group_admin_email + asset_display_name = "${module.docdb-log-group.this.arn}:*" + asset_id = "${module.docdb-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_log_group_gateway_id + parent_asset_id = module.docdb-cluster-asset.this.asset_id + reason = var.aws_log_group_reason + region = var.aws_log_group_region +} diff --git a/modules/onboard-aws-docdb-cluster/outputs.tf b/modules/onboard-aws-docdb-cluster/outputs.tf new file mode 100644 index 0000000..5321b7e --- /dev/null +++ b/modules/onboard-aws-docdb-cluster/outputs.tf @@ -0,0 +1,29 @@ +output "docdb-param-group" { + description = "docdb parameter group" + value = module.docdb-param-group.this +} + +output "docdb-cluster" { + description = "docdb cluster" + value = module.docdb-cluster.this +} + +output "docdb-cluster-instance" { + description = "docdb cluster instance" + value = module.docdb-cluster-instance[*].this +} + +output "docdb-log-group" { + description = "docdb log group" + value = module.docdb-log-group.this +} + +output "docdb-cluster-asset" { + description = "docdb cluster asset" + value = module.docdb-cluster-asset.this +} + +output "docdb-log-group-asset" { + description = "docdb log group asset" + value = module.docdb-log-group-asset.this +} diff --git a/modules/onboard-aws-docdb-cluster/variables.tf b/modules/onboard-aws-docdb-cluster/variables.tf new file mode 100644 index 0000000..b29f8d4 --- /dev/null +++ b/modules/onboard-aws-docdb-cluster/variables.tf @@ -0,0 +1,221 @@ +# AWS DocumentDB Parameter Group variables +variable "parameter_group_description" { + description = "The description of the DocumentDB cluster parameter group." + type = string + default = "Managed by Terraform" +} + +variable "parameter_group_family" { + description = "Database family version, e.g. \"docdb5.0\"" + type = string + default = "docdb5.0" +} + +variable "parameter_group_name" { + description = "The name of the DocumentDB cluster parameter group." + type = string + default = "docdb-parameter-group" +} + +variable "parameter_group_parameters" { + description = "List of objects containing parameters for the DocumentDB parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [{ + name = "audit_logs" + value = "all" + apply_method = "immediate" + }] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the cluster." + type = map(string) + default = null +} + +# AWS DocumentDB Cluster and AWS DocumentDB Instance shared variables +variable "cluster_identifier" { + description = "Identifier of DocumentDB Cluster." + type = string +} + +# AWS DocumentDB Cluster variables +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "cluster_db_subnet_group_name" { + description = "A DB subnet group to associate with this DB instance." + type = string +} + +variable "cluster_deletion_protection" { + description = "A value that indicates whether the DB cluster has deletion protection enabled. The database can't be deleted when deletion protection is enabled." + type = bool + default = false +} + +variable "cluster_enabled_cloudwatch_logs_exports" { + description = "List of log types to export to CloudWatch." + type = list(string) + default = ["audit"] + validation { + condition = alltrue([for log in var.cluster_enabled_cloudwatch_logs_exports : log == "audit" || log == "profiler"]) + error_message = "Invalid value in cluster_enabled_cloudwatch_logs_exports. Allowed values are (audit, profiler)." + } + validation { + condition = length(var.cluster_enabled_cloudwatch_logs_exports) == length(distinct(var.cluster_enabled_cloudwatch_logs_exports)) + error_message = "Duplicate item in cluster_enabled_cloudwatch_logs_exports. Allowed values are 'audit' or 'profiler'. Please ensure that each log type is unique." + } +} + +variable "cluster_engine_version" { + description = "Database engine version, e.g. \"5.0.0\"" + type = string + default = "5.0.0" +} + +variable "cluster_final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB cluster is deleted. If omitted, no final snapshot will be made. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "cluster_master_password" { + description = "Password for the master DB user." + type = string +} + +variable "cluster_master_username" { + description = "Master DB username." + type = string + default = "docdb" +} + +variable "cluster_port" { + description = "The port on which the DB accepts connections." + type = number + default = 27017 +} + +variable "cluster_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB cluster is deleted. If true is specified, no DB snapshot is created. If false is specified, a DB snapshot is created before the DB cluster is deleted, using the value from final_snapshot_identifier" + type = bool + default = true +} + +variable "cluster_storage_type" { + description = "The storage type to associate with the DB cluster." + type = string + default = "standard" + validation { + condition = can(regex("^(iopt1|standard)$", var.cluster_storage_type)) + error_message = "Invalid value for storage_type. Allowed values are 'iopt1' or 'standard'." + } +} + +variable "cluster_tags" { + description = "A map of tags to assign to the DB cluster." + type = map(string) + default = null +} + +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate with the Cluster" + type = list(string) +} + +# AWS DocumentDB Instance variables +variable "instance_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_count" { + description = "The number of instances to create in the DocumentDB cluster." + type = number + default = 1 +} + +variable "instance_instance_class" { + description = "The instance type of the DocumentDB cluster. Example: 'db.r5.large'. Reference: https://docs.aws.amazon.com/documentdb/latest/developerguide/db-instance-classes.html#db-instance-class-specs" + type = string + default = "db.r5.large" +} + +variable "instance_promotion_tier" { + description = "Failover Priority setting on instance level. The reader who has lower tier has higher priority to get promoted to a writer in case of failover." + type = number + default = 0 +} + +variable "instance_tags" { + description = "A map of tags to assign to the DocumentDB instance." + type = map(string) + default = null +} + +# AWS CloudWatch Log Group variables +variable "log_group_retention_in_days" { + description = "The number of days to retain log events." + type = number + default = 7 +} + +# DSFHUB AWS DocumentDB Cluster asset variables +variable "aws_docdb_cluster_admin_email" { + description = "The email address to notify about the asset." + type = string +} + +variable "aws_docdb_cluster_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_docdb_cluster_region" { + description = "AWS region of the DocumentDB Cluster." + type = string +} + +variable "aws_docdb_cluster_parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +# DSFHUB CloudWatch Log Group variables +variable "aws_log_group_admin_email" { + description = "The email address to notify about the asset." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "aws_log_group_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_log_group_reason" { + description = "Used to differentiate connections that belong to the same asset" + type = string + default = "default" +} + +variable "aws_log_group_region" { + description = "AWS region of the log group" + type = string +} diff --git a/modules/onboard-aws-neptune-slow-query/README.md b/modules/onboard-aws-neptune-slow-query/README.md new file mode 100644 index 0000000..fc8ca02 --- /dev/null +++ b/modules/onboard-aws-neptune-slow-query/README.md @@ -0,0 +1,83 @@ +# onboard-aws-neptune-slow-query +Onboard Amazon Neptune Slowquery to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-log-group-asset](#module\_aws-log-group-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-log-group-slowquery-asset](#module\_aws-log-group-slowquery-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-neptune-cluster-asset](#module\_aws-neptune-cluster-asset) | ../dsfhub-aws-neptune-cluster | n/a | +| [neptune-cluster](#module\_neptune-cluster) | ../aws-neptune-cluster | n/a | +| [neptune-cluster-parameter-group](#module\_neptune-cluster-parameter-group) | ../aws-neptune-cluster-parameter-group | n/a | +| [neptune-instance](#module\_neptune-instance) | ../aws-neptune-instance | n/a | +| [neptune-log-group](#module\_neptune-log-group) | ../aws-cloudwatch-log-group | n/a | +| [neptune-log-group-slowquery](#module\_neptune-log-group-slowquery) | ../aws-cloudwatch-log-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_neptune\_cluster\_admin\_email](#input\_aws\_neptune\_cluster\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_neptune\_cluster\_gateway\_id](#input\_aws\_neptune\_cluster\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_neptune\_cluster\_parent\_asset\_id](#input\_aws\_neptune\_cluster\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [aws\_neptune\_cluster\_region](#input\_aws\_neptune\_cluster\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [cluster\_apply\_immediately](#input\_cluster\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [cluster\_backup\_retention\_period](#input\_cluster\_backup\_retention\_period) | The days to retain backups for. Default is 1 | `number` | `1` | no | +| [cluster\_enable\_cloudwatch\_logs\_exports](#input\_cluster\_enable\_cloudwatch\_logs\_exports) | A list of the log types this DB cluster is configured to export to Cloudwatch Logs. Currently only supports audit and slowquery | `list(string)` |
[
"audit",
"slowquery"
]
| no | +| [cluster\_engine](#input\_cluster\_engine) | The name of the database engine to be used for this Neptune cluster. | `string` | `"neptune"` | no | +| [cluster\_engine\_version](#input\_cluster\_engine\_version) | The database engine version. | `string` | `"1.3.2.0"` | no | +| [cluster\_iam\_database\_authentication\_enabled](#input\_cluster\_iam\_database\_authentication\_enabled) | Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | `bool` | `true` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | The cluster identifier | `string` | n/a | yes | +| [cluster\_preferred\_maintenance\_window](#input\_cluster\_preferred\_maintenance\_window) | Weekly time range during which system maintenance can occur, in (UTC). | `string` | `"sun:18:00-sun:21:00"` | no | +| [cluster\_skip\_final\_snapshot](#input\_cluster\_skip\_final\_snapshot) | Determines whether a final Neptune snapshot is created before the Neptune cluster is deleted. If true is specified, no Neptune snapshot is created. If false is specified, a Neptune snapshot is created before the Neptune cluster is deleted, using the value from final\_snapshot\_identifier | `bool` | `true` | no | +| [cluster\_storage\_type](#input\_cluster\_storage\_type) | Storage type associated with the cluster. Default: standard | `string` | `"standard"` | no | +| [cluster\_vpc\_security\_group\_ids](#input\_cluster\_vpc\_security\_group\_ids) | List of VPC security groups to associate with the Cluster | `list(string)` | `null` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any instance modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_auto\_minor\_version\_upgrade](#input\_instance\_auto\_minor\_version\_upgrade) | Indicates that minor engine upgrades will be applied automatically to the instance during the maintenance window. Default is true | `bool` | `false` | no | +| [instance\_class](#input\_instance\_class) | The instance class to use. | `string` | `"db.t3.medium"` | no | +| [instance\_identifier](#input\_instance\_identifier) | The identifier for the neptune instance. | `string` | n/a | yes | +| [instance\_neptune\_parameter\_group\_name](#input\_instance\_neptune\_parameter\_group\_name) | The name of the neptune parameter group to associate with this instance | `string` | `"default.neptune1"` | no | +| [instance\_neptune\_subnet\_group\_name](#input\_instance\_neptune\_subnet\_group\_name) | A subnet group to associate with this neptune instance. NOTE: This must match the neptune\_subnet\_group\_name of the attached aws\_neptune\_cluster | `string` | `null` | no | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. Defaults to 8182 | `number` | `8182` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. Default is false | `bool` | `false` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire. | `number` | `7` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | Neptune cluster parameter group | `string` | `"Neptune cluster parameter group"` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the cluster parameter group. | `string` | `"neptune1.3"` | no | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the cluster parameter group. | `string` | n/a | yes | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | List of objects containing parameters for the cluster parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"apply_method": "pending-reboot",
"name": "neptune_enable_audit_log",
"value": 1
},
{
"name": "neptune_enable_slow_query_log",
"value": "info"
},
{
"name": "neptune_slow_query_log_threshold",
"value": 10000
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [cluster](#output\_cluster) | Neptune Cluster | +| [cluster\_parameter\_group](#output\_cluster\_parameter\_group) | Neptune Cluster parameter group | +| [dsf\_neptune\_cluster](#output\_dsf\_neptune\_cluster) | Neptune cluster DSF asset | +| [dsf\_neptune\_log\_group](#output\_dsf\_neptune\_log\_group) | DSF neptune log group asset | +| [dsf\_neptune\_log\_group\_slowquery](#output\_dsf\_neptune\_log\_group\_slowquery) | DSF neptune slow query log group asset | +| [instance](#output\_instance) | Neptune instance | +| [log\_group](#output\_log\_group) | Neptune log group | +| [log\_group\_slowquery](#output\_log\_group\_slowquery) | Neptune slow query log group | + \ No newline at end of file diff --git a/modules/onboard-aws-neptune-slow-query/main.tf b/modules/onboard-aws-neptune-slow-query/main.tf new file mode 100644 index 0000000..c652cca --- /dev/null +++ b/modules/onboard-aws-neptune-slow-query/main.tf @@ -0,0 +1,99 @@ +module "neptune-cluster-parameter-group" { + source = "../aws-neptune-cluster-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "neptune-cluster" { + depends_on = [module.neptune-cluster-parameter-group, module.neptune-log-group, module.neptune-log-group-slowquery] + + source = "../aws-neptune-cluster" + + identifier = var.cluster_identifier + engine = var.cluster_engine + engine_version = var.cluster_engine_version + backup_retention_period = var.cluster_backup_retention_period + skip_final_snapshot = var.cluster_skip_final_snapshot + enable_cloudwatch_logs_exports = var.cluster_enable_cloudwatch_logs_exports + parameter_group_name = module.neptune-cluster-parameter-group.this.name + storage_type = var.cluster_storage_type + preferred_maintenance_window = var.cluster_preferred_maintenance_window + iam_database_authentication_enabled = var.cluster_iam_database_authentication_enabled + vpc_security_group_ids = var.cluster_vpc_security_group_ids + neptune_subnet_group_name = var.instance_neptune_subnet_group_name + apply_immediately = var.cluster_apply_immediately +} + +module "neptune-instance" { + depends_on = [module.neptune-cluster] + source = "../aws-neptune-instance" + + cluster_identifier = module.neptune-cluster.this.cluster_identifier + identifier = var.instance_identifier + class = var.instance_class + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + neptune_subnet_group_name = var.instance_neptune_subnet_group_name + neptune_parameter_group_name = var.instance_neptune_parameter_group_name + auto_minor_version_upgrade = var.instance_auto_minor_version_upgrade + apply_immediately = var.instance_apply_immediately +} + +module "neptune-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/neptune/${var.cluster_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "neptune-log-group-slowquery" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/neptune/${var.cluster_identifier}/slowquery" + retention_in_days = var.log_group_retention_in_days +} + +module "aws-neptune-cluster-asset" { + source = "../dsfhub-aws-neptune-cluster" + + admin_email = var.aws_neptune_cluster_admin_email + asset_display_name = module.neptune-cluster.this.id + asset_id = module.neptune-cluster.this.arn + gateway_id = var.aws_neptune_cluster_gateway_id + server_host_name = module.neptune-cluster.this.endpoint + server_port = module.neptune-cluster.this.port + region = var.aws_neptune_cluster_region + parent_asset_id = var.aws_neptune_cluster_parent_asset_id +} + +module "aws-log-group-asset" { + depends_on = [module.aws-neptune-cluster-asset] + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_neptune_cluster_admin_email + asset_display_name = module.neptune-log-group.this.id + asset_id = "${module.neptune-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_neptune_cluster_gateway_id + parent_asset_id = module.aws-neptune-cluster-asset.this.asset_id + audit_type = "LOG_GROUP" + region = var.aws_neptune_cluster_region +} + +module "aws-log-group-slowquery-asset" { + depends_on = [module.aws-neptune-cluster-asset, module.aws-log-group-asset] + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_neptune_cluster_admin_email + asset_display_name = module.neptune-log-group-slowquery.this.id + asset_id = "${module.neptune-log-group-slowquery.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_neptune_cluster_gateway_id + parent_asset_id = module.aws-neptune-cluster-asset.this.asset_id + audit_type = "AWS_NEPTUNE_SLOW" + region = var.aws_neptune_cluster_region +} \ No newline at end of file diff --git a/modules/onboard-aws-neptune-slow-query/outputs.tf b/modules/onboard-aws-neptune-slow-query/outputs.tf new file mode 100644 index 0000000..399a683 --- /dev/null +++ b/modules/onboard-aws-neptune-slow-query/outputs.tf @@ -0,0 +1,39 @@ +output "cluster_parameter_group" { + description = "Neptune Cluster parameter group" + value = module.neptune-cluster-parameter-group.this +} + +output "cluster" { + description = "Neptune Cluster" + value = module.neptune-cluster.this +} + +output "instance" { + description = "Neptune instance" + value = module.neptune-instance.this +} + +output "log_group" { + description = "Neptune log group" + value = module.neptune-log-group.this +} + +output "log_group_slowquery" { + description = "Neptune slow query log group" + value = module.neptune-log-group-slowquery.this +} + +output "dsf_neptune_cluster" { + description = "Neptune cluster DSF asset" + value = module.aws-neptune-cluster-asset.this +} + +output "dsf_neptune_log_group" { + description = "DSF neptune log group asset" + value = module.aws-log-group-asset.this +} + +output "dsf_neptune_log_group_slowquery" { + description = "DSF neptune slow query log group asset" + value = module.aws-log-group-slowquery-asset.this +} \ No newline at end of file diff --git a/modules/onboard-aws-neptune-slow-query/variables.tf b/modules/onboard-aws-neptune-slow-query/variables.tf new file mode 100644 index 0000000..741130f --- /dev/null +++ b/modules/onboard-aws-neptune-slow-query/variables.tf @@ -0,0 +1,201 @@ +#AWS neptune cluster parameter group variables +variable "parameter_group_description" { + description = "Neptune cluster parameter group" + type = string + default = "Neptune cluster parameter group" +} + +variable "parameter_group_family" { + description = "The family of the cluster parameter group." + type = string + default = "neptune1.3" +} + +variable "parameter_group_name" { + description = "The name of the cluster parameter group." + type = string +} + +variable "parameter_group_parameters" { + description = "List of objects containing parameters for the cluster parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [ + { + name = "neptune_enable_audit_log" + value = 1 + apply_method = "pending-reboot" + }, + { + name = "neptune_enable_slow_query_log" + value = "info" + }, + { + name = "neptune_slow_query_log_threshold" + value = 10000 + } + ] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +#AWS Neptune cluster variables +variable "cluster_identifier" { + description = "The cluster identifier" + type = string +} + +variable "cluster_engine" { + description = "The name of the database engine to be used for this Neptune cluster." + type = string + default = "neptune" +} + +variable "cluster_engine_version" { + description = "The database engine version." + type = string + default = "1.3.2.0" +} + +variable "cluster_backup_retention_period" { + description = "The days to retain backups for. Default is 1" + type = number + default = 1 +} + +variable "cluster_skip_final_snapshot" { + description = "Determines whether a final Neptune snapshot is created before the Neptune cluster is deleted. If true is specified, no Neptune snapshot is created. If false is specified, a Neptune snapshot is created before the Neptune cluster is deleted, using the value from final_snapshot_identifier" + type = bool + default = true +} + +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. " + type = bool + default = true +} + +variable "cluster_enable_cloudwatch_logs_exports" { + description = "A list of the log types this DB cluster is configured to export to Cloudwatch Logs. Currently only supports audit and slowquery" + type = list(string) + default = ["audit", "slowquery"] +} + +variable "cluster_storage_type" { + description = "Storage type associated with the cluster. Default: standard" + type = string + default = "standard" + validation { + condition = contains(["standard", "standard/iopt1"], var.cluster_storage_type) + error_message = "Invalid value. Pick either standard or standard/iopt1" + } +} + +variable "cluster_iam_database_authentication_enabled" { + description = " Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled." + type = bool + default = true +} + +variable "cluster_preferred_maintenance_window" { + description = "Weekly time range during which system maintenance can occur, in (UTC)." + type = string + default = "sun:18:00-sun:21:00" +} + +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate with the Cluster" + type = list(string) + default = null +} + +#AWS Neptune instance variables +variable "instance_apply_immediately" { + description = "Specifies whether any instance modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_auto_minor_version_upgrade" { + description = "Indicates that minor engine upgrades will be applied automatically to the instance during the maintenance window. Default is true" + type = bool + default = false +} + +variable "instance_identifier" { + description = "The identifier for the neptune instance." + type = string +} + +variable "instance_class" { + description = "The instance class to use." + type = string + default = "db.t3.medium" +} + +variable "instance_neptune_subnet_group_name" { + description = "A subnet group to associate with this neptune instance. NOTE: This must match the neptune_subnet_group_name of the attached aws_neptune_cluster" + type = string + default = null +} + +variable "instance_neptune_parameter_group_name" { + description = "The name of the neptune parameter group to associate with this instance" + type = string + default = "default.neptune1" +} + +variable "instance_port" { + description = "The port on which the DB accepts connections. Defaults to 8182" + type = number + default = 8182 +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible. Default is false" + type = bool + default = false +} + +#AWS cloudwatch variables +variable "log_group_retention_in_days" { + description = "Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire." + type = number + default = 7 +} + +#DSFHUB variables +variable "aws_neptune_cluster_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_neptune_cluster_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_neptune_cluster_parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "aws_neptune_cluster_region" { + description = "AWS region containing the instance." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} \ No newline at end of file diff --git a/modules/onboard-aws-neptune/README.md b/modules/onboard-aws-neptune/README.md new file mode 100644 index 0000000..b8735dd --- /dev/null +++ b/modules/onboard-aws-neptune/README.md @@ -0,0 +1,79 @@ +# onboard-aws-neptune +Onboard Amazon Neptune to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-log-group-asset](#module\_aws-log-group-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-neptune-cluster-asset](#module\_aws-neptune-cluster-asset) | ../dsfhub-aws-neptune-cluster | n/a | +| [neptune-cluster](#module\_neptune-cluster) | ../aws-neptune-cluster | n/a | +| [neptune-cluster-parameter-group](#module\_neptune-cluster-parameter-group) | ../aws-neptune-cluster-parameter-group | n/a | +| [neptune-instance](#module\_neptune-instance) | ../aws-neptune-instance | n/a | +| [neptune-log-group](#module\_neptune-log-group) | ../aws-cloudwatch-log-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_neptune\_cluster\_admin\_email](#input\_aws\_neptune\_cluster\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_neptune\_cluster\_gateway\_id](#input\_aws\_neptune\_cluster\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_neptune\_cluster\_parent\_asset\_id](#input\_aws\_neptune\_cluster\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [aws\_neptune\_cluster\_region](#input\_aws\_neptune\_cluster\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [cluster\_apply\_immediately](#input\_cluster\_apply\_immediately) | Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [cluster\_backup\_retention\_period](#input\_cluster\_backup\_retention\_period) | The days to retain backups for. Default is 1 | `number` | `1` | no | +| [cluster\_enable\_cloudwatch\_logs\_exports](#input\_cluster\_enable\_cloudwatch\_logs\_exports) | A list of the log types this DB cluster is configured to export to Cloudwatch Logs. Currently only supports audit and slowquery | `list(string)` |
[
"audit"
]
| no | +| [cluster\_engine](#input\_cluster\_engine) | The name of the database engine to be used for this Neptune cluster. | `string` | `"neptune"` | no | +| [cluster\_engine\_version](#input\_cluster\_engine\_version) | The database engine version. | `string` | `"1.3.2.0"` | no | +| [cluster\_iam\_database\_authentication\_enabled](#input\_cluster\_iam\_database\_authentication\_enabled) | Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled. | `bool` | `true` | no | +| [cluster\_identifier](#input\_cluster\_identifier) | The cluster identifier | `string` | n/a | yes | +| [cluster\_preferred\_maintenance\_window](#input\_cluster\_preferred\_maintenance\_window) | Weekly time range during which system maintenance can occur, in (UTC). | `string` | `"sun:18:00-sun:21:00"` | no | +| [cluster\_skip\_final\_snapshot](#input\_cluster\_skip\_final\_snapshot) | Determines whether a final Neptune snapshot is created before the Neptune cluster is deleted. If true is specified, no Neptune snapshot is created. If false is specified, a Neptune snapshot is created before the Neptune cluster is deleted, using the value from final\_snapshot\_identifier | `bool` | `true` | no | +| [cluster\_storage\_type](#input\_cluster\_storage\_type) | Storage type associated with the cluster. Default: standard | `string` | `"standard"` | no | +| [cluster\_vpc\_security\_group\_ids](#input\_cluster\_vpc\_security\_group\_ids) | List of VPC security groups to associate with the Cluster | `list(string)` | `null` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any instance modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_auto\_minor\_version\_upgrade](#input\_instance\_auto\_minor\_version\_upgrade) | Indicates that minor engine upgrades will be applied automatically to the instance during the maintenance window. Default is true | `bool` | `false` | no | +| [instance\_class](#input\_instance\_class) | The instance class to use. | `string` | `"db.t3.medium"` | no | +| [instance\_identifier](#input\_instance\_identifier) | The identifier for the neptune instance. | `string` | n/a | yes | +| [instance\_neptune\_parameter\_group\_name](#input\_instance\_neptune\_parameter\_group\_name) | The name of the neptune parameter group to associate with this instance | `string` | `"default.neptune1"` | no | +| [instance\_neptune\_subnet\_group\_name](#input\_instance\_neptune\_subnet\_group\_name) | A subnet group to associate with this neptune instance. NOTE: This must match the neptune\_subnet\_group\_name of the attached aws\_neptune\_cluster | `string` | `null` | no | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. Defaults to 8182 | `number` | `8182` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. Default is false | `bool` | `false` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire. | `number` | `7` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | Neptune cluster parameter group | `string` | `"Neptune cluster parameter group"` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the cluster parameter group. | `string` | `"neptune1.3"` | no | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the cluster parameter group. | `string` | n/a | yes | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | List of objects containing parameters for the cluster parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"apply_method": "pending-reboot",
"name": "neptune_enable_audit_log",
"value": 1
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [cluster](#output\_cluster) | Neptune Cluster | +| [cluster\_parameter\_group](#output\_cluster\_parameter\_group) | Neptune Cluster parameter group | +| [dsf\_neptune\_cluster](#output\_dsf\_neptune\_cluster) | Neptune cluster DSF asset | +| [dsf\_neptune\_log\_group](#output\_dsf\_neptune\_log\_group) | DSF neptune log group asset | +| [instance](#output\_instance) | Neptune instance | +| [log\_group](#output\_log\_group) | Neptune log group | + \ No newline at end of file diff --git a/modules/onboard-aws-neptune/main.tf b/modules/onboard-aws-neptune/main.tf new file mode 100644 index 0000000..be60878 --- /dev/null +++ b/modules/onboard-aws-neptune/main.tf @@ -0,0 +1,78 @@ +module "neptune-cluster-parameter-group" { + source = "../aws-neptune-cluster-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "neptune-cluster" { + depends_on = [module.neptune-cluster-parameter-group, module.neptune-log-group] + + source = "../aws-neptune-cluster" + + identifier = var.cluster_identifier + engine = var.cluster_engine + engine_version = var.cluster_engine_version + backup_retention_period = var.cluster_backup_retention_period + skip_final_snapshot = var.cluster_skip_final_snapshot + enable_cloudwatch_logs_exports = var.cluster_enable_cloudwatch_logs_exports + parameter_group_name = module.neptune-cluster-parameter-group.this.name + storage_type = var.cluster_storage_type + preferred_maintenance_window = var.cluster_preferred_maintenance_window + iam_database_authentication_enabled = var.cluster_iam_database_authentication_enabled + vpc_security_group_ids = var.cluster_vpc_security_group_ids + neptune_subnet_group_name = var.instance_neptune_subnet_group_name + apply_immediately = var.cluster_apply_immediately +} + +module "neptune-instance" { + depends_on = [module.neptune-cluster] + source = "../aws-neptune-instance" + + cluster_identifier = module.neptune-cluster.this.cluster_identifier + identifier = var.instance_identifier + class = var.instance_class + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + neptune_subnet_group_name = var.instance_neptune_subnet_group_name + neptune_parameter_group_name = var.instance_neptune_parameter_group_name + auto_minor_version_upgrade = var.instance_auto_minor_version_upgrade + apply_immediately = var.instance_apply_immediately +} + +module "neptune-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/neptune/${var.cluster_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "aws-neptune-cluster-asset" { + source = "../dsfhub-aws-neptune-cluster" + + admin_email = var.aws_neptune_cluster_admin_email + asset_display_name = module.neptune-cluster.this.id + asset_id = module.neptune-cluster.this.arn + gateway_id = var.aws_neptune_cluster_gateway_id + server_host_name = module.neptune-cluster.this.endpoint + server_port = module.neptune-cluster.this.port + region = var.aws_neptune_cluster_region + parent_asset_id = var.aws_neptune_cluster_parent_asset_id +} + +module "aws-log-group-asset" { + depends_on = [module.aws-neptune-cluster-asset] + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_neptune_cluster_admin_email + asset_display_name = module.neptune-log-group.this.id + asset_id = "${module.neptune-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_neptune_cluster_gateway_id + parent_asset_id = module.aws-neptune-cluster-asset.this.asset_id + audit_type = "LOG_GROUP" + region = var.aws_neptune_cluster_region +} \ No newline at end of file diff --git a/modules/onboard-aws-neptune/outputs.tf b/modules/onboard-aws-neptune/outputs.tf new file mode 100644 index 0000000..dd1ef93 --- /dev/null +++ b/modules/onboard-aws-neptune/outputs.tf @@ -0,0 +1,29 @@ +output "cluster_parameter_group" { + description = "Neptune Cluster parameter group" + value = module.neptune-cluster-parameter-group.this +} + +output "cluster" { + description = "Neptune Cluster" + value = module.neptune-cluster.this +} + +output "instance" { + description = "Neptune instance" + value = module.neptune-instance.this +} + +output "log_group" { + description = "Neptune log group" + value = module.neptune-log-group.this +} + +output "dsf_neptune_cluster" { + description = "Neptune cluster DSF asset" + value = module.aws-neptune-cluster-asset.this +} + +output "dsf_neptune_log_group" { + description = "DSF neptune log group asset" + value = module.aws-log-group-asset.this +} \ No newline at end of file diff --git a/modules/onboard-aws-neptune/variables.tf b/modules/onboard-aws-neptune/variables.tf new file mode 100644 index 0000000..1a6847b --- /dev/null +++ b/modules/onboard-aws-neptune/variables.tf @@ -0,0 +1,196 @@ +#AWS neptune cluster parameter group variables +variable "parameter_group_description" { + description = "Neptune cluster parameter group" + type = string + default = "Neptune cluster parameter group" +} + +variable "parameter_group_family" { + description = "The family of the cluster parameter group." + type = string + default = "neptune1.3" +} + +variable "parameter_group_name" { + description = "The name of the cluster parameter group." + type = string +} + +variable "parameter_group_parameters" { + description = "List of objects containing parameters for the cluster parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [ + { + name = "neptune_enable_audit_log" + value = 1 + apply_method = "pending-reboot" + } + ] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +#AWS Neptune cluster variables +variable "cluster_identifier" { + description = "The cluster identifier" + type = string +} + +variable "cluster_engine" { + description = "The name of the database engine to be used for this Neptune cluster." + type = string + default = "neptune" +} + +variable "cluster_engine_version" { + description = "The database engine version." + type = string + default = "1.3.2.0" +} + +variable "cluster_backup_retention_period" { + description = "The days to retain backups for. Default is 1" + type = number + default = 1 +} + +variable "cluster_skip_final_snapshot" { + description = "Determines whether a final Neptune snapshot is created before the Neptune cluster is deleted. If true is specified, no Neptune snapshot is created. If false is specified, a Neptune snapshot is created before the Neptune cluster is deleted, using the value from final_snapshot_identifier" + type = bool + default = true +} + +variable "cluster_apply_immediately" { + description = "Specifies whether any cluster modifications are applied immediately, or during the next maintenance window. " + type = bool + default = true +} + +variable "cluster_enable_cloudwatch_logs_exports" { + description = "A list of the log types this DB cluster is configured to export to Cloudwatch Logs. Currently only supports audit and slowquery" + type = list(string) + default = ["audit"] +} + +variable "cluster_storage_type" { + description = "Storage type associated with the cluster. Default: standard" + type = string + default = "standard" + validation { + condition = contains(["standard", "standard/iopt1"], var.cluster_storage_type) + error_message = "Invalid value. Pick either standard or standard/iopt1" + } +} + +variable "cluster_iam_database_authentication_enabled" { + description = " Specifies whether or not mappings of AWS Identity and Access Management (IAM) accounts to database accounts is enabled." + type = bool + default = true +} + +variable "cluster_preferred_maintenance_window" { + description = "Weekly time range during which system maintenance can occur, in (UTC)." + type = string + default = "sun:18:00-sun:21:00" +} + +variable "cluster_vpc_security_group_ids" { + description = "List of VPC security groups to associate with the Cluster" + type = list(string) + default = null +} + +#AWS Neptune instance variables +variable "instance_apply_immediately" { + description = "Specifies whether any instance modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_auto_minor_version_upgrade" { + description = "Indicates that minor engine upgrades will be applied automatically to the instance during the maintenance window. Default is true" + type = bool + default = false +} + +variable "instance_identifier" { + description = "The identifier for the neptune instance." + type = string +} + +variable "instance_class" { + description = "The instance class to use." + type = string + default = "db.t3.medium" +} + +variable "instance_neptune_subnet_group_name" { + description = "A subnet group to associate with this neptune instance. NOTE: This must match the neptune_subnet_group_name of the attached aws_neptune_cluster" + type = string + default = null +} + +variable "instance_neptune_parameter_group_name" { + description = "The name of the neptune parameter group to associate with this instance" + type = string + default = "default.neptune1" +} + +variable "instance_port" { + description = "The port on which the DB accepts connections. Defaults to 8182" + type = number + default = 8182 +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible. Default is false" + type = bool + default = false +} + +#AWS cloudwatch variables +variable "log_group_retention_in_days" { + description = "Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire." + type = number + default = 7 +} + +#DSFHUB variables +variable "aws_neptune_cluster_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_neptune_cluster_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_neptune_cluster_parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "aws_neptune_cluster_region" { + description = "AWS region containing the instance." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + + + diff --git a/modules/onboard-aws-rds-mariadb/README.md b/modules/onboard-aws-rds-mariadb/README.md new file mode 100644 index 0000000..07df834 --- /dev/null +++ b/modules/onboard-aws-rds-mariadb/README.md @@ -0,0 +1,80 @@ +# onboard-aws-rds-mariadb +Onboard Amazon RDS for MariaDB to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-log-group-asset](#module\_aws-log-group-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-rds-mariadb-asset](#module\_aws-rds-mariadb-asset) | ../dsfhub-aws-rds-mariadb | n/a | +| [mariadb-instance](#module\_mariadb-instance) | ../aws-rds-instance | n/a | +| [mariadb-log-group](#module\_mariadb-log-group) | ../aws-cloudwatch-log-group | n/a | +| [mariadb-option-group](#module\_mariadb-option-group) | ../aws-rds-option-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_log\_group\_admin\_email](#input\_aws\_log\_group\_admin\_email) | The email address to notify about the asset. | `string` | n/a | yes | +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_log\_group\_gateway\_id](#input\_aws\_log\_group\_gateway\_id) | The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'. | `string` | n/a | yes | +| [aws\_log\_group\_region](#input\_aws\_log\_group\_region) | AWS region of the log group | `string` | n/a | yes | +| [aws\_rds\_mariadb\_admin\_email](#input\_aws\_rds\_mariadb\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_rds\_mariadb\_gateway\_id](#input\_aws\_rds\_mariadb\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_rds\_mariadb\_parent\_asset\_id](#input\_aws\_rds\_mariadb\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [aws\_rds\_mariadb\_region](#input\_aws\_rds\_mariadb\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [instance\_allocated\_storage](#input\_instance\_allocated\_storage) | The allocated storage in gibibytes. If max\_allocated\_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate\_source\_db is set, the value is ignored during the creation of the instance. | `number` | `20` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_db\_name](#input\_instance\_db\_name) | The name of the database to create when the DB instance is created. | `string` | `"testdb"` | no | +| [instance\_deletion\_protection](#input\_instance\_deletion\_protection) | If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. | `bool` | `false` | no | +| [instance\_enabled\_cloudwatch\_logs\_exports](#input\_instance\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. | `list(string)` | `null` | no | +| [instance\_engine\_version](#input\_instance\_engine\_version) | Database engine version, e.g. "8.0" | `string` | `null` | no | +| [instance\_final\_snapshot\_identifier](#input\_instance\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [instance\_identifier](#input\_instance\_identifier) | Identifier of RDS instance | `string` | n/a | yes | +| [instance\_instance\_class](#input\_instance\_instance\_class) | The instance type of the RDS instance. | `string` | `"db.t3.small"` | no | +| [instance\_max\_allocated\_storage](#input\_instance\_max\_allocated\_storage) | When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated\_storage. | `number` | `null` | no | +| [instance\_parameter\_group\_name](#input\_instance\_parameter\_group\_name) | Name of the parameter group to associate with the RDS instance. | `string` | `null` | no | +| [instance\_password](#input\_instance\_password) | Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. | `string` | n/a | yes | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. | `string` | `null` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. | `bool` | `true` | no | +| [instance\_skip\_final\_snapshot](#input\_instance\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final\_snapshot\_identifier. | `bool` | `true` | no | +| [instance\_subnet\_group\_name](#input\_instance\_subnet\_group\_name) | Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available. | `string` | n/a | yes | +| [instance\_tags](#input\_instance\_tags) | A map of tags to assign to the RDS instance. | `map(string)` | `null` | no | +| [instance\_username](#input\_instance\_username) | Username for the master DB user. | `string` | `"admin"` | no | +| [instance\_vpc\_security\_group\_ids](#input\_instance\_vpc\_security\_group\_ids) | List of VPC security groups to associate. | `list(string)` | `null` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire. | `number` | `7` | no | +| [option\_group\_description](#input\_option\_group\_description) | The description of the DB option group. | `string` | `null` | no | +| [option\_group\_major\_engine\_version](#input\_option\_group\_major\_engine\_version) | value | `any` | n/a | yes | +| [option\_group\_name](#input\_option\_group\_name) | The name of the DB option group. | `string` | n/a | yes | +| [option\_group\_options](#input\_option\_group\_options) | List of objects containing options for the DB option group. |
list(
object({
option_name = string
option_settings = optional(
list(
object({
name = string
value = string
})
),
null
)
port = optional(string, null)
version = optional(string, null)
db_security_group_memberships = optional(list(string), null)
vpc_security_group_memberships = optional(list(string), null)
})
)
| n/a | yes | +| [option\_group\_tags](#input\_option\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [aws-log-group-asset](#output\_aws-log-group-asset) | aws log group asset | +| [aws-rds-mariadb-asset](#output\_aws-rds-mariadb-asset) | aws rds mariadb asset | +| [mariadb-instance](#output\_mariadb-instance) | mariadb instance | +| [mariadb-log-group](#output\_mariadb-log-group) | mariadb log group | +| [mariadb-option-group](#output\_mariadb-option-group) | mariadb option group | + \ No newline at end of file diff --git a/modules/onboard-aws-rds-mariadb/main.tf b/modules/onboard-aws-rds-mariadb/main.tf new file mode 100644 index 0000000..71eefb4 --- /dev/null +++ b/modules/onboard-aws-rds-mariadb/main.tf @@ -0,0 +1,71 @@ +module "mariadb-option-group" { + source = "../aws-rds-option-group" + + description = var.option_group_description + engine_name = "mariadb" + major_engine_version = var.option_group_major_engine_version + name = var.option_group_name + options = var.option_group_options + tags = var.option_group_tags +} + +module "mariadb-instance" { + depends_on = [module.mariadb-log-group] + + source = "../aws-rds-instance" + + allocated_storage = var.instance_allocated_storage + apply_immediately = var.instance_apply_immediately + db_name = var.instance_db_name + deletion_protection = var.instance_deletion_protection + enabled_cloudwatch_logs_exports = var.instance_enabled_cloudwatch_logs_exports + engine = "mariadb" + engine_version = var.instance_engine_version + final_snapshot_identifier = var.instance_final_snapshot_identifier + identifier = var.instance_identifier + instance_class = var.instance_instance_class + max_allocated_storage = var.instance_max_allocated_storage + option_group_name = module.mariadb-option-group.this.id + parameter_group_name = var.instance_parameter_group_name + password = var.instance_password + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + skip_final_snapshot = var.instance_skip_final_snapshot + subnet_group_name = var.instance_subnet_group_name + tags = var.instance_tags + username = var.instance_username + vpc_security_group_ids = var.instance_vpc_security_group_ids +} + +module "mariadb-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/rds/instance/${var.instance_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "aws-rds-mariadb-asset" { + source = "../dsfhub-aws-rds-mariadb" + + admin_email = var.aws_rds_mariadb_admin_email + asset_display_name = module.mariadb-instance.this.identifier + asset_id = module.mariadb-instance.this.arn + database_name = module.mariadb-instance.this.db_name + gateway_id = var.aws_rds_mariadb_gateway_id + parent_asset_id = var.aws_rds_mariadb_parent_asset_id + region = var.aws_rds_mariadb_region + server_host_name = module.mariadb-instance.this.address + server_port = module.mariadb-instance.this.port +} + +module "aws-log-group-asset" { + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_log_group_admin_email + asset_display_name = "${module.mariadb-log-group.this.arn}:*" + asset_id = "${module.mariadb-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_log_group_gateway_id + parent_asset_id = module.aws-rds-mariadb-asset.this.asset_id + region = var.aws_log_group_region +} diff --git a/modules/onboard-aws-rds-mariadb/outputs.tf b/modules/onboard-aws-rds-mariadb/outputs.tf new file mode 100644 index 0000000..a6d06e4 --- /dev/null +++ b/modules/onboard-aws-rds-mariadb/outputs.tf @@ -0,0 +1,24 @@ +output "mariadb-option-group" { + description = "mariadb option group" + value = module.mariadb-option-group.this +} + +output "mariadb-instance" { + description = "mariadb instance" + value = module.mariadb-instance.this +} + +output "mariadb-log-group" { + description = "mariadb log group" + value = module.mariadb-log-group.this +} + +output "aws-rds-mariadb-asset" { + description = "aws rds mariadb asset" + value = module.aws-rds-mariadb-asset.this +} + +output "aws-log-group-asset" { + description = "aws log group asset" + value = module.aws-log-group-asset.this +} diff --git a/modules/onboard-aws-rds-mariadb/variables.tf b/modules/onboard-aws-rds-mariadb/variables.tf new file mode 100644 index 0000000..fdd47c6 --- /dev/null +++ b/modules/onboard-aws-rds-mariadb/variables.tf @@ -0,0 +1,201 @@ +variable "aws_rds_mariadb_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_rds_mariadb_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_rds_mariadb_parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +variable "aws_rds_mariadb_region" { + description = "AWS region containing the instance." + type = string +} + +variable "aws_log_group_admin_email" { + description = "The email address to notify about the asset." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "aws_log_group_gateway_id" { + description = "The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'." + type = string +} + +variable "aws_log_group_region" { + description = "AWS region of the log group" + type = string +} + +variable "instance_allocated_storage" { + description = "The allocated storage in gibibytes. If max_allocated_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate_source_db is set, the value is ignored during the creation of the instance." + type = number + default = 20 +} + +variable "instance_apply_immediately" { + description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_db_name" { + description = "The name of the database to create when the DB instance is created." + type = string + default = "testdb" +} + +variable "instance_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string +} + +variable "instance_deletion_protection" { + description = "If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true." + type = bool + default = false +} + +variable "instance_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported." + type = list(string) + default = null +} + +variable "instance_engine_version" { + description = "Database engine version, e.g. \"8.0\"" + type = string + default = null +} + +variable "instance_final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "instance_identifier" { + description = "Identifier of RDS instance" + type = string +} + +variable "instance_instance_class" { + description = "The instance type of the RDS instance." + type = string + default = "db.t3.small" +} + +variable "instance_max_allocated_storage" { + description = "When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated_storage." + type = number + default = null +} + +variable "instance_parameter_group_name" { + description = "Name of the parameter group to associate with the RDS instance." + type = string + default = null +} + +variable "instance_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." + type = string +} + +variable "instance_port" { + description = "The port on which the DB accepts connections." + type = string + default = null +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible." + type = bool + default = true +} + +variable "instance_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final_snapshot_identifier." + type = bool + default = true +} + +variable "instance_tags" { + description = "A map of tags to assign to the RDS instance." + type = map(string) + default = null +} + +variable "instance_username" { + description = "Username for the master DB user." + type = string + default = "admin" +} + +variable "instance_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(string) + default = null +} + +variable "log_group_retention_in_days" { + description = "Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire." + type = number + default = 7 +} + +variable "option_group_description" { + description = "The description of the DB option group." + type = string + default = null +} + +variable "option_group_major_engine_version" { + description = "value" + type = any +} + +variable "option_group_name" { + description = "The name of the DB option group." + type = string +} + +variable "option_group_options" { + description = "List of objects containing options for the DB option group." + type = list( + object({ + option_name = string + option_settings = optional( + list( + object({ + name = string + value = string + }) + ), + null + ) + port = optional(string, null) + version = optional(string, null) + db_security_group_memberships = optional(list(string), null) + vpc_security_group_memberships = optional(list(string), null) + }) + ) +} + +variable "option_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} diff --git a/modules/onboard-aws-rds-mysql-slow-query/README.md b/modules/onboard-aws-rds-mysql-slow-query/README.md new file mode 100644 index 0000000..d80db55 --- /dev/null +++ b/modules/onboard-aws-rds-mysql-slow-query/README.md @@ -0,0 +1,90 @@ +# onboard-aws-rds-mysql-slow-query +Onboard Amazon RDS for MySQL with slow query to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-log-group-audit-asset](#module\_aws-log-group-audit-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-log-group-slow-query-asset](#module\_aws-log-group-slow-query-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-rds-mysql-asset](#module\_aws-rds-mysql-asset) | ../dsfhub-aws-rds-mysql | n/a | +| [mysql-audit-log-group](#module\_mysql-audit-log-group) | ../aws-cloudwatch-log-group | n/a | +| [mysql-instance](#module\_mysql-instance) | ../aws-rds-instance | n/a | +| [mysql-option-group](#module\_mysql-option-group) | ../aws-rds-option-group | n/a | +| [mysql-parameter-group](#module\_mysql-parameter-group) | ../aws-rds-parameter-group | n/a | +| [mysql-slow-query-log-group](#module\_mysql-slow-query-log-group) | ../aws-cloudwatch-log-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_log\_group\_admin\_email](#input\_aws\_log\_group\_admin\_email) | The email address to notify about the asset. | `string` | n/a | yes | +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_log\_group\_gateway\_id](#input\_aws\_log\_group\_gateway\_id) | The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'. | `string` | n/a | yes | +| [aws\_log\_group\_region](#input\_aws\_log\_group\_region) | AWS region of the log group | `string` | n/a | yes | +| [aws\_rds\_mysql\_admin\_email](#input\_aws\_rds\_mysql\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_rds\_mysql\_audit\_type](#input\_aws\_rds\_mysql\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `"LOG_GROUP"` | no | +| [aws\_rds\_mysql\_gateway\_id](#input\_aws\_rds\_mysql\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_rds\_mysql\_parent\_asset\_id](#input\_aws\_rds\_mysql\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [aws\_rds\_mysql\_region](#input\_aws\_rds\_mysql\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [instance\_allocated\_storage](#input\_instance\_allocated\_storage) | The allocated storage in gibibytes. If max\_allocated\_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate\_source\_db is set, the value is ignored during the creation of the instance. | `number` | `20` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_db\_name](#input\_instance\_db\_name) | The name of the database to create when the DB instance is created. | `string` | `"testdb"` | no | +| [instance\_deletion\_protection](#input\_instance\_deletion\_protection) | If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. | `bool` | `false` | no | +| [instance\_enabled\_cloudwatch\_logs\_exports](#input\_instance\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. | `list(string)` |
[
"audit",
"slowquery"
]
| no | +| [instance\_engine\_version](#input\_instance\_engine\_version) | Database engine version, e.g. "8.0" | `string` | `null` | no | +| [instance\_final\_snapshot\_identifier](#input\_instance\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [instance\_identifier](#input\_instance\_identifier) | Identifier of RDS instance | `string` | n/a | yes | +| [instance\_instance\_class](#input\_instance\_instance\_class) | The instance type of the RDS instance. | `string` | `"db.t3.small"` | no | +| [instance\_max\_allocated\_storage](#input\_instance\_max\_allocated\_storage) | When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated\_storage. | `number` | `null` | no | +| [instance\_password](#input\_instance\_password) | Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. | `string` | n/a | yes | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. | `string` | `null` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. | `bool` | `true` | no | +| [instance\_skip\_final\_snapshot](#input\_instance\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final\_snapshot\_identifier. | `bool` | `true` | no | +| [instance\_subnet\_group\_name](#input\_instance\_subnet\_group\_name) | Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available. | `string` | n/a | yes | +| [instance\_tags](#input\_instance\_tags) | A map of tags to assign to the RDS instance. | `map(string)` | `null` | no | +| [instance\_username](#input\_instance\_username) | Username for the master DB user. | `string` | `"admin"` | no | +| [instance\_vpc\_security\_group\_ids](#input\_instance\_vpc\_security\_group\_ids) | List of VPC security groups to associate. | `list(string)` | `null` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire. | `number` | `7` | no | +| [option\_group\_description](#input\_option\_group\_description) | The description of the DB option group. | `string` | `null` | no | +| [option\_group\_major\_engine\_version](#input\_option\_group\_major\_engine\_version) | value | `any` | n/a | yes | +| [option\_group\_name](#input\_option\_group\_name) | The name of the DB option group. | `string` | n/a | yes | +| [option\_group\_options](#input\_option\_group\_options) | List of objects containing options for the DB option group. |
list(
object({
option_name = string
option_settings = optional(
list(
object({
name = string
value = string
})
),
null
)
port = optional(string, null)
version = optional(string, null)
db_security_group_memberships = optional(list(string), null)
vpc_security_group_memberships = optional(list(string), null)
})
)
|
[
{
"option_name": "MARIADB_AUDIT_PLUGIN",
"option_settings": [
{
"name": "SERVER_AUDIT_EVENTS",
"value": "CONNECT,QUERY,QUERY_DDL,QUERY_DML,QUERY_DCL"
},
{
"name": "SERVER_AUDIT_EXCL_USERS",
"value": "rdsadmin"
}
]
}
]
| no | +| [option\_group\_tags](#input\_option\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the DB parameter group. | `string` | `null` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the DB parameter group. For example, 'oracle-ee', 'postgres', etc. | `string` | n/a | yes | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the DB parameter group. | `string` | `null` | no | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | List of objects containing parameters for the DB parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"name": "slow_query_log",
"value": 1
},
{
"name": "long_query_time",
"value": 60
},
{
"name": "log_output",
"value": "FILE"
},
{
"name": "log_slow_admin_statements",
"value": 1
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [aws-log-group-audit-asset](#output\_aws-log-group-audit-asset) | aws log group audit asset | +| [aws-log-group-slow-query-asset](#output\_aws-log-group-slow-query-asset) | aws log group slow query asset | +| [aws-rds-mysql-asset](#output\_aws-rds-mysql-asset) | aws rds mysql asset | +| [mysql-audit-log-group](#output\_mysql-audit-log-group) | mysql audit log group | +| [mysql-instance](#output\_mysql-instance) | mysql instance | +| [mysql-option-group](#output\_mysql-option-group) | mysql option group | +| [mysql-slow-query-log-group](#output\_mysql-slow-query-log-group) | mysql slow query log group | + \ No newline at end of file diff --git a/modules/onboard-aws-rds-mysql-slow-query/main.tf b/modules/onboard-aws-rds-mysql-slow-query/main.tf new file mode 100644 index 0000000..f55c7ce --- /dev/null +++ b/modules/onboard-aws-rds-mysql-slow-query/main.tf @@ -0,0 +1,105 @@ +module "mysql-option-group" { + source = "../aws-rds-option-group" + + description = var.option_group_description + engine_name = "mysql" + major_engine_version = var.option_group_major_engine_version + name = var.option_group_name + options = var.option_group_options + tags = var.option_group_tags +} + +module "mysql-parameter-group" { + source = "../aws-rds-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "mysql-instance" { + depends_on = [module.mysql-audit-log-group, module.mysql-slow-query-log-group] + + source = "../aws-rds-instance" + + allocated_storage = var.instance_allocated_storage + apply_immediately = var.instance_apply_immediately + db_name = var.instance_db_name + deletion_protection = var.instance_deletion_protection + enabled_cloudwatch_logs_exports = var.instance_enabled_cloudwatch_logs_exports + engine = "mysql" + engine_version = var.instance_engine_version + final_snapshot_identifier = var.instance_final_snapshot_identifier + identifier = var.instance_identifier + instance_class = var.instance_instance_class + max_allocated_storage = var.instance_max_allocated_storage + option_group_name = module.mysql-option-group.this.id + parameter_group_name = module.mysql-parameter-group.this.name + password = var.instance_password + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + skip_final_snapshot = var.instance_skip_final_snapshot + subnet_group_name = var.instance_subnet_group_name + tags = var.instance_tags + username = var.instance_username + vpc_security_group_ids = var.instance_vpc_security_group_ids +} + +module "mysql-audit-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/rds/instance/${var.instance_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "mysql-slow-query-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/rds/instance/${var.instance_identifier}/slowquery" + retention_in_days = var.log_group_retention_in_days +} + +module "aws-rds-mysql-asset" { + source = "../dsfhub-aws-rds-mysql" + + admin_email = var.aws_rds_mysql_admin_email + asset_display_name = module.mysql-instance.this.identifier + asset_id = module.mysql-instance.this.arn + audit_type = var.aws_rds_mysql_audit_type + database_name = module.mysql-instance.this.db_name + gateway_id = var.aws_rds_mysql_gateway_id + parent_asset_id = var.aws_rds_mysql_parent_asset_id + region = var.aws_rds_mysql_region + server_host_name = module.mysql-instance.this.address + server_port = module.mysql-instance.this.port +} + +module "aws-log-group-audit-asset" { + depends_on = [module.aws-rds-mysql-asset] + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_log_group_admin_email + asset_display_name = "${module.mysql-audit-log-group.this.arn}:*" + asset_id = "${module.mysql-audit-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_log_group_gateway_id + parent_asset_id = module.aws-rds-mysql-asset.this.asset_id + region = var.aws_log_group_region +} + +module "aws-log-group-slow-query-asset" { + depends_on = [module.aws-log-group-audit-asset] + + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_log_group_admin_email + asset_display_name = "${module.mysql-slow-query-log-group.this.arn}:*" + asset_id = "${module.mysql-slow-query-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + audit_type = "AWS_RDS_MYSQL_SLOW" + gateway_id = var.aws_log_group_gateway_id + parent_asset_id = module.aws-rds-mysql-asset.this.asset_id + region = var.aws_log_group_region +} diff --git a/modules/onboard-aws-rds-mysql-slow-query/outputs.tf b/modules/onboard-aws-rds-mysql-slow-query/outputs.tf new file mode 100644 index 0000000..0322239 --- /dev/null +++ b/modules/onboard-aws-rds-mysql-slow-query/outputs.tf @@ -0,0 +1,34 @@ +output "mysql-option-group" { + description = "mysql option group" + value = module.mysql-option-group.this +} + +output "mysql-instance" { + description = "mysql instance" + value = module.mysql-instance.this +} + +output "mysql-audit-log-group" { + description = "mysql audit log group" + value = module.mysql-audit-log-group.this +} + +output "mysql-slow-query-log-group" { + description = "mysql slow query log group" + value = module.mysql-slow-query-log-group.this +} + +output "aws-rds-mysql-asset" { + description = "aws rds mysql asset" + value = module.aws-rds-mysql-asset.this +} + +output "aws-log-group-audit-asset" { + description = "aws log group audit asset" + value = module.aws-log-group-audit-asset.this +} + +output "aws-log-group-slow-query-asset" { + description = "aws log group slow query asset" + value = module.aws-log-group-slow-query-asset.this +} diff --git a/modules/onboard-aws-rds-mysql-slow-query/variables.tf b/modules/onboard-aws-rds-mysql-slow-query/variables.tf new file mode 100644 index 0000000..a24bead --- /dev/null +++ b/modules/onboard-aws-rds-mysql-slow-query/variables.tf @@ -0,0 +1,272 @@ +variable "aws_log_group_admin_email" { + description = "The email address to notify about the asset." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "aws_log_group_gateway_id" { + description = "The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'." + type = string +} + +variable "aws_log_group_region" { + description = "AWS region of the log group" + type = string +} + +variable "aws_rds_mysql_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_rds_mysql_audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = "LOG_GROUP" + validation { + condition = contains(["LOG_GROUP", "AGGREGATED"], var.aws_rds_mysql_audit_type) + error_message = "Invalid auth mechanism. Pick either LOG_GROUP, or AGGREGATED." + } +} + +variable "aws_rds_mysql_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_rds_mysql_parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +variable "aws_rds_mysql_region" { + description = "AWS region containing the instance." + type = string +} + +variable "instance_allocated_storage" { + description = "The allocated storage in gibibytes. If max_allocated_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate_source_db is set, the value is ignored during the creation of the instance." + type = number + default = 20 +} + +variable "instance_apply_immediately" { + description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_db_name" { + description = "The name of the database to create when the DB instance is created." + type = string + default = "testdb" +} + +variable "instance_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string +} + +variable "instance_deletion_protection" { + description = "If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true." + type = bool + default = false +} + +variable "instance_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported." + type = list(string) + default = ["audit", "slowquery"] +} + +variable "instance_engine_version" { + description = "Database engine version, e.g. \"8.0\"" + type = string + default = null +} + +variable "instance_final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "instance_identifier" { + description = "Identifier of RDS instance" + type = string +} + +variable "instance_instance_class" { + description = "The instance type of the RDS instance." + type = string + default = "db.t3.small" +} + +variable "instance_max_allocated_storage" { + description = "When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated_storage." + type = number + default = null +} + +variable "instance_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." + type = string +} + +variable "instance_port" { + description = "The port on which the DB accepts connections." + type = string + default = null +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible." + type = bool + default = true +} + +variable "instance_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final_snapshot_identifier." + type = bool + default = true +} + +variable "instance_tags" { + description = "A map of tags to assign to the RDS instance." + type = map(string) + default = null +} + +variable "instance_username" { + description = "Username for the master DB user." + type = string + default = "admin" +} + +variable "instance_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(string) + default = null +} + +variable "log_group_retention_in_days" { + description = "Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire." + type = number + default = 7 +} + +variable "option_group_description" { + description = "The description of the DB option group." + type = string + default = null +} + +variable "option_group_major_engine_version" { + description = "value" + type = any +} + +variable "option_group_name" { + description = "The name of the DB option group." + type = string +} + +variable "option_group_options" { + description = "List of objects containing options for the DB option group." + type = list( + object({ + option_name = string + option_settings = optional( + list( + object({ + name = string + value = string + }) + ), + null + ) + port = optional(string, null) + version = optional(string, null) + db_security_group_memberships = optional(list(string), null) + vpc_security_group_memberships = optional(list(string), null) + }) + ) + default = [ + { + option_name = "MARIADB_AUDIT_PLUGIN" + option_settings = [ + { + name = "SERVER_AUDIT_EVENTS" + value = "CONNECT,QUERY,QUERY_DDL,QUERY_DML,QUERY_DCL" + }, + { + name = "SERVER_AUDIT_EXCL_USERS" + value = "rdsadmin" + } + ] + } + ] +} + +variable "option_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +variable "parameter_group_description" { + description = "The description of the DB parameter group." + type = string + default = null +} + +variable "parameter_group_family" { + description = "The family of the DB parameter group. For example, 'oracle-ee', 'postgres', etc." + type = string +} + +variable "parameter_group_name" { + description = "The name of the DB parameter group." + type = string + default = null +} + +variable "parameter_group_parameters" { + description = "List of objects containing parameters for the DB parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [ + { + name = "slow_query_log" + value = 1 + }, + { + name = "long_query_time" + value = 60 + }, + { + name = "log_output" + value = "FILE" + }, + { + name = "log_slow_admin_statements" + value = 1 + }, + ] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} \ No newline at end of file diff --git a/modules/onboard-aws-rds-mysql/README.md b/modules/onboard-aws-rds-mysql/README.md new file mode 100644 index 0000000..1871367 --- /dev/null +++ b/modules/onboard-aws-rds-mysql/README.md @@ -0,0 +1,81 @@ +# onboard-aws-rds-mysql +Onboard Amazon RDS for MySQL to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-log-group-asset](#module\_aws-log-group-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-rds-mysql-asset](#module\_aws-rds-mysql-asset) | ../dsfhub-aws-rds-mysql | n/a | +| [mysql-instance](#module\_mysql-instance) | ../aws-rds-instance | n/a | +| [mysql-log-group](#module\_mysql-log-group) | ../aws-cloudwatch-log-group | n/a | +| [mysql-option-group](#module\_mysql-option-group) | ../aws-rds-option-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_log\_group\_admin\_email](#input\_aws\_log\_group\_admin\_email) | The email address to notify about the asset. | `string` | n/a | yes | +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_log\_group\_gateway\_id](#input\_aws\_log\_group\_gateway\_id) | The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'. | `string` | n/a | yes | +| [aws\_log\_group\_region](#input\_aws\_log\_group\_region) | AWS region of the log group | `string` | n/a | yes | +| [aws\_rds\_mysql\_admin\_email](#input\_aws\_rds\_mysql\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_rds\_mysql\_audit\_type](#input\_aws\_rds\_mysql\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `"LOG_GROUP"` | no | +| [aws\_rds\_mysql\_gateway\_id](#input\_aws\_rds\_mysql\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_rds\_mysql\_parent\_asset\_id](#input\_aws\_rds\_mysql\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [aws\_rds\_mysql\_region](#input\_aws\_rds\_mysql\_region) | AWS region containing the instance. | `string` | n/a | yes | +| [instance\_allocated\_storage](#input\_instance\_allocated\_storage) | The allocated storage in gibibytes. If max\_allocated\_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate\_source\_db is set, the value is ignored during the creation of the instance. | `number` | `20` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_db\_name](#input\_instance\_db\_name) | The name of the database to create when the DB instance is created. | `string` | `"testdb"` | no | +| [instance\_deletion\_protection](#input\_instance\_deletion\_protection) | If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. | `bool` | `false` | no | +| [instance\_enabled\_cloudwatch\_logs\_exports](#input\_instance\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. | `list(string)` |
[
"audit"
]
| no | +| [instance\_engine\_version](#input\_instance\_engine\_version) | Database engine version, e.g. "8.0" | `string` | `null` | no | +| [instance\_final\_snapshot\_identifier](#input\_instance\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [instance\_identifier](#input\_instance\_identifier) | Identifier of RDS instance | `string` | n/a | yes | +| [instance\_instance\_class](#input\_instance\_instance\_class) | The instance type of the RDS instance. | `string` | `"db.t3.small"` | no | +| [instance\_max\_allocated\_storage](#input\_instance\_max\_allocated\_storage) | When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated\_storage. | `number` | `null` | no | +| [instance\_parameter\_group\_name](#input\_instance\_parameter\_group\_name) | Name of the parameter group to associate with the RDS instance. | `string` | `null` | no | +| [instance\_password](#input\_instance\_password) | Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. | `string` | n/a | yes | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. | `string` | `null` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. | `bool` | `true` | no | +| [instance\_skip\_final\_snapshot](#input\_instance\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final\_snapshot\_identifier. | `bool` | `true` | no | +| [instance\_subnet\_group\_name](#input\_instance\_subnet\_group\_name) | Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available. | `string` | n/a | yes | +| [instance\_tags](#input\_instance\_tags) | A map of tags to assign to the RDS instance. | `map(string)` | `null` | no | +| [instance\_username](#input\_instance\_username) | Username for the master DB user. | `string` | `"admin"` | no | +| [instance\_vpc\_security\_group\_ids](#input\_instance\_vpc\_security\_group\_ids) | List of VPC security groups to associate. | `list(string)` | `null` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire. | `number` | `7` | no | +| [option\_group\_description](#input\_option\_group\_description) | The description of the DB option group. | `string` | `null` | no | +| [option\_group\_major\_engine\_version](#input\_option\_group\_major\_engine\_version) | value | `any` | n/a | yes | +| [option\_group\_name](#input\_option\_group\_name) | The name of the DB option group. | `string` | n/a | yes | +| [option\_group\_options](#input\_option\_group\_options) | List of objects containing options for the DB option group. |
list(
object({
option_name = string
option_settings = optional(
list(
object({
name = string
value = string
})
),
null
)
port = optional(string, null)
version = optional(string, null)
db_security_group_memberships = optional(list(string), null)
vpc_security_group_memberships = optional(list(string), null)
})
)
|
[
{
"option_name": "MARIADB_AUDIT_PLUGIN",
"option_settings": [
{
"name": "SERVER_AUDIT_EVENTS",
"value": "CONNECT,QUERY,QUERY_DDL,QUERY_DML,QUERY_DCL"
},
{
"name": "SERVER_AUDIT_EXCL_USERS",
"value": "rdsadmin"
}
]
}
]
| no | +| [option\_group\_tags](#input\_option\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [aws-log-group-asset](#output\_aws-log-group-asset) | aws log group asset | +| [aws-rds-mysql-asset](#output\_aws-rds-mysql-asset) | aws rds mysql asset | +| [mysql-instance](#output\_mysql-instance) | mysql instance | +| [mysql-log-group](#output\_mysql-log-group) | mysql log group | +| [mysql-option-group](#output\_mysql-option-group) | mysql option group | + \ No newline at end of file diff --git a/modules/onboard-aws-rds-mysql/main.tf b/modules/onboard-aws-rds-mysql/main.tf new file mode 100644 index 0000000..a90429a --- /dev/null +++ b/modules/onboard-aws-rds-mysql/main.tf @@ -0,0 +1,72 @@ +module "mysql-option-group" { + source = "../aws-rds-option-group" + + description = var.option_group_description + engine_name = "mysql" + major_engine_version = var.option_group_major_engine_version + name = var.option_group_name + options = var.option_group_options + tags = var.option_group_tags +} + +module "mysql-instance" { + depends_on = [module.mysql-log-group] + + source = "../aws-rds-instance" + + allocated_storage = var.instance_allocated_storage + apply_immediately = var.instance_apply_immediately + db_name = var.instance_db_name + deletion_protection = var.instance_deletion_protection + enabled_cloudwatch_logs_exports = var.instance_enabled_cloudwatch_logs_exports + engine = "mysql" + engine_version = var.instance_engine_version + final_snapshot_identifier = var.instance_final_snapshot_identifier + identifier = var.instance_identifier + instance_class = var.instance_instance_class + max_allocated_storage = var.instance_max_allocated_storage + option_group_name = module.mysql-option-group.this.id + parameter_group_name = var.instance_parameter_group_name + password = var.instance_password + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + skip_final_snapshot = var.instance_skip_final_snapshot + subnet_group_name = var.instance_subnet_group_name + tags = var.instance_tags + username = var.instance_username + vpc_security_group_ids = var.instance_vpc_security_group_ids +} + +module "mysql-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/rds/instance/${var.instance_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "aws-rds-mysql-asset" { + source = "../dsfhub-aws-rds-mysql" + + admin_email = var.aws_rds_mysql_admin_email + asset_display_name = module.mysql-instance.this.identifier + asset_id = module.mysql-instance.this.arn + audit_type = var.aws_rds_mysql_audit_type + database_name = module.mysql-instance.this.db_name + gateway_id = var.aws_rds_mysql_gateway_id + parent_asset_id = var.aws_rds_mysql_parent_asset_id + region = var.aws_rds_mysql_region + server_host_name = module.mysql-instance.this.address + server_port = module.mysql-instance.this.port +} + +module "aws-log-group-asset" { + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_log_group_admin_email + asset_display_name = "${module.mysql-log-group.this.arn}:*" + asset_id = "${module.mysql-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_log_group_gateway_id + parent_asset_id = module.aws-rds-mysql-asset.this.asset_id + region = var.aws_log_group_region +} diff --git a/modules/onboard-aws-rds-mysql/outputs.tf b/modules/onboard-aws-rds-mysql/outputs.tf new file mode 100644 index 0000000..f86a84b --- /dev/null +++ b/modules/onboard-aws-rds-mysql/outputs.tf @@ -0,0 +1,24 @@ +output "mysql-option-group" { + description = "mysql option group" + value = module.mysql-option-group.this +} + +output "mysql-instance" { + description = "mysql instance" + value = module.mysql-instance.this +} + +output "mysql-log-group" { + description = "mysql log group" + value = module.mysql-log-group.this +} + +output "aws-rds-mysql-asset" { + description = "aws rds mysql asset" + value = module.aws-rds-mysql-asset.this +} + +output "aws-log-group-asset" { + description = "aws log group asset" + value = module.aws-log-group-asset.this +} diff --git a/modules/onboard-aws-rds-mysql/variables.tf b/modules/onboard-aws-rds-mysql/variables.tf new file mode 100644 index 0000000..ea5cd25 --- /dev/null +++ b/modules/onboard-aws-rds-mysql/variables.tf @@ -0,0 +1,226 @@ +variable "aws_log_group_admin_email" { + description = "The email address to notify about the asset." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "aws_log_group_gateway_id" { + description = "The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'." + type = string +} + +variable "aws_log_group_region" { + description = "AWS region of the log group" + type = string +} + +variable "aws_rds_mysql_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_rds_mysql_audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = "LOG_GROUP" + validation { + condition = contains(["LOG_GROUP", "AGGREGATED"], var.aws_rds_mysql_audit_type) + error_message = "Invalid auth mechanism. Pick either LOG_GROUP, or AGGREGATED." + } +} + +variable "aws_rds_mysql_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_rds_mysql_parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +variable "aws_rds_mysql_region" { + description = "AWS region containing the instance." + type = string +} + +variable "instance_allocated_storage" { + description = "The allocated storage in gibibytes. If max_allocated_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate_source_db is set, the value is ignored during the creation of the instance." + type = number + default = 20 +} + +variable "instance_apply_immediately" { + description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_db_name" { + description = "The name of the database to create when the DB instance is created." + type = string + default = "testdb" +} + +variable "instance_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string +} + +variable "instance_deletion_protection" { + description = "If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true." + type = bool + default = false +} + +variable "instance_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported." + type = list(string) + default = ["audit"] +} + +variable "instance_engine_version" { + description = "Database engine version, e.g. \"8.0\"" + type = string + default = null +} + +variable "instance_final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "instance_identifier" { + description = "Identifier of RDS instance" + type = string +} + +variable "instance_instance_class" { + description = "The instance type of the RDS instance." + type = string + default = "db.t3.small" +} + +variable "instance_max_allocated_storage" { + description = "When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated_storage." + type = number + default = null +} + +variable "instance_parameter_group_name" { + description = "Name of the parameter group to associate with the RDS instance." + type = string + default = null +} + +variable "instance_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." + type = string +} + +variable "instance_port" { + description = "The port on which the DB accepts connections." + type = string + default = null +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible." + type = bool + default = true +} + +variable "instance_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final_snapshot_identifier." + type = bool + default = true +} + +variable "instance_tags" { + description = "A map of tags to assign to the RDS instance." + type = map(string) + default = null +} + +variable "instance_username" { + description = "Username for the master DB user." + type = string + default = "admin" +} + +variable "instance_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(string) + default = null +} + +variable "log_group_retention_in_days" { + description = "Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire." + type = number + default = 7 +} + +variable "option_group_description" { + description = "The description of the DB option group." + type = string + default = null +} + +variable "option_group_major_engine_version" { + description = "value" + type = any +} + +variable "option_group_name" { + description = "The name of the DB option group." + type = string +} + +variable "option_group_options" { + description = "List of objects containing options for the DB option group." + type = list( + object({ + option_name = string + option_settings = optional( + list( + object({ + name = string + value = string + }) + ), + null + ) + port = optional(string, null) + version = optional(string, null) + db_security_group_memberships = optional(list(string), null) + vpc_security_group_memberships = optional(list(string), null) + }) + ) + default = [ + { + option_name = "MARIADB_AUDIT_PLUGIN" + option_settings = [ + { + name = "SERVER_AUDIT_EVENTS" + value = "CONNECT,QUERY,QUERY_DDL,QUERY_DML,QUERY_DCL" + }, + { + name = "SERVER_AUDIT_EXCL_USERS" + value = "rdsadmin" + } + ] + } + ] +} + +variable "option_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} diff --git a/modules/onboard-aws-rds-oracle-standard/README.md b/modules/onboard-aws-rds-oracle-standard/README.md new file mode 100644 index 0000000..1108020 --- /dev/null +++ b/modules/onboard-aws-rds-oracle-standard/README.md @@ -0,0 +1,82 @@ +# onboard-aws-rds-oracle-standard +Onboard Amazon RDS for Oracle (Standard Audit via CloudWatch) to DSF Hub. + +## Notes +There are two prerequisites for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. +2. A method to create an audit policy on the Oracle instance. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-log-group-asset](#module\_aws-log-group-asset) | ../dsfhub-aws-log-group | n/a | +| [aws-rds-oracle-asset](#module\_aws-rds-oracle-asset) | ../dsfhub-aws-rds-oracle | n/a | +| [oracle-instance](#module\_oracle-instance) | ../aws-rds-instance | n/a | +| [oracle-log-group](#module\_oracle-log-group) | ../aws-cloudwatch-log-group | n/a | +| [oracle-parameter-group](#module\_oracle-parameter-group) | ../aws-rds-parameter-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_log\_group\_admin\_email](#input\_aws\_log\_group\_admin\_email) | The email address to notify about the asset. | `string` | n/a | yes | +| [aws\_log\_group\_audit\_pull\_enabled](#input\_aws\_log\_group\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_log\_group\_gateway\_id](#input\_aws\_log\_group\_gateway\_id) | The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'. | `string` | n/a | yes | +| [aws\_log\_group\_region](#input\_aws\_log\_group\_region) | AWS region of the log group | `string` | n/a | yes | +| [aws\_rds\_oracle\_admin\_email](#input\_aws\_rds\_oracle\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_rds\_oracle\_audit\_type](#input\_aws\_rds\_oracle\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `"LOG_GROUP"` | no | +| [aws\_rds\_oracle\_gateway\_id](#input\_aws\_rds\_oracle\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_rds\_oracle\_parent\_asset\_id](#input\_aws\_rds\_oracle\_parent\_asset\_id) | The asset\_id that contains this asset (e.g. Asset ID of the database sending audit events) | `string` | n/a | yes | +| [aws\_rds\_oracle\_region](#input\_aws\_rds\_oracle\_region) | AWS region containing the instance. | `string` | `null` | no | +| [instance\_allocated\_storage](#input\_instance\_allocated\_storage) | The allocated storage in gibibytes. If max\_allocated\_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate\_source\_db is set, the value is ignored during the creation of the instance. | `number` | `20` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_db\_name](#input\_instance\_db\_name) | The Oracle System ID (SID) of the created RDS Custom DB instance. | `string` | `"ORCL"` | no | +| [instance\_deletion\_protection](#input\_instance\_deletion\_protection) | If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. | `bool` | `false` | no | +| [instance\_enabled\_cloudwatch\_logs\_exports](#input\_instance\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. | `list(string)` |
[
"audit"
]
| no | +| [instance\_engine\_version](#input\_instance\_engine\_version) | Database engine version, e.g. "8.0" | `string` | `null` | no | +| [instance\_final\_snapshot\_identifier](#input\_instance\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [instance\_identifier](#input\_instance\_identifier) | Identifier of RDS instance | `string` | n/a | yes | +| [instance\_instance\_class](#input\_instance\_instance\_class) | The instance type of the RDS instance. | `string` | `"db.t3.small"` | no | +| [instance\_max\_allocated\_storage](#input\_instance\_max\_allocated\_storage) | When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated\_storage. | `number` | `null` | no | +| [instance\_option\_group\_name](#input\_instance\_option\_group\_name) | Name of the option group to associate with the RDS instance. | `string` | `null` | no | +| [instance\_password](#input\_instance\_password) | Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. | `string` | n/a | yes | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. | `string` | `null` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. | `bool` | `true` | no | +| [instance\_skip\_final\_snapshot](#input\_instance\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final\_snapshot\_identifier. | `bool` | `true` | no | +| [instance\_subnet\_group\_name](#input\_instance\_subnet\_group\_name) | Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available. | `string` | n/a | yes | +| [instance\_tags](#input\_instance\_tags) | A map of tags to assign to the RDS instance. | `map(string)` | `null` | no | +| [instance\_username](#input\_instance\_username) | Username for the master DB user. | `string` | `"admin"` | no | +| [instance\_vpc\_security\_group\_ids](#input\_instance\_vpc\_security\_group\_ids) | List of VPC security groups to associate. | `list(string)` | `null` | no | +| [log\_group\_retention\_in\_days](#input\_log\_group\_retention\_in\_days) | Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire. | `number` | `7` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the DB parameter group. | `string` | `null` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the DB parameter group. For example, 'oracle-ee', 'postgres', etc. | `string` | n/a | yes | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the DB parameter group. | `string` | `null` | no | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | List of objects containing parameters for the DB parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"apply_method": "pending-reboot",
"name": "audit_trail",
"value": "OS"
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [aws-log-group-asset](#output\_aws-log-group-asset) | aws log group asset | +| [aws-rds-oracle-asset](#output\_aws-rds-oracle-asset) | aws rds oracle asset | +| [oracle-instance](#output\_oracle-instance) | oracle instance | +| [oracle-log-group](#output\_oracle-log-group) | value | +| [oracle-parameter-group](#output\_oracle-parameter-group) | oracle parameter group | + \ No newline at end of file diff --git a/modules/onboard-aws-rds-oracle-standard/main.tf b/modules/onboard-aws-rds-oracle-standard/main.tf new file mode 100644 index 0000000..5b0dfcd --- /dev/null +++ b/modules/onboard-aws-rds-oracle-standard/main.tf @@ -0,0 +1,69 @@ +module "oracle-parameter-group" { + source = "../aws-rds-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "oracle-instance" { + source = "../aws-rds-instance" + + allocated_storage = var.instance_allocated_storage + apply_immediately = var.instance_apply_immediately + db_name = var.instance_db_name + deletion_protection = var.instance_deletion_protection + enabled_cloudwatch_logs_exports = var.instance_enabled_cloudwatch_logs_exports + engine = "oracle-ee" + engine_version = var.instance_engine_version + final_snapshot_identifier = var.instance_final_snapshot_identifier + identifier = var.instance_identifier + instance_class = var.instance_instance_class + max_allocated_storage = var.instance_max_allocated_storage + option_group_name = var.instance_option_group_name + parameter_group_name = module.oracle-parameter-group.this.id + password = var.instance_password + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + skip_final_snapshot = var.instance_skip_final_snapshot + subnet_group_name = var.instance_subnet_group_name + tags = var.instance_tags + username = var.instance_username + vpc_security_group_ids = var.instance_vpc_security_group_ids +} + +module "oracle-log-group" { + source = "../aws-cloudwatch-log-group" + + name = "/aws/rds/instance/${var.instance_identifier}/audit" + retention_in_days = var.log_group_retention_in_days +} + +module "aws-rds-oracle-asset" { + source = "../dsfhub-aws-rds-oracle" + + admin_email = var.aws_rds_oracle_admin_email + asset_display_name = module.oracle-instance.this.identifier + asset_id = module.oracle-instance.this.arn + audit_type = var.aws_rds_oracle_audit_type + gateway_id = var.aws_rds_oracle_gateway_id + parent_asset_id = var.aws_rds_oracle_parent_asset_id + region = var.aws_rds_oracle_region + server_host_name = module.oracle-instance.this.address + server_port = module.oracle-instance.this.port + service_name = module.oracle-instance.this.db_name +} + +module "aws-log-group-asset" { + source = "../dsfhub-aws-log-group" + + admin_email = var.aws_log_group_admin_email + asset_display_name = "${module.oracle-log-group.this.arn}:*" + asset_id = "${module.oracle-log-group.this.arn}:*" + audit_pull_enabled = var.aws_log_group_audit_pull_enabled + gateway_id = var.aws_log_group_gateway_id + parent_asset_id = module.aws-rds-oracle-asset.this.asset_id + region = var.aws_log_group_region +} diff --git a/modules/onboard-aws-rds-oracle-standard/outputs.tf b/modules/onboard-aws-rds-oracle-standard/outputs.tf new file mode 100644 index 0000000..d37d8cc --- /dev/null +++ b/modules/onboard-aws-rds-oracle-standard/outputs.tf @@ -0,0 +1,24 @@ +output "oracle-parameter-group" { + description = "oracle parameter group" + value = module.oracle-parameter-group.this +} + +output "oracle-instance" { + description = "oracle instance" + value = module.oracle-instance.this +} + +output "oracle-log-group" { + description = "value" + value = module.oracle-log-group.this +} + +output "aws-rds-oracle-asset" { + description = "aws rds oracle asset" + value = module.aws-rds-oracle-asset.this +} + +output "aws-log-group-asset" { + description = "aws log group asset" + value = module.aws-log-group-asset.this +} diff --git a/modules/onboard-aws-rds-oracle-standard/variables.tf b/modules/onboard-aws-rds-oracle-standard/variables.tf new file mode 100644 index 0000000..cb0b460 --- /dev/null +++ b/modules/onboard-aws-rds-oracle-standard/variables.tf @@ -0,0 +1,209 @@ +variable "aws_log_group_admin_email" { + description = "The email address to notify about the asset." + type = string +} + +variable "aws_log_group_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "aws_log_group_gateway_id" { + description = "The jsonarUid unique identifier of the agentless gateway. Example: '7a4af7cf-4292-89d9-46ec-183756ksdjd'." + type = string +} + +variable "aws_log_group_region" { + description = "AWS region of the log group" + type = string +} + +variable "aws_rds_oracle_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_rds_oracle_audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = "LOG_GROUP" + validation { + condition = contains(["LOG_GROUP", "AGGREGATED"], var.aws_rds_oracle_audit_type) + error_message = "Invalid Value. Select from LOG_GROUP, or AGGREGATED." + } +} + +variable "aws_rds_oracle_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_rds_oracle_parent_asset_id" { + description = "The asset_id that contains this asset (e.g. Asset ID of the database sending audit events)" + type = string +} + +variable "aws_rds_oracle_region" { + description = "AWS region containing the instance." + type = string + default = null +} + +variable "log_group_retention_in_days" { + description = "Specifies the number of days you want to retain log events in the specified log group. If you select 0, the events in the log group are always retained and never expire." + type = number + default = 7 +} + +variable "parameter_group_description" { + description = "The description of the DB parameter group." + type = string + default = null +} + +variable "parameter_group_family" { + description = "The family of the DB parameter group. For example, 'oracle-ee', 'postgres', etc." + type = string +} + +variable "parameter_group_name" { + description = "The name of the DB parameter group." + type = string + default = null +} + +variable "parameter_group_parameters" { + description = "List of objects containing parameters for the DB parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [ + { + name = "audit_trail" + value = "OS" + apply_method = "pending-reboot" + } + ] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +variable "instance_allocated_storage" { + description = "The allocated storage in gibibytes. If max_allocated_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate_source_db is set, the value is ignored during the creation of the instance." + type = number + default = 20 +} + +variable "instance_apply_immediately" { + description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_db_name" { + description = "The Oracle System ID (SID) of the created RDS Custom DB instance." + type = string + default = "ORCL" +} + +variable "instance_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string +} + +variable "instance_deletion_protection" { + description = "If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true." + type = bool + default = false +} + +variable "instance_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported." + type = list(string) + default = ["audit"] +} + +variable "instance_engine_version" { + description = "Database engine version, e.g. \"8.0\"" + type = string + default = null +} + +variable "instance_final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "instance_identifier" { + description = "Identifier of RDS instance" + type = string +} + +variable "instance_instance_class" { + description = "The instance type of the RDS instance." + type = string + default = "db.t3.small" +} + +variable "instance_max_allocated_storage" { + description = "When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated_storage." + type = number + default = null +} + +variable "instance_option_group_name" { + description = "Name of the option group to associate with the RDS instance." + type = string + default = null +} + +variable "instance_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." + type = string +} + +variable "instance_port" { + description = "The port on which the DB accepts connections." + type = string + default = null +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible." + type = bool + default = true +} + +variable "instance_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final_snapshot_identifier." + type = bool + default = true +} + +variable "instance_tags" { + description = "A map of tags to assign to the RDS instance." + type = map(string) + default = null +} + +variable "instance_username" { + description = "Username for the master DB user." + type = string + default = "admin" +} + +variable "instance_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(string) + default = null +} diff --git a/modules/onboard-aws-rds-oracle-unified/README.md b/modules/onboard-aws-rds-oracle-unified/README.md new file mode 100644 index 0000000..dff850a --- /dev/null +++ b/modules/onboard-aws-rds-oracle-unified/README.md @@ -0,0 +1,80 @@ +# onboard-aws-rds-oracle-unified +Onboard Amazon RDS for Oracle (Unified Audit) to DSF Hub. + +## Notes +There are two prerequisites for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from CloudWatch log groups. +2. A method to create an audit pull user, as well as an audit policy on the Oracle instance. + +See the corresponding example for more details. + + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [aws-rds-oracle-asset](#module\_aws-rds-oracle-asset) | ../dsfhub-aws-rds-oracle | n/a | +| [oracle-instance](#module\_oracle-instance) | ../aws-rds-instance | n/a | +| [oracle-parameter-group](#module\_oracle-parameter-group) | ../aws-rds-parameter-group | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_rds\_oracle\_admin\_email](#input\_aws\_rds\_oracle\_admin\_email) | The email address to notify about this asset | `string` | n/a | yes | +| [aws\_rds\_oracle\_audit\_pull\_enabled](#input\_aws\_rds\_oracle\_audit\_pull\_enabled) | If true, sonargateway will collect the audit logs for this system if it can. | `bool` | `false` | no | +| [aws\_rds\_oracle\_audit\_type](#input\_aws\_rds\_oracle\_audit\_type) | Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details | `string` | `"UNIFIED"` | no | +| [aws\_rds\_oracle\_auth\_mechanism](#input\_aws\_rds\_oracle\_auth\_mechanism) | Specifies the auth mechanism used by the connection | `string` | `"password"` | no | +| [aws\_rds\_oracle\_dsn](#input\_aws\_rds\_oracle\_dsn) | Datasource name to use in odbc.ini. If using the asset for SDM, keep a dummy DSN value. | `string` | `null` | no | +| [aws\_rds\_oracle\_gateway\_id](#input\_aws\_rds\_oracle\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the asset | `string` | n/a | yes | +| [aws\_rds\_oracle\_password](#input\_aws\_rds\_oracle\_password) | Password to use to connect to Oracle database. Must not include semicolons. | `string` | n/a | yes | +| [aws\_rds\_oracle\_reason](#input\_aws\_rds\_oracle\_reason) | Used to differentiate connections that belong to the same asset | `string` | `"default"` | no | +| [aws\_rds\_oracle\_region](#input\_aws\_rds\_oracle\_region) | AWS region containing the instance. | `string` | `null` | no | +| [aws\_rds\_oracle\_username](#input\_aws\_rds\_oracle\_username) | Username to use to connect to Oracle database. | `string` | n/a | yes | +| [aws\_rds\_oracle\_wallet\_dir](#input\_aws\_rds\_oracle\_wallet\_dir) | Path to the Oracle wallet directory | `string` | `null` | no | +| [instance\_allocated\_storage](#input\_instance\_allocated\_storage) | The allocated storage in gibibytes. If max\_allocated\_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate\_source\_db is set, the value is ignored during the creation of the instance. | `number` | `20` | no | +| [instance\_apply\_immediately](#input\_instance\_apply\_immediately) | Specifies whether any database modifications are applied immediately, or during the next maintenance window. | `bool` | `true` | no | +| [instance\_db\_name](#input\_instance\_db\_name) | The Oracle System ID (SID) of the created RDS Custom DB instance. | `string` | `"ORCL"` | no | +| [instance\_deletion\_protection](#input\_instance\_deletion\_protection) | If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true. | `bool` | `false` | no | +| [instance\_enabled\_cloudwatch\_logs\_exports](#input\_instance\_enabled\_cloudwatch\_logs\_exports) | Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported. | `list(string)` | `null` | no | +| [instance\_engine\_version](#input\_instance\_engine\_version) | Database engine version, e.g. "8.0" | `string` | `null` | no | +| [instance\_final\_snapshot\_identifier](#input\_instance\_final\_snapshot\_identifier) | The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip\_final\_snapshot is set to false. | `string` | `null` | no | +| [instance\_identifier](#input\_instance\_identifier) | Identifier of RDS instance | `string` | n/a | yes | +| [instance\_instance\_class](#input\_instance\_instance\_class) | The instance type of the RDS instance. | `string` | `"db.t3.small"` | no | +| [instance\_max\_allocated\_storage](#input\_instance\_max\_allocated\_storage) | When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated\_storage. | `number` | `null` | no | +| [instance\_option\_group\_name](#input\_instance\_option\_group\_name) | Name of the option group to associate with the RDS instance. | `string` | `null` | no | +| [instance\_password](#input\_instance\_password) | Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file. | `string` | n/a | yes | +| [instance\_port](#input\_instance\_port) | The port on which the DB accepts connections. | `string` | `null` | no | +| [instance\_publicly\_accessible](#input\_instance\_publicly\_accessible) | Bool to control if instance is publicly accessible. | `bool` | `true` | no | +| [instance\_skip\_final\_snapshot](#input\_instance\_skip\_final\_snapshot) | Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final\_snapshot\_identifier. | `bool` | `true` | no | +| [instance\_subnet\_group\_name](#input\_instance\_subnet\_group\_name) | Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available. | `string` | n/a | yes | +| [instance\_tags](#input\_instance\_tags) | A map of tags to assign to the RDS instance. | `map(string)` | `null` | no | +| [instance\_username](#input\_instance\_username) | Username for the master DB user. | `string` | `"admin"` | no | +| [instance\_vpc\_security\_group\_ids](#input\_instance\_vpc\_security\_group\_ids) | List of VPC security groups to associate. | `list(string)` | `null` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the DB parameter group. | `string` | `null` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the DB parameter group. For example, 'oracle-ee', 'postgres', etc. | `string` | n/a | yes | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the DB parameter group. | `string` | `null` | no | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | List of objects containing parameters for the DB parameter group. |
list(
object({
name = string
apply_method = optional(string, "immediate")
value = any
})
)
|
[
{
"apply_method": "pending-reboot",
"name": "audit_trail",
"value": "DB,EXTENDED"
},
{
"apply_method": "pending-reboot",
"name": "audit_sys_operations",
"value": "TRUE"
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [aws-rds-oracle-asset](#output\_aws-rds-oracle-asset) | aws rds oracle asset | +| [oracle-instance](#output\_oracle-instance) | oracle instance | +| [oracle-parameter-group](#output\_oracle-parameter-group) | oracle parameter group | + \ No newline at end of file diff --git a/modules/onboard-aws-rds-oracle-unified/main.tf b/modules/onboard-aws-rds-oracle-unified/main.tf new file mode 100644 index 0000000..ae4e46e --- /dev/null +++ b/modules/onboard-aws-rds-oracle-unified/main.tf @@ -0,0 +1,56 @@ +module "oracle-parameter-group" { + source = "../aws-rds-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "oracle-instance" { + source = "../aws-rds-instance" + + allocated_storage = var.instance_allocated_storage + apply_immediately = var.instance_apply_immediately + db_name = var.instance_db_name + deletion_protection = var.instance_deletion_protection + enabled_cloudwatch_logs_exports = var.instance_enabled_cloudwatch_logs_exports + engine = "oracle-ee" + engine_version = var.instance_engine_version + final_snapshot_identifier = var.instance_final_snapshot_identifier + identifier = var.instance_identifier + instance_class = var.instance_instance_class + max_allocated_storage = var.instance_max_allocated_storage + option_group_name = var.instance_option_group_name + parameter_group_name = module.oracle-parameter-group.this.id + password = var.instance_password + port = var.instance_port + publicly_accessible = var.instance_publicly_accessible + skip_final_snapshot = var.instance_skip_final_snapshot + subnet_group_name = var.instance_subnet_group_name + tags = var.instance_tags + username = var.instance_username + vpc_security_group_ids = var.instance_vpc_security_group_ids +} + +module "aws-rds-oracle-asset" { + source = "../dsfhub-aws-rds-oracle" + + admin_email = var.aws_rds_oracle_admin_email + asset_display_name = module.oracle-instance.this.identifier + asset_id = module.oracle-instance.this.arn + audit_pull_enabled = var.aws_rds_oracle_audit_pull_enabled + audit_type = var.aws_rds_oracle_audit_type + auth_mechanism = var.aws_rds_oracle_auth_mechanism + dsn = var.aws_rds_oracle_dsn + gateway_id = var.aws_rds_oracle_gateway_id + password = var.aws_rds_oracle_password + reason = var.aws_rds_oracle_reason + region = var.aws_rds_oracle_region + server_host_name = module.oracle-instance.this.address + server_port = module.oracle-instance.this.port + service_name = module.oracle-instance.this.db_name + username = var.aws_rds_oracle_username + wallet_dir = var.aws_rds_oracle_wallet_dir +} diff --git a/modules/onboard-aws-rds-oracle-unified/outputs.tf b/modules/onboard-aws-rds-oracle-unified/outputs.tf new file mode 100644 index 0000000..a0202c5 --- /dev/null +++ b/modules/onboard-aws-rds-oracle-unified/outputs.tf @@ -0,0 +1,14 @@ +output "oracle-parameter-group" { + description = "oracle parameter group" + value = module.oracle-parameter-group.this +} + +output "oracle-instance" { + description = "oracle instance" + value = module.oracle-instance.this +} + +output "aws-rds-oracle-asset" { + description = "aws rds oracle asset" + value = module.aws-rds-oracle-asset.this +} diff --git a/modules/onboard-aws-rds-oracle-unified/variables.tf b/modules/onboard-aws-rds-oracle-unified/variables.tf new file mode 100644 index 0000000..783310f --- /dev/null +++ b/modules/onboard-aws-rds-oracle-unified/variables.tf @@ -0,0 +1,226 @@ +variable "aws_rds_oracle_admin_email" { + description = "The email address to notify about this asset" + type = string +} + +variable "aws_rds_oracle_audit_pull_enabled" { + description = "If true, sonargateway will collect the audit logs for this system if it can." + type = bool + default = false +} + +variable "aws_rds_oracle_audit_type" { + description = "Used to indicate what mechanism should be used to fetch logs on systems supporting multiple ways to get logs, see asset specific documentation for details" + type = string + default = "UNIFIED" + validation { + condition = contains(["UNIFIED", "UNIFIED_AGGREGATED"], var.aws_rds_oracle_audit_type) + error_message = "Invalid Value. Select from UNIFIED, or UNIFIED_AGGREGATED." + } +} + +variable "aws_rds_oracle_auth_mechanism" { + description = "Specifies the auth mechanism used by the connection" + type = string + default = "password" + validation { + condition = contains(["password", "oracle_wallet"], var.aws_rds_oracle_auth_mechanism) + error_message = "Invalid auth mechanism. Pick either password, or oracle_wallet." + } +} + +variable "aws_rds_oracle_dsn" { + description = "Datasource name to use in odbc.ini. If using the asset for SDM, keep a dummy DSN value." + type = string + default = null +} + +variable "aws_rds_oracle_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the asset" + type = string +} + +variable "aws_rds_oracle_password" { + description = "Password to use to connect to Oracle database. Must not include semicolons." + type = string +} + +variable "aws_rds_oracle_reason" { + description = "Used to differentiate connections that belong to the same asset" + type = string + default = "default" +} + +variable "aws_rds_oracle_region" { + description = "AWS region containing the instance." + type = string + default = null +} + +variable "aws_rds_oracle_username" { + description = "Username to use to connect to Oracle database." + type = string +} + +variable "aws_rds_oracle_wallet_dir" { + description = "Path to the Oracle wallet directory" + type = string + default = null +} + +variable "parameter_group_description" { + description = "The description of the DB parameter group." + type = string + default = null +} + +variable "parameter_group_family" { + description = "The family of the DB parameter group. For example, 'oracle-ee', 'postgres', etc." + type = string +} + +variable "parameter_group_name" { + description = "The name of the DB parameter group." + type = string + default = null +} + +variable "parameter_group_parameters" { + description = "List of objects containing parameters for the DB parameter group." + type = list( + object({ + name = string + apply_method = optional(string, "immediate") + value = any + }) + ) + default = [ + { + name = "audit_trail" + value = "DB,EXTENDED" + apply_method = "pending-reboot" + }, + { + name = "audit_sys_operations" + value = "TRUE" + apply_method = "pending-reboot" + } + ] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +variable "instance_allocated_storage" { + description = "The allocated storage in gibibytes. If max_allocated_storage is configured, this argument represents the initial storage allocation and differences from the configuration will be ignored automatically when Storage Autoscaling occurs. If replicate_source_db is set, the value is ignored during the creation of the instance." + type = number + default = 20 +} + +variable "instance_apply_immediately" { + description = "Specifies whether any database modifications are applied immediately, or during the next maintenance window." + type = bool + default = true +} + +variable "instance_db_name" { + description = "The Oracle System ID (SID) of the created RDS Custom DB instance." + type = string + default = "ORCL" +} + +variable "instance_subnet_group_name" { + description = "Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the default VPC, or in EC2 Classic, if available." + type = string +} + +variable "instance_deletion_protection" { + description = "If the DB instance should have deletion protection enabled. The database can't be deleted when this value is set to true." + type = bool + default = false +} + +variable "instance_enabled_cloudwatch_logs_exports" { + description = "Set of log types to enable for exporting to CloudWatch logs. If omitted, no logs will be exported." + type = list(string) + default = null +} + +variable "instance_engine_version" { + description = "Database engine version, e.g. \"8.0\"" + type = string + default = null +} + +variable "instance_final_snapshot_identifier" { + description = "The name of your final DB snapshot when this DB instance is deleted. Must be provided if skip_final_snapshot is set to false." + type = string + default = null +} + +variable "instance_identifier" { + description = "Identifier of RDS instance" + type = string +} + +variable "instance_instance_class" { + description = "The instance type of the RDS instance." + type = string + default = "db.t3.small" +} + +variable "instance_max_allocated_storage" { + description = "When configured, the upper limit to which Amazon RDS can automatically scale the storage of the DB instance. Configuring this will automatically ignore differences to allocated_storage." + type = number + default = null +} + +variable "instance_option_group_name" { + description = "Name of the option group to associate with the RDS instance." + type = string + default = null +} + +variable "instance_password" { + description = "Password for the master DB user. Note that this may show up in logs, and it will be stored in the state file." + type = string +} + +variable "instance_port" { + description = "The port on which the DB accepts connections." + type = string + default = null +} + +variable "instance_publicly_accessible" { + description = "Bool to control if instance is publicly accessible." + type = bool + default = true +} + +variable "instance_skip_final_snapshot" { + description = "Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from final_snapshot_identifier." + type = bool + default = true +} + +variable "instance_tags" { + description = "A map of tags to assign to the RDS instance." + type = map(string) + default = null +} + +variable "instance_username" { + description = "Username for the master DB user." + type = string + default = "admin" +} + +variable "instance_vpc_security_group_ids" { + description = "List of VPC security groups to associate." + type = list(string) + default = null +} diff --git a/modules/onboard-aws-redshift-odbc/README.md b/modules/onboard-aws-redshift-odbc/README.md new file mode 100644 index 0000000..33f038c --- /dev/null +++ b/modules/onboard-aws-redshift-odbc/README.md @@ -0,0 +1,71 @@ +# onboard-aws-redshift-odbc +Onboard Amazon Redshift (via ODBC) to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. A method to create an audit pull user on the Redshift cluster. + +See the corresponding example for more details. + + +## Requirements + +No requirements. + +## Providers + +No providers. + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [redshift-asset](#module\_redshift-asset) | ../dsfhub-aws-redshift-cluster | n/a | +| [redshift-cluster](#module\_redshift-cluster) | ../aws-redshift-cluster | n/a | + +## Resources + +No resources. + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_redshift\_admin\_email](#input\_aws\_redshift\_admin\_email) | The email address to notify about the Redshift asset | `string` | n/a | yes | +| [aws\_redshift\_audit\_pull\_enabled](#input\_aws\_redshift\_audit\_pull\_enabled) | A boolean that indicates if the asset should be audited. | `bool` | `false` | no | +| [aws\_redshift\_gateway\_id](#input\_aws\_redshift\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the Redshift asset | `string` | n/a | yes | +| [aws\_redshift\_parent\_asset\_id](#input\_aws\_redshift\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | `null` | no | +| [aws\_redshift\_password](#input\_aws\_redshift\_password) | The password for the Redshift cluster. | `string` | n/a | yes | +| [aws\_redshift\_region](#input\_aws\_redshift\_region) | AWS region containing the Redshift cluster. | `string` | n/a | yes | +| [aws\_redshift\_ssl](#input\_aws\_redshift\_ssl) | Whether to use SSL for the connection. | `bool` | `null` | no | +| [aws\_redshift\_username](#input\_aws\_redshift\_username) | The username for the Redshift cluster. | `string` | n/a | yes | +| [redshift\_apply\_immediately](#input\_redshift\_apply\_immediately) | A boolean that indicates whether major version upgrades are applied immediately, regardless of the maintenance window. | `bool` | `true` | no | +| [redshift\_cluster\_identifier](#input\_redshift\_cluster\_identifier) | Identifier of the Redshift cluster. Must be a lower case string. | `string` | n/a | yes | +| [redshift\_cluster\_subnet\_group\_name](#input\_redshift\_cluster\_subnet\_group\_name) | The name of a cluster subnet group to be associated with this cluster. | `string` | `null` | no | +| [redshift\_cluster\_type](#input\_redshift\_cluster\_type) | The type of the cluster. Valid values: single-node \| multi-node. | `string` | `"single-node"` | no | +| [redshift\_cluster\_version](#input\_redshift\_cluster\_version) | The version of the Amazon Redshift engine software that you want to deploy on the cluster. | `string` | `"1.0"` | no | +| [redshift\_database\_name](#input\_redshift\_database\_name) | The name of the first database to be created when the cluster is created. | `string` | `"dev"` | no | +| [redshift\_default\_iam\_role\_arn](#input\_redshift\_default\_iam\_role\_arn) | The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created. | `string` | `null` | no | +| [redshift\_elastic\_ip](#input\_redshift\_elastic\_ip) | The Elastic IP (EIP) address for the cluster. | `string` | `null` | no | +| [redshift\_final\_snapshot\_identifier](#input\_redshift\_final\_snapshot\_identifier) | The identifier of the final snapshot that is to be created immediately before deleting the cluster. | `string` | `null` | no | +| [redshift\_iam\_roles](#input\_redshift\_iam\_roles) | A list of IAM roles to associate with the cluster. A maximum of 10 IAM roles can be associated to the cluster at any time. | `list(string)` | `null` | no | +| [redshift\_master\_password](#input\_redshift\_master\_password) | The password for the master database user. Must contain at least 8 characters and contain at least one uppercase letter, one lowercase letter, and one number. | `string` | n/a | yes | +| [redshift\_master\_username](#input\_redshift\_master\_username) | The username for the master database user. | `string` | `"admin"` | no | +| [redshift\_node\_type](#input\_redshift\_node\_type) | The node type to be provisioned for the cluster. | `string` | `"dc2.large"` | no | +| [redshift\_number\_of\_nodes](#input\_redshift\_number\_of\_nodes) | The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node. | `number` | `1` | no | +| [redshift\_port](#input\_redshift\_port) | The port number on which the cluster accepts incoming connections. Valid values are between 1115 and 65535 | `number` | `5439` | no | +| [redshift\_preferred\_maintenance\_window](#input\_redshift\_preferred\_maintenance\_window) | The weekly time range (in UTC) during which automated cluster maintenance can occur. | `string` | `null` | no | +| [redshift\_publicly\_accessible](#input\_redshift\_publicly\_accessible) | A boolean that indicates if the cluster is publicly accessible. If the value is true, the cluster can be accessed from a public network. | `bool` | `true` | no | +| [redshift\_skip\_final\_snapshot](#input\_redshift\_skip\_final\_snapshot) | A boolean that indicates whether a final snapshot is created before the cluster is deleted. | `bool` | `true` | no | +| [redshift\_snapshot\_cluster\_identifier](#input\_redshift\_snapshot\_cluster\_identifier) | The name of the cluster the source snapshot was created from. | `string` | `null` | no | +| [redshift\_snapshot\_identifier](#input\_redshift\_snapshot\_identifier) | The name of the snapshot from which to create the new cluster | `string` | `null` | no | +| [redshift\_tags](#input\_redshift\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | +| [redshift\_vpc\_security\_group\_ids](#input\_redshift\_vpc\_security\_group\_ids) | A list of security group identifiers to associate with this cluster. | `list(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [redshift-asset](#output\_redshift-asset) | aws redshift asset | +| [redshift-cluster](#output\_redshift-cluster) | redshift cluster | + \ No newline at end of file diff --git a/modules/onboard-aws-redshift-odbc/main.tf b/modules/onboard-aws-redshift-odbc/main.tf new file mode 100644 index 0000000..15d5bb1 --- /dev/null +++ b/modules/onboard-aws-redshift-odbc/main.tf @@ -0,0 +1,49 @@ +module "redshift-cluster" { + source = "../aws-redshift-cluster" + + apply_immediately = var.redshift_apply_immediately + cluster_identifier = var.redshift_cluster_identifier + cluster_subnet_group_name = var.redshift_cluster_subnet_group_name + cluster_type = var.redshift_cluster_type + cluster_version = var.redshift_cluster_version + database_name = var.redshift_database_name + default_iam_role_arn = var.redshift_default_iam_role_arn + elastic_ip = var.redshift_elastic_ip + final_snapshot_identifier = var.redshift_final_snapshot_identifier + iam_roles = var.redshift_iam_roles + master_password = var.redshift_master_password + master_username = var.redshift_master_username + node_type = var.redshift_node_type + number_of_nodes = var.redshift_number_of_nodes + port = var.redshift_port + preferred_maintenance_window = var.redshift_preferred_maintenance_window + publicly_accessible = var.redshift_publicly_accessible + skip_final_snapshot = var.redshift_skip_final_snapshot + snapshot_cluster_identifier = var.redshift_snapshot_cluster_identifier + snapshot_identifier = var.redshift_snapshot_identifier + vpc_security_group_ids = var.redshift_vpc_security_group_ids + tags = var.redshift_tags +} + +module "redshift-asset" { + source = "../dsfhub-aws-redshift-cluster" + + admin_email = var.aws_redshift_admin_email + asset_display_name = module.redshift-cluster.this.cluster_identifier + asset_id = module.redshift-cluster.this.arn + audit_pull_enabled = var.aws_redshift_audit_pull_enabled + audit_type = "TABLE" + database_name = module.redshift-cluster.this.database_name + gateway_id = var.aws_redshift_gateway_id + parent_asset_id = var.aws_redshift_parent_asset_id + region = var.aws_redshift_region + server_host_name = regex("(.*):", module.redshift-cluster.this.endpoint)[0] + server_ip = regex("(.*):", module.redshift-cluster.this.endpoint)[0] + server_port = module.redshift-cluster.this.port + service_name = module.redshift-cluster.this.database_name + + auth_mechanism = "password" + username = var.aws_redshift_username + password = var.aws_redshift_password + ssl = var.aws_redshift_ssl +} diff --git a/modules/onboard-aws-redshift-odbc/output.tf b/modules/onboard-aws-redshift-odbc/output.tf new file mode 100644 index 0000000..574d8f2 --- /dev/null +++ b/modules/onboard-aws-redshift-odbc/output.tf @@ -0,0 +1,9 @@ +output "redshift-cluster" { + description = "redshift cluster" + value = module.redshift-cluster.this +} + +output "redshift-asset" { + description = "aws redshift asset" + value = module.redshift-asset.this +} diff --git a/modules/onboard-aws-redshift-odbc/variables.tf b/modules/onboard-aws-redshift-odbc/variables.tf new file mode 100644 index 0000000..588ec45 --- /dev/null +++ b/modules/onboard-aws-redshift-odbc/variables.tf @@ -0,0 +1,174 @@ +# AWS Redshift Cluster variables +variable "redshift_cluster_identifier" { + description = "Identifier of the Redshift cluster. Must be a lower case string." + type = string +} + +variable "redshift_database_name" { + description = "The name of the first database to be created when the cluster is created." + type = string + default = "dev" +} + +variable "redshift_default_iam_role_arn" { + description = "The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created." + type = string + default = null +} + +variable "redshift_node_type" { + description = "The node type to be provisioned for the cluster." + type = string + default = "dc2.large" +} + +variable "redshift_cluster_type" { + description = "The type of the cluster. Valid values: single-node | multi-node." + type = string + default = "single-node" +} + +variable "redshift_master_password" { + description = "The password for the master database user. Must contain at least 8 characters and contain at least one uppercase letter, one lowercase letter, and one number." + type = string +} + +variable "redshift_master_username" { + description = "The username for the master database user." + type = string + default = "admin" +} + +variable "redshift_vpc_security_group_ids" { + description = "A list of security group identifiers to associate with this cluster." + type = list(string) + default = null +} + +variable "redshift_cluster_subnet_group_name" { + description = "The name of a cluster subnet group to be associated with this cluster." + type = string + default = null +} + +variable "redshift_preferred_maintenance_window" { + description = "The weekly time range (in UTC) during which automated cluster maintenance can occur." + type = string + default = null +} + +variable "redshift_port" { + description = "The port number on which the cluster accepts incoming connections. Valid values are between 1115 and 65535" + type = number + default = 5439 +} + +variable "redshift_cluster_version" { + description = "The version of the Amazon Redshift engine software that you want to deploy on the cluster." + type = string + default = "1.0" +} + +variable "redshift_apply_immediately" { + description = "A boolean that indicates whether major version upgrades are applied immediately, regardless of the maintenance window." + type = bool + default = true +} + +variable "redshift_number_of_nodes" { + description = "The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node." + type = number + default = 1 +} + +variable "redshift_publicly_accessible" { + description = "A boolean that indicates if the cluster is publicly accessible. If the value is true, the cluster can be accessed from a public network." + type = bool + default = true +} + +variable "redshift_elastic_ip" { + description = "The Elastic IP (EIP) address for the cluster." + type = string + default = null +} + +variable "redshift_skip_final_snapshot" { + description = "A boolean that indicates whether a final snapshot is created before the cluster is deleted." + type = bool + default = true +} + +variable "redshift_final_snapshot_identifier" { + description = "The identifier of the final snapshot that is to be created immediately before deleting the cluster." + type = string + default = null +} + +variable "redshift_snapshot_identifier" { + description = "The name of the snapshot from which to create the new cluster" + type = string + default = null +} + +variable "redshift_snapshot_cluster_identifier" { + description = "The name of the cluster the source snapshot was created from." + type = string + default = null +} + +variable "redshift_iam_roles" { + description = "A list of IAM roles to associate with the cluster. A maximum of 10 IAM roles can be associated to the cluster at any time." + type = list(string) + default = null +} + +variable "redshift_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +# AWS Redshift Asset variables +variable "aws_redshift_admin_email" { + description = "The email address to notify about the Redshift asset" + type = string +} + +variable "aws_redshift_audit_pull_enabled" { + description = "A boolean that indicates if the asset should be audited." + type = bool + default = false +} + +variable "aws_redshift_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the Redshift asset" + type = string +} + +variable "aws_redshift_region" { + description = "AWS region containing the Redshift cluster." + type = string +} + +variable "aws_redshift_parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string + default = null +} + +variable "aws_redshift_username" { + description = "The username for the Redshift cluster." + type = string +} + +variable "aws_redshift_password" { + description = "The password for the Redshift cluster." + type = string +} + +variable "aws_redshift_ssl" { + description = "Whether to use SSL for the connection." + type = bool + default = null +} diff --git a/modules/onboard-aws-redshift-s3/README.md b/modules/onboard-aws-redshift-s3/README.md new file mode 100644 index 0000000..243885e --- /dev/null +++ b/modules/onboard-aws-redshift-s3/README.md @@ -0,0 +1,100 @@ +# onboard-aws-redshift-s3 +Onboard Amazon Redshift (via S3 Bucket) to DSF Hub. + +## Notes +There is one prerequisite for using this module: +1. An AWS cloud account asset onboarded to your DSF Hub with permissions to pull from S3 buckets. + + +## Requirements + +No requirements. + +## Providers + +| Name | Version | +|------|---------| +| [aws](#provider\_aws) | n/a | + +## Modules + +| Name | Source | Version | +|------|--------|---------| +| [redshift-asset](#module\_redshift-asset) | ../dsfhub-aws-redshift-cluster | n/a | +| [redshift-cluster](#module\_redshift-cluster) | ../aws-redshift-cluster | n/a | +| [redshift-logging](#module\_redshift-logging) | ../aws-redshift-logging | n/a | +| [redshift-parameter-group](#module\_redshift-parameter-group) | ../aws-redshift-parameter-group | n/a | +| [s3-bucket](#module\_s3-bucket) | ../aws-s3-bucket | n/a | +| [s3-bucket-asset](#module\_s3-bucket-asset) | ../dsfhub-aws-s3-bucket-la | n/a | +| [s3-bucket-policy](#module\_s3-bucket-policy) | ../aws-s3-bucket-policy | n/a | + +## Resources + +| Name | Type | +|------|------| +| [aws_iam_policy_document.s3_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source | + +## Inputs + +| Name | Description | Type | Default | Required | +|------|-------------|------|---------|:--------:| +| [aws\_redshift\_admin\_email](#input\_aws\_redshift\_admin\_email) | The email address to notify about the Redshift asset | `string` | n/a | yes | +| [aws\_redshift\_audit\_pull\_enabled](#input\_aws\_redshift\_audit\_pull\_enabled) | A boolean that indicates if the asset should be audited. | `bool` | `true` | no | +| [aws\_redshift\_bucket\_account\_id](#input\_aws\_redshift\_bucket\_account\_id) | The account\_id of the bucket owner | `string` | n/a | yes | +| [aws\_redshift\_gateway\_id](#input\_aws\_redshift\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the Redshift asset | `string` | n/a | yes | +| [aws\_redshift\_parent\_asset\_id](#input\_aws\_redshift\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | `null` | no | +| [aws\_redshift\_region](#input\_aws\_redshift\_region) | AWS region containing the Redshift cluster. | `string` | n/a | yes | +| [aws\_s3\_admin\_email](#input\_aws\_s3\_admin\_email) | The email address to notify about the S3 asset | `string` | n/a | yes | +| [aws\_s3\_asset\_display\_name](#input\_aws\_s3\_asset\_display\_name) | User-friendly name of the asset, defined by the user | `string` | n/a | yes | +| [aws\_s3\_audit\_pull\_enabled](#input\_aws\_s3\_audit\_pull\_enabled) | A boolean that indicates if the asset should be audited. | `bool` | `true` | no | +| [aws\_s3\_bucket\_account\_id](#input\_aws\_s3\_bucket\_account\_id) | The account\_id of the bucket owner | `string` | `null` | no | +| [aws\_s3\_gateway\_id](#input\_aws\_s3\_gateway\_id) | Unique identifier (UID) attached to the jSonar machine controlling the S3 asset | `string` | n/a | yes | +| [aws\_s3\_parent\_asset\_id](#input\_aws\_s3\_parent\_asset\_id) | The asset\_id of AWS cloud account being used. E.g. Key-pair, iam\_role, profile or default | `string` | n/a | yes | +| [aws\_s3\_region](#input\_aws\_s3\_region) | AWS region containing the S3 bucket. | `string` | n/a | yes | +| [aws\_s3\_server\_port](#input\_aws\_s3\_server\_port) | Port used by the source server. Default: 443 | `number` | `443` | no | +| [parameter\_group\_description](#input\_parameter\_group\_description) | The description of the Redshift parameter group. | `string` | `null` | no | +| [parameter\_group\_family](#input\_parameter\_group\_family) | The family of the Redshift parameter group. | `string` | `"redshift-1.0"` | no | +| [parameter\_group\_name](#input\_parameter\_group\_name) | The name of the Redshift parameter group. | `string` | n/a | yes | +| [parameter\_group\_parameters](#input\_parameter\_group\_parameters) | A list of Redshift parameters to apply. |
list(
object({
name = string
value = any
})
)
|
[
{
"name": "enable_user_activity_logging",
"value": "true"
}
]
| no | +| [parameter\_group\_tags](#input\_parameter\_group\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | +| [redshift\_apply\_immediately](#input\_redshift\_apply\_immediately) | A boolean that indicates whether major version upgrades are applied immediately, regardless of the maintenance window. | `bool` | `true` | no | +| [redshift\_cluster\_identifier](#input\_redshift\_cluster\_identifier) | Identifier of the Redshift cluster. Must be a lower case string. | `string` | n/a | yes | +| [redshift\_cluster\_parameter\_group\_name](#input\_redshift\_cluster\_parameter\_group\_name) | The name of the parameter group to be associated with this cluster. | `string` | `null` | no | +| [redshift\_cluster\_subnet\_group\_name](#input\_redshift\_cluster\_subnet\_group\_name) | The name of a cluster subnet group to be associated with this cluster. | `string` | `null` | no | +| [redshift\_cluster\_type](#input\_redshift\_cluster\_type) | The type of the cluster. Valid values: single-node \| multi-node. | `string` | `"single-node"` | no | +| [redshift\_cluster\_version](#input\_redshift\_cluster\_version) | The version of the Amazon Redshift engine software that you want to deploy on the cluster. | `string` | `"1.0"` | no | +| [redshift\_database\_name](#input\_redshift\_database\_name) | The name of the first database to be created when the cluster is created. | `string` | `"dev"` | no | +| [redshift\_default\_iam\_role\_arn](#input\_redshift\_default\_iam\_role\_arn) | The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created. | `string` | `null` | no | +| [redshift\_elastic\_ip](#input\_redshift\_elastic\_ip) | The Elastic IP (EIP) address for the cluster. | `string` | `null` | no | +| [redshift\_final\_snapshot\_identifier](#input\_redshift\_final\_snapshot\_identifier) | The identifier of the final snapshot that is to be created immediately before deleting the cluster. | `string` | `null` | no | +| [redshift\_iam\_roles](#input\_redshift\_iam\_roles) | A list of IAM roles to associate with the cluster. A maximum of 10 IAM roles can be associated to the cluster at any time. | `list(string)` | `null` | no | +| [redshift\_master\_password](#input\_redshift\_master\_password) | The password for the master database user. Must contain at least 8 characters and contain at least one uppercase letter, one lowercase letter, and one number. | `string` | n/a | yes | +| [redshift\_master\_username](#input\_redshift\_master\_username) | The username for the master database user. | `string` | `"admin"` | no | +| [redshift\_node\_type](#input\_redshift\_node\_type) | The node type to be provisioned for the cluster. | `string` | `"dc2.large"` | no | +| [redshift\_number\_of\_nodes](#input\_redshift\_number\_of\_nodes) | The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node. | `number` | `1` | no | +| [redshift\_port](#input\_redshift\_port) | The port number on which the cluster accepts incoming connections. Valid values are between 1115 and 65535 | `number` | `5439` | no | +| [redshift\_preferred\_maintenance\_window](#input\_redshift\_preferred\_maintenance\_window) | The weekly time range (in UTC) during which automated cluster maintenance can occur. | `string` | `null` | no | +| [redshift\_publicly\_accessible](#input\_redshift\_publicly\_accessible) | A boolean that indicates if the cluster is publicly accessible. If the value is true, the cluster can be accessed from a public network. | `bool` | `true` | no | +| [redshift\_skip\_final\_snapshot](#input\_redshift\_skip\_final\_snapshot) | A boolean that indicates whether a final snapshot is created before the cluster is deleted. | `bool` | `true` | no | +| [redshift\_snapshot\_cluster\_identifier](#input\_redshift\_snapshot\_cluster\_identifier) | The name of the cluster the source snapshot was created from. | `string` | `null` | no | +| [redshift\_snapshot\_identifier](#input\_redshift\_snapshot\_identifier) | The name of the snapshot from which to create the new cluster | `string` | `null` | no | +| [redshift\_tags](#input\_redshift\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | +| [redshift\_vpc\_security\_group\_ids](#input\_redshift\_vpc\_security\_group\_ids) | A list of security group identifiers to associate with this cluster. | `list(string)` | `null` | no | +| [s3\_bucket](#input\_s3\_bucket) | The name of the bucket. Must be lowercase and less than or equal to 63 characters in length. | `string` | n/a | yes | +| [s3\_force\_destroy](#input\_s3\_force\_destroy) | A boolean that indicates all objects should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. See more details in the (aws terraform documentation)[https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#force_destroy]. | `bool` | `false` | no | +| [s3\_object\_lock\_enabled](#input\_s3\_object\_lock\_enabled) | A boolean that indicates whether this bucket should have an Object Lock configuration enabled. | `bool` | `false` | no | +| [s3\_tags](#input\_s3\_tags) | A map of tags to assign to the resource. | `map(string)` | `null` | no | + +## Outputs + +| Name | Description | +|------|-------------| +| [redshift-asset](#output\_redshift-asset) | aws redshift asset | +| [redshift-cluster](#output\_redshift-cluster) | redshift cluster | +| [redshift-logging](#output\_redshift-logging) | redshift logging configuration | +| [redshift-parameter-group](#output\_redshift-parameter-group) | redshift parameter group | +| [s3-bucket](#output\_s3-bucket) | s3 bucket | +| [s3-bucket-asset](#output\_s3-bucket-asset) | aws s3 bucket asset | +| [s3-bucket-policy](#output\_s3-bucket-policy) | s3 bucket policy | +| [s3\_policy](#output\_s3\_policy) | s3 iam policy | + \ No newline at end of file diff --git a/modules/onboard-aws-redshift-s3/main.tf b/modules/onboard-aws-redshift-s3/main.tf new file mode 100644 index 0000000..e392276 --- /dev/null +++ b/modules/onboard-aws-redshift-s3/main.tf @@ -0,0 +1,119 @@ +module "s3-bucket" { + source = "../aws-s3-bucket" + + bucket = var.s3_bucket + force_destroy = var.s3_force_destroy + object_lock_enabled = var.s3_object_lock_enabled + tags = var.s3_tags +} + +data "aws_iam_policy_document" "s3_policy" { + statement { + effect = "Allow" + principals { + type = "Service" + identifiers = ["redshift.amazonaws.com"] + } + actions = [ + "s3:PutObject", + "s3:GetBucketAcl" + ] + resources = [ + "arn:aws:s3:::${module.s3-bucket.this.bucket}", + "arn:aws:s3:::${module.s3-bucket.this.bucket}/*" + ] + } + +} + +module "s3-bucket-policy" { + source = "../aws-s3-bucket-policy" + + bucket = module.s3-bucket.this.bucket + policy = data.aws_iam_policy_document.s3_policy.json +} + +module "redshift-parameter-group" { + source = "../aws-redshift-parameter-group" + + description = var.parameter_group_description + family = var.parameter_group_family + name = var.parameter_group_name + parameters = var.parameter_group_parameters + tags = var.parameter_group_tags +} + +module "redshift-logging" { + source = "../aws-redshift-logging" + + depends_on = [module.s3-bucket-policy] + + bucket_name = module.s3-bucket.this.bucket + cluster_identifier = module.redshift-cluster.this.cluster_identifier + log_destination_type = "s3" + s3_key_prefix = "redshift" +} + +module "redshift-cluster" { + source = "../aws-redshift-cluster" + + apply_immediately = var.redshift_apply_immediately + cluster_identifier = var.redshift_cluster_identifier + cluster_parameter_group_name = module.redshift-parameter-group.this.name + cluster_subnet_group_name = var.redshift_cluster_subnet_group_name + cluster_type = var.redshift_cluster_type + cluster_version = var.redshift_cluster_version + database_name = var.redshift_database_name + default_iam_role_arn = var.redshift_default_iam_role_arn + elastic_ip = var.redshift_elastic_ip + final_snapshot_identifier = var.redshift_final_snapshot_identifier + iam_roles = var.redshift_iam_roles + master_password = var.redshift_master_password + master_username = var.redshift_master_username + node_type = var.redshift_node_type + number_of_nodes = var.redshift_number_of_nodes + port = var.redshift_port + preferred_maintenance_window = var.redshift_preferred_maintenance_window + publicly_accessible = var.redshift_publicly_accessible + skip_final_snapshot = var.redshift_skip_final_snapshot + snapshot_cluster_identifier = var.redshift_snapshot_cluster_identifier + snapshot_identifier = var.redshift_snapshot_identifier + vpc_security_group_ids = var.redshift_vpc_security_group_ids + tags = var.redshift_tags +} + +module "redshift-asset" { + source = "../dsfhub-aws-redshift-cluster" + + admin_email = var.aws_redshift_admin_email + asset_display_name = module.redshift-cluster.this.cluster_identifier + asset_id = module.redshift-cluster.this.arn + audit_pull_enabled = var.aws_redshift_audit_pull_enabled + audit_type = "REDSHIFT" + bucket_account_id = var.aws_redshift_bucket_account_id + database_name = module.redshift-cluster.this.database_name + gateway_id = var.aws_redshift_gateway_id + logs_destination_asset_id = module.s3-bucket-asset.this.asset_id + parent_asset_id = var.aws_redshift_parent_asset_id + region = var.aws_redshift_region + server_host_name = regex("(.*):", module.redshift-cluster.this.endpoint)[0] + server_ip = regex("(.*):", module.redshift-cluster.this.endpoint)[0] + server_port = module.redshift-cluster.this.port +} + +module "s3-bucket-asset" { + source = "../dsfhub-aws-s3-bucket-la" + + admin_email = var.aws_s3_admin_email + asset_display_name = var.aws_s3_asset_display_name + asset_id = module.s3-bucket.this.arn + audit_pull_enabled = var.aws_s3_audit_pull_enabled + audit_type = "REDSHIFT" + bucket_account_id = var.aws_s3_bucket_account_id + gateway_id = var.aws_s3_gateway_id + parent_asset_id = var.aws_s3_parent_asset_id + region = var.aws_s3_region + server_host_name = module.s3-bucket.this.id + server_ip = module.s3-bucket.this.arn + server_port = var.aws_s3_server_port +} diff --git a/modules/onboard-aws-redshift-s3/output.tf b/modules/onboard-aws-redshift-s3/output.tf new file mode 100644 index 0000000..c396e59 --- /dev/null +++ b/modules/onboard-aws-redshift-s3/output.tf @@ -0,0 +1,39 @@ +output "s3-bucket" { + description = "s3 bucket" + value = module.redshift-cluster.this +} + +output "s3_policy" { + description = "s3 iam policy" + value = data.aws_iam_policy_document.s3_policy.json +} + +output "s3-bucket-policy" { + description = "s3 bucket policy" + value = module.s3-bucket-policy.this +} + +output "redshift-parameter-group" { + description = "redshift parameter group" + value = module.redshift-parameter-group.this +} + +output "redshift-logging" { + description = "redshift logging configuration" + value = module.redshift-logging.this +} + +output "redshift-cluster" { + description = "redshift cluster" + value = module.redshift-cluster.this +} + +output "redshift-asset" { + description = "aws redshift asset" + value = module.redshift-asset.this +} + +output "s3-bucket-asset" { + description = "aws s3 bucket asset" + value = module.s3-bucket-asset.this +} diff --git a/modules/onboard-aws-redshift-s3/variables.tf b/modules/onboard-aws-redshift-s3/variables.tf new file mode 100644 index 0000000..a2229f4 --- /dev/null +++ b/modules/onboard-aws-redshift-s3/variables.tf @@ -0,0 +1,274 @@ +# AWS S3 Bucket variables +variable "s3_bucket" { + description = "The name of the bucket. Must be lowercase and less than or equal to 63 characters in length." + type = string +} + +variable "s3_force_destroy" { + description = "A boolean that indicates all objects should be deleted from the bucket when the bucket is destroyed so that the bucket can be destroyed without error. See more details in the (aws terraform documentation)[https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/s3_bucket#force_destroy]." + type = bool + default = false +} + +variable "s3_object_lock_enabled" { + description = "A boolean that indicates whether this bucket should have an Object Lock configuration enabled." + type = bool + default = false +} + +variable "s3_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +# AWS Redshift Parameter Group variables +variable "parameter_group_description" { + description = "The description of the Redshift parameter group." + type = string + default = null +} + +variable "parameter_group_family" { + description = "The family of the Redshift parameter group." + type = string + default = "redshift-1.0" +} + +variable "parameter_group_name" { + description = "The name of the Redshift parameter group." + type = string +} + +variable "parameter_group_parameters" { + description = "A list of Redshift parameters to apply." + type = list( + object({ + name = string + value = any + }) + ) + default = [{ + name = "enable_user_activity_logging" + value = "true" + }] +} + +variable "parameter_group_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +# AWS Redshift Cluster variables +variable "redshift_cluster_identifier" { + description = "Identifier of the Redshift cluster. Must be a lower case string." + type = string +} + +variable "redshift_database_name" { + description = "The name of the first database to be created when the cluster is created." + type = string + default = "dev" +} + +variable "redshift_default_iam_role_arn" { + description = "The Amazon Resource Name (ARN) for the IAM role that was set as default for the cluster when the cluster was created." + type = string + default = null +} + +variable "redshift_node_type" { + description = "The node type to be provisioned for the cluster." + type = string + default = "dc2.large" +} + +variable "redshift_cluster_type" { + description = "The type of the cluster. Valid values: single-node | multi-node." + type = string + default = "single-node" +} + +variable "redshift_master_password" { + description = "The password for the master database user. Must contain at least 8 characters and contain at least one uppercase letter, one lowercase letter, and one number." + type = string +} + +variable "redshift_master_username" { + description = "The username for the master database user." + type = string + default = "admin" +} + +variable "redshift_vpc_security_group_ids" { + description = "A list of security group identifiers to associate with this cluster." + type = list(string) + default = null +} + +variable "redshift_cluster_subnet_group_name" { + description = "The name of a cluster subnet group to be associated with this cluster." + type = string + default = null +} + +variable "redshift_preferred_maintenance_window" { + description = "The weekly time range (in UTC) during which automated cluster maintenance can occur." + type = string + default = null +} + +variable "redshift_cluster_parameter_group_name" { + description = "The name of the parameter group to be associated with this cluster." + type = string + default = null +} + +variable "redshift_port" { + description = "The port number on which the cluster accepts incoming connections. Valid values are between 1115 and 65535" + type = number + default = 5439 +} + +variable "redshift_cluster_version" { + description = "The version of the Amazon Redshift engine software that you want to deploy on the cluster." + type = string + default = "1.0" +} + +variable "redshift_apply_immediately" { + description = "A boolean that indicates whether major version upgrades are applied immediately, regardless of the maintenance window." + type = bool + default = true +} + +variable "redshift_number_of_nodes" { + description = "The number of compute nodes in the cluster. This parameter is required when the ClusterType parameter is specified as multi-node." + type = number + default = 1 +} + +variable "redshift_publicly_accessible" { + description = "A boolean that indicates if the cluster is publicly accessible. If the value is true, the cluster can be accessed from a public network." + type = bool + default = true +} + +variable "redshift_elastic_ip" { + description = "The Elastic IP (EIP) address for the cluster." + type = string + default = null +} + +variable "redshift_skip_final_snapshot" { + description = "A boolean that indicates whether a final snapshot is created before the cluster is deleted." + type = bool + default = true +} + +variable "redshift_final_snapshot_identifier" { + description = "The identifier of the final snapshot that is to be created immediately before deleting the cluster." + type = string + default = null +} + +variable "redshift_snapshot_identifier" { + description = "The name of the snapshot from which to create the new cluster" + type = string + default = null +} + +variable "redshift_snapshot_cluster_identifier" { + description = "The name of the cluster the source snapshot was created from." + type = string + default = null +} + +variable "redshift_iam_roles" { + description = "A list of IAM roles to associate with the cluster. A maximum of 10 IAM roles can be associated to the cluster at any time." + type = list(string) + default = null +} + +variable "redshift_tags" { + description = "A map of tags to assign to the resource." + type = map(string) + default = null +} + +# AWS Redshift Asset variables +variable "aws_redshift_admin_email" { + description = "The email address to notify about the Redshift asset" + type = string +} + +variable "aws_redshift_audit_pull_enabled" { + description = "A boolean that indicates if the asset should be audited." + type = bool + default = true +} + +variable "aws_redshift_bucket_account_id" { + description = "The account_id of the bucket owner" + type = string +} + +variable "aws_redshift_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the Redshift asset" + type = string +} + +variable "aws_redshift_parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string + default = null +} + +variable "aws_redshift_region" { + description = "AWS region containing the Redshift cluster." + type = string +} + +# AWS S3 Asset variables +variable "aws_s3_admin_email" { + description = "The email address to notify about the S3 asset" + type = string +} +variable "aws_s3_asset_display_name" { + description = "User-friendly name of the asset, defined by the user" + type = string +} + +variable "aws_s3_audit_pull_enabled" { + description = "A boolean that indicates if the asset should be audited." + type = bool + default = true +} + +variable "aws_s3_bucket_account_id" { + description = "The account_id of the bucket owner" + type = string + default = null +} + +variable "aws_s3_gateway_id" { + description = "Unique identifier (UID) attached to the jSonar machine controlling the S3 asset" + type = string +} + +variable "aws_s3_parent_asset_id" { + description = "The asset_id of AWS cloud account being used. E.g. Key-pair, iam_role, profile or default" + type = string +} + +variable "aws_s3_server_port" { + description = "Port used by the source server. Default: 443" + type = number + default = 443 +} + +variable "aws_s3_region" { + description = "AWS region containing the S3 bucket." + type = string +}