Extend using Terraform/Pulumi
You may want to create additional cloud resources (Queues, Databases, Topics or anything) within a cloud account for any app environment - dev, stage, prod, beyond what LocalOps has provisioned for the same app environment.
This guide explains how to extend app environments using your Terraform/Pulumi scripts.
At a high level, every app environment comes with the following components that are provisioned and managed by LocalOps:
- 1 VPC
- 3 private subnets
- 3 public subnets
- a managed Kubernetes cluster (EKS in AWS)
All your code is deployed and run as sevice(s) in the managed kubernetes cluster.
You can provision additional cloud resources within the same VPC & subnets and they can be accessed from within your service(s) privately.
To do this, we expose IDs of the above entities within LocalOps environment dashboard:
Manual
You can create cloud resources manually within the cloud console and use VPC/Subnet IDs in relevant places.
Automate
Add the VPC/Subnet IDs as variables in your Pulumi/Terraform scripts and automate those cloud resources.
Say you want to create a RDS database for your App environment. Here is how you will do it in Terraform, OpenTofu or Pulumi.
Using Terraform or OpenTofu
Here is how you can create an RDS database within the same private subnets and VPCs of the app environment using Terraform or OpenTofu.
Using Pulumi
Here is a short example in Typescript, for provisioning a RDS database using Pulumi. Note that we can pass in VPC ID and subnet IDs as environment variable.
We use 10.0.0.0/16
as CIDR range for any VPC we create. You can use the same as source IP or destination IP range
when defining security groups.
Use same tags
LocalOps creates all resources with two standard tags for any given environment. So that you can take inventory of all resources in the cloud, analyse cost per app environment in Cost analysis console in the cloud account and more. These tags are exposed within App environment Dashboard page.
When you extend app environments with custom cloud resources, you can attach the same tags so that you can see both the resources managed by LocalOps and those you created outside LocalOps for the same environment.
Resource lifecycle
When you extend LocalOps environments with additional cloud resources either manually or by using Terraform-like IaC tools, you have to manage their configuration yourself for their lifetime. They won’t be imported or managed by LocalOps.
If you want to delete environments, you will have to first delete your terraform/opentofu/pulumi stack before deleting app environment within LocalOps console. This is to ensure that all your additional cloud resources are deleted in full before VPC and other resources are deleted.