Skip to content
This repository has been archived by the owner on Jan 29, 2024. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArthurFlag committed Dec 28, 2023
1 parent a0b3d51 commit 0cdb2c6
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 77 deletions.
117 changes: 59 additions & 58 deletions docs/tools/terraform/howto/config-postgresql-provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,70 +12,71 @@ The new provider must be added to the ``required_providers`` block in the Terraf

1. This example shows how to add the PostgreSQL provider (source: ``cyrilgdn/postgresql``) along with the Aiven Terraform Provider (source: ``aiven/aiven``).

.. code:: terraform
terraform {
required_providers {
aiven = {
source = "aiven/aiven"
version = ">=4.0.0, < 5.0.0"
.. code:: terraform
terraform {
required_providers {
aiven = {
source = "aiven/aiven"
version = ">=4.0.0, < 5.0.0"
}
postgresql = {
source = "cyrilgdn/postgresql"
version = "1.16.0"
}
}
postgresql = {
source = "cyrilgdn/postgresql"
version = "1.16.0"
}
}
}
2. If the PostgreSQL provider is used on its own, you can provide the Aiven for PostgreSQL service connection details as follows:

.. code:: terraform
provider "postgresql" {
host = "pg-serivicename-projectname.aivencloud.com"
port = 12691
database = "defaultdb"
username = "avnadmin"
password = "postgres_password"
sslmode = "require"
connect_timeout = 15
}
Optionally, when the Aiven for PostgreSQL service is created within the same Terraform project, the values required to configure the PostgreSQL provider can be passed using references to the resource, as shown in the code below:
.. code:: terraform
.. code:: terraform
resource "aiven_pg" "demo-pg" {
project = var.project_name
cloud_name = "google-asia-southeast1"
plan = "business-8"
service_name = "demo-pg"
termination_protection = true
}
# PostgreSQL provider is configured with references to the aiven_pg.demo-pg resource.
provider "postgresql" {
host = aiven_pg.demo-pg.service_host
port = aiven_pg.demo-pg.service_port
database = aiven_pg.demo-pg.pg.dbname
username = aiven_pg.demo-pg.service_username
password = aiven_pg.demo-pg.service_password
sslmode = "require"
connect_timeout = 15
}
provider "postgresql" {
host = "pg-serivicename-projectname.aivencloud.com"
port = 12691
database = "defaultdb"
username = "avnadmin"
password = "postgres_password"
sslmode = "require"
connect_timeout = 15
}
Optionally, when the Aiven for PostgreSQL service is created within the same Terraform project, the values required to configure the PostgreSQL provider can be passed using references to the resource, as shown in the code below:

.. code:: terraform
resource "aiven_pg" "demo-pg" {
project = var.project_name
cloud_name = "google-asia-southeast1"
plan = "business-8"
service_name = "demo-pg"
termination_protection = true
}
# PostgreSQL provider is configured with references to the aiven_pg.demo-pg resource.
provider "postgresql" {
host = aiven_pg.demo-pg.service_host
port = aiven_pg.demo-pg.service_port
database = aiven_pg.demo-pg.pg.dbname
username = aiven_pg.demo-pg.service_username
password = aiven_pg.demo-pg.service_password
sslmode = "require"
connect_timeout = 15
}
3. Create a PostgreSQL role called ``test_role`` using the Terraform resource ``postgresql_role.my_role``.

.. code:: terraform
resource "postgresql_role" "my_role" {
name = "test_role"
}
.. note::

For the full documentation of the ``Aiven Terraform Provider`` refer to `Aiven provider documentation <https://registry.terraform.io/providers/aiven/aiven/latest/docs>`_.

For the full list of resources available in ``PostgreSQL provider`` refer to `PostgreSQL provider documentation <https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs>`_.

.. code:: terraform
resource "postgresql_role" "my_role" {
name = "test_role"
}
.. note::

For the full documentation of the ``Aiven Terraform Provider`` refer to `Aiven provider documentation <https://registry.terraform.io/providers/aiven/aiven/latest/docs>`_.

For the full list of resources available in ``PostgreSQL provider`` refer to `PostgreSQL provider documentation <https://registry.terraform.io/providers/cyrilgdn/postgresql/latest/docs>`_.


10 changes: 5 additions & 5 deletions docs/tools/terraform/howto/upgrade-provider-v1-v2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,18 @@ Upgrade Terraform 0.12 to 0.13
Between v0.12 and v0.13, the syntax of Terraform files changed. If you have the older syntax,
follow these steps to get the updated syntax:


1. Upgrade your modules first by installing Terraform v0.13.x (i.e. 0.13.7): ``tfenv install 0.13.7 && tfenv use 0.13.7`` and then using ``0.13upgrade`` tool.

2. Update ``required_version`` from ``>= 0.12`` to ``>= 0.13`` in the requirements block.

3. Update the existing state file, by running:
``terraform state replace-provider registry.terraform.io/-/aiven registry.terraform.io/aiven/aiven``
you will replace old Aiven terraform provider references to the new format.

``terraform state replace-provider registry.terraform.io/-/aiven registry.terraform.io/aiven/aiven``
you will replace old Aiven terraform provider references to the new format.

4. Run ``terraform 0.13upgrade`` to see any additional fixes recommended by HashiCorp.
If you are using more providers than Aiven provider you most likely need to upgrade them as well.
More information `here <https://www.terraform.io/upgrade-guides/0-13.html>`_.
If you are using more providers than Aiven provider you most likely need to upgrade them as well.
More information `here <https://www.terraform.io/upgrade-guides/0-13.html>`_.

5. Run ``terraform init -upgrade``

Expand Down
28 changes: 14 additions & 14 deletions docs/tools/terraform/howto/upgrade-provider-v3-v4.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@ In this example, the ``aiven_database`` field is updated to the service-specific

1. Update ``aiven_database`` references to ``aiven_pg_database`` as in this example file:

.. code::
- resource "aiven_database" "mydatabase" {
project = aiven_project.myproject.project
service_name = aiven_pg.mypg.service_name
database_name = "<DATABASE_NAME>"
}
+ resource "aiven_pg_database" "mydatabase" {
project = aiven_project.myproject.project
service_name = aiven_pg.mypg.service_name
database_name = "<DATABASE_NAME>"
}
.. code::
- resource "aiven_database" "mydatabase" {
project = aiven_project.myproject.project
service_name = aiven_pg.mypg.service_name
database_name = "<DATABASE_NAME>"
}
+ resource "aiven_pg_database" "mydatabase" {
project = aiven_project.myproject.project
service_name = aiven_pg.mypg.service_name
database_name = "<DATABASE_NAME>"
}
2. View a list of all resources in the state file:

Expand Down

0 comments on commit 0cdb2c6

Please sign in to comment.