Defining Cached Services

Create a Terraform Configuration

The first step to creating a cached service is to create an infrastructure as code representation of the service. Make sure you define terraform outputs for any values that will need to be used in templates in the future -- otherwise they will not be accessible! For example, if you would like to define a MySQL AWS RDS cached service, you can use the following terraform snippet:

resource "aws_db_instance" "default" {
  allocated_storage    = 20
  engine               = "postgresql"
  engine_version       = "12.2"
  instance_class       = "db.t3.micro"
  name                 = var.database_name
  username             = var.database_user
  password             = var.database_password
  skip_final_snapshot  = true
}

output "db_name" {
  value = aws_db_instance.default.name
}

Snapshots

If your DBMS supports snapshotting, you can specify snapshots in your IaC templates to get pre-seeded databases.

Now, you can go to the cached services tab, name your cached service, and select the cloud providers you need to use in your terraform file. You'll use the cached service name as an identifier to access cached service resources in your template IaC scripts.

Now link your terraform definition with Gallery. You can either use a terraform snippet or a repository.

Once you create your cached service, instances of your services will start spinning up (up to the minimum replicas you initially indicated).

Scaling

You can adjust the number of active cached service instances from the cached service page. Just hit edit, adjust the minimum number of instances and hit save to scale up or down the number of idle cached services that are running at any time.

Use in Templates

You can now use your cached services in templates. Take a look at Using Cached Services for more information.

Last updated