{"id":18830768,"url":"https://github.com/materializeinc/terraform-aws-rds-postgres","last_synced_at":"2026-03-19T06:37:54.958Z","repository":{"id":113651780,"uuid":"593798858","full_name":"MaterializeInc/terraform-aws-rds-postgres","owner":"MaterializeInc","description":"A Terraform Module to setup a pre-configured RDS instance","archived":false,"fork":false,"pushed_at":"2024-06-27T13:09:17.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-29T16:15:41.307Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MaterializeInc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-01-26T21:29:15.000Z","updated_at":"2024-06-27T13:09:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"aec5b020-37a5-418f-a834-2cab7674ed4a","html_url":"https://github.com/MaterializeInc/terraform-aws-rds-postgres","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/MaterializeInc/terraform-aws-rds-postgres","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaterializeInc%2Fterraform-aws-rds-postgres","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaterializeInc%2Fterraform-aws-rds-postgres/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaterializeInc%2Fterraform-aws-rds-postgres/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaterializeInc%2Fterraform-aws-rds-postgres/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MaterializeInc","download_url":"https://codeload.github.com/MaterializeInc/terraform-aws-rds-postgres/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MaterializeInc%2Fterraform-aws-rds-postgres/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28826429,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T18:44:20.126Z","status":"ssl_error","status_checked_at":"2026-01-27T18:44:09.161Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-08T01:50:32.880Z","updated_at":"2026-01-27T23:02:55.868Z","avatar_url":"https://github.com/MaterializeInc.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Materialize + Postgres RDS + Terraform\n\nTerraform module for deploying a new RDS Postgres instance and connecting it to Materialize.\n\nFor the manual setup, see the [Materialize + RDS](https://materialize.com/docs/integrations/cdc-postgres/#direct-postgres-source) documentation.\n\n\u003e **Warning** This is provided on a best-effort basis and Materialize cannot offer support for this module.\n\n## Overview\n\nThis module will create the following resources:\n\n- VPC with public and private subnets\n- Security group for RDS Postgres instance: allows inbound traffic from Materialize and the user's IP address\n- RDS Postgres instance\n- RDS Parameter Group for RDS Postgres instance to enable logical replication\n\nTo override the default AWS provider variables, you can export the following environment variables:\n\n```bash\nexport AWS_PROFILE=\u003cyour_aws_profile\u003e # eg. default\nexport AWS_CONFIG_FILE=\u003cyour_aws_config_file\u003e # eg. [\"~/.aws/config\"]\n```\n\n## Prerequisites\n\nBefore using this module, you must have the following:\n\n- An AWS account\n- Materialize instance\n- Get your Materialize instance egress IP addresses from the `mz_egress_ips` table:\n\n    Access the Materialize instance and run the following query:\n\n    ```sql\n    SELECT jsonb_agg(egress_ip || '/32') egress_cidrs FROM mz_egress_ips;\n    ```\n\n    The query above will return a JSON array of egress IP addresses. Define the following variable in your `terraform.tfvars` file:\n\n    ```bash\n    mz_egress_ips = [\"123.456.789.0/32\", \"123.456.789.1/32\"]\n    ```\n\n## Running the module\n\n### Variables\n\nCopy the `terraform.tfvars.example` file to `terraform.tfvars` and fill in the variables:\n\n```bash\ncp terraform.tfvars.example terraform.tfvars\n```\n\n| Name                  | Description                              | Type         | Example                                    | Required |\n|-----------------------|------------------------------------------|:------------:|:------------------------------------------:|:--------:|\n| `mz_egress_ips`       | Materialize instance egress IP addresses | list(string) | `[\"123.456.789.0/32\", \"123.456.789.1/32\"]` | yes      |\n| `rds_instance_name`   | The name of the RDS instance             | string       | `mz-rds-demo-db`                           | yes      |\n| `publicly_accessible` | Whether the RDS is publicly accessible   | `bool`       | true                                       | no       |\n| `rds_instance_class`  | The RDS instance class                   | string       | `db.m5.large`                              | no       |\n| `engine_version`      | The RDS engine version                   | string       | `14`                                       | no       |\n\n### Apply the Terraform Module\n\n1. Add the Materialize instance egress IP addresses to the `mz_egress_ips` variable in `terraform.tfvars`:\n\n    ```bash\n    mz_egress_ips = [\"123.456.789.0/32\", \"123.456.789.1/32\"]\n    ```\n\n1. Apply the Terraform configuration:\n\n    ```bash\n    terraform apply\n    ```\n\n    Once you run the command, it might take a few minutes for the RDS instance to be created.\n\n1. Check the output:\n\n    ```bash\n    terraform output -raw mz_rds_details\n    ```\n\n## Output\n\n```sql\n    -- On the RDS instance side:\n    -- 1. Connect to the RDS instance\n    PGPASSWORD=YOUR_SECURE_PASSWORD psql -h mz-rds-demo-db.some-db-url.us-east-1.rds.amazonaws.com -U materialize -d materialize\n    -- 2. Create a new table\n    CREATE TABLE test_table (id int, name varchar(255));\n    -- 3. Insert some data\n    INSERT INTO test_table VALUES (1, 'test'), (2, 'test2');\n    -- 4. Verify the data\n    SELECT * FROM test_table;\n    -- 5. Set the replica identity to full\n    ALTER TABLE test_table REPLICA IDENTITY FULL;\n    -- 6. Create a publication\n    CREATE PUBLICATION mz_source FOR TABLE test_table;\n\n    -- On the Materialize side:\n    -- 1. Create a secret for the RDS password\n    CREATE SECRET mz_rds_password AS 'YOUR_SECURE_PASSWORD';\n    -- 2. Create a connection to the RDS instance\n    CREATE CONNECTION pg_connection TO POSTGRES (\n        HOST 'mz-rds-demo-db.some-db-url.us-east-1.rds.amazonaws.com',\n        PORT 5432,\n        USER 'materialize',\n        PASSWORD SECRET mz_rds_password,\n        SSL MODE 'require',\n        DATABASE 'materialize'\n    );\n\n    -- 3. Create a source\n    CREATE SOURCE mz_source\n        FROM POSTGRES CONNECTION pg_connection (PUBLICATION 'mz_source')\n        FOR ALL TABLES;\n\n    -- 4. Query the source\n    SELECT * FROM test_table;\n```\n\n## Security\n\nThe RDS instance is publicly accessible, but the module creates a security group that allows inbound traffic from the Materialize egress IPs and the user's IP address on port 5432.\n\nIf you create a Materialize source from the RDS instance and leave the RDS instance idle for a long time, the replication slot might grow in size. If left unchecked a replication slot in an inactive state can consume all your disk space. To avoid this, add alarms on the RDS metric `TransactionLogsDiskUsage` and `OldestReplicationSlotLag` to alert you when the transaction logs disk usage increased above a threshold or when a replication slot started lagging.\n\n## Helpful links\n\n- [Materialize](https://materialize.com/)\n- [Postgres Connection](https://materialize.com/docs/sql/create-connection/#postgres)\n- [Postgres CDC](https://materialize.com/docs/integrations/cdc-postgres/)\n- [Materialize Terraform Provider](https://github.com/MaterializeInc/terraform-provider-materialize)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterializeinc%2Fterraform-aws-rds-postgres","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaterializeinc%2Fterraform-aws-rds-postgres","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaterializeinc%2Fterraform-aws-rds-postgres/lists"}