Skip to content

Creating a postgres data service#

To create the postgres data service, you need to;

  1. Create a network access resource.
  2. Create the postgres data service attached to the network access resource.

Create a network access resource#

In the Ametnes Cloud console;

  1. Navigate to the Network Access left menu.
  2. On the network access dashboard, click New Network.
  3. Enter Name: PostgresTutorialNetwork.
  4. Select Kind: Load Balancer.
  5. Select the Location: You Data Service Location.
  6. Client Create Network.
  7. After a while, your network access resource will be created and have the status ready.

Install terraform#

Follow instructions here to install terraform on your computer.

Create your project#

Add these files to an empty folder on your workstation.

Setup the variables#

variables.tf
variable "token" {
  type = string
  description = "The ametnes cloud api doken to use. You'd need to create one in the ametnes cloud console corresponding to your regsitered email"
}

variable "username" {
  type = string
  description = "This is your ametnes cloud registered email address"
}

variable "project" {
  type = string
  description = "The project you'd like to create your resources in"
   default = "Default"
}

Add your API key secrets#

secrets.auto.tfvars
username = "Your.Email@domain.com"
token = "YourApiToken"

Define your resources#

provider.tf
terraform {
  required_providers {
    ametnes = {
      source  = "ametnes.com/cloud/ametnes"
    }
  }
}

# Init and create the provider
provider "ametnes" {
  token = var.token
  username = var.username
}

Define your resources#

data.tf
# Read location.
data "ametnes_location" "location" {
  name = "DemoDsl"
  code = "USE2"
}

# Read the project that will host all your resources.
data "ametnes_project" "project" {
  name = var.project
}

Define your resources#

network.tf
1
2
3
4
5
6
7
# Create a network access resource.
resource "ametnes_network" "network" {
  name = "NETWORK-USE2"
  project = ametnes_project.project.id
  location = data.ametnes_location.location.id
  description = "My Network Access resource"
}

Proceed to create your postgres data service.

Create the postgres data service#

In the Ametnes Cloud console;

  1. Navigate to the Services left menu.
  2. On the network access dashboard, click New Service.
  3. Enter Name: PostgresService.
  4. Select Kind: Postgres 13.0 Service.
  5. Select the Location: You Data Service Location.
  6. Select the Network: PostgresTutorialNetwork.
  7. Click Create Service
  8. After a while, your postgres data service will be created and have the status ready.

Setup the variables#

service.tf
# Create a service resource.
resource "ametnes_service" "service" {
  name = "Weaviate-Demo-Instance"
  project = ametnes_project.project.id
  location = data.ametnes_location.location.id
  kind = "postgres:13.0"
  description = "PostgresTutorialNetwork"
  network = ametnes_network.network.resource_id
  capacity {
    storage = 10
    memory = 1
    cpu = 1
  }
   config = {
     "admin.user" = "admin"
     "admin.password" = "fo9ruk3kee7uJe1vi"
   }
  nodes = 1
}

output "service_connections" {
  value = ametnes_service.service.connections
}
  1. Now runterraform plan and check the resources going to be created.
  2. Once happy with the changes, please run terraform apply -auto-approve