This OpenTofu/Terraform module provisions and configures OCI Database for PostgreSQL.
-
OCI PostgreSQL Deployment: Deploys a PostgreSQL database with customizable parameters.
-
Network Setup: Configures a private subnet and security groups.
-
Automated Backups: Enables automatic backups.
-
Custom Configuration: Fine-tunes database settings such as max_connections.
-
Monitoring and Alerts: Sets up alarms for key performance metrics.
-
User and Database Initialization: Creates users, roles, and necessary extensions.
- While creating PostgreSQL custom configurations:
- Fixed shapes require specifying predefined OCPU and memory values corresponding to the selected shape.
- For flexible shapes, set the memory and OCPU values as 0 or skip them, as these resources are controlled dynamically at the
dbsystemlevel. - when defining the PostgreSQL configuration, specify the shape without the
PostgresQLprefix (e.g.,VM.Standard.E4.Flex). However, when creating a PostgreSQL database using this configuration, appendPostgreSQLto the shape name (e.g.,PostgreSQL..VM.Standard.E4.Flex). - the attribute
is_flexibleis a required field. Set this totrue/falseaccordingly. Do not set this to null.
- To enable extensions, use the value
oci.admin_enabled_extensionsdb_configuration_overrides { items { config_key = "oci.admin_enabled_extensions" overriden_config_value = "pglogical" # mention the OCI supported extension name here } }
- After the provisioning of database, you may need to update the OCPU or memory based on the performance requirements.
- Flexible shapes are mapped with flexible configurations, allowing customization of OCUPS and memory.
- Fixed shapes have predefined OCPU and memory. If updating the fixed shape, the existing configuration can't be applied. You must either select an existing valid configuration or create a new configuration and pass it to the module.
- Series of the shape cannot be changed. (eg., StandardE4 to StandardE5)
Ensure you have the following before using this module:
- OpenTofu or Terraform installed
- An Oracle Cloud Infrastruture(OCI) Account
- Configure OCI CLI with appropriate credentials
- Required IAM policies
This module is compatible with OpenTofu. To use Terraform instead of OpenTofu, ensure you have Terraform installed and use the following provider configuration:
terraform {
required_providers {
oci = {
source = "oracle/oci"
version = ">= 6.31.0"
}
}
}
-
Use
terraform.tfvarsFileThe repository includes a terraform.tfvars.example file. Edit it and replace the placeholder values with your actual OCI credentials, to create your own terraform.tfvars file.
-
To deploy the resources, initialize and apply the configuration:
tofu init # or terraform init
tofu plan # or terraform plan
tofu apply # or terraform applyTo destroy the created resources, use:
tofu destroy # or terraform destroy- OCI PostgreSQL
- OCI PostgreSQL custom configurations
- Supported Shapes
- OCI Monitoring
- OCI Notifications
- OCI PostgreSQL Metrics
- MQL Reference
This project is licensed under the MIT License - see the LICENSE file for details.