Guides
Advanced
Deploying into VPCs

Deploying into AWS Virtual Private Clouds (VPCs)

It's very common to have existing AWS infrastructure in your account when you deploy your Flightcontrol projects. Because you use your own AWS account, you can deploy your Flightcontrol projects with any services you already have. This includes deploying your Flightcontrol projects into existing Virtual Private Clouds (VPCs).

By default, Flightcontrol will create a new VPC for each environment you deploy, but you can also deploy your application into an existing VPC when you use configuration as code - the flightcontrol.json file.

Using the vpc object with flightcontrol.json

You can map and deploy any environment to an existing VPC using with the vpc object in your flightcontrol.json configuration. Add the vpc object to an environment, and all services in that environment will be deployed into the VPC you define.

The vpc object has three properties:

  • id - The AWS ID of the VPC you want to deploy into - this is not the name of the VPC. You should be able to find this in the AWS console. Required.
  • cidr - Classless Inter-Domain Routing (CIDR). If you only have one CIDR block attached to the VPC, you do not need to define a cidr attribute, as Flightcontrol will automatically use the default CIDR block. If the VPC has multiple CIDR blocks attached, you can select the CIDR block you want to use to deploy the application, using the cidr parameter. Optional if the VPC has only one CIDR block.
  • private - Should Flightcontrol deploy the application into the private subnets of the VPC? The default value is false. Optional.

In the following example, we have an existing VPC with the ID vpc-1234 and multiple CID blocks and we want to deploy our application into that VPC.

{
  "environments": [
    {
      "id": "test",
      "name": "test",
      "region": "us-east-1",
      "source": {
        "branch": "main"
      },
      "vpc": {
        "id": "vpc-1234",
        "cidr": "10.10.1.0/24"
      },
      "services": [
        {
          "id": "web",
          "name": "web",
          "type": "web",
          "target": {
            "type": "fargate"
          },
          "buildType": "nixpacks",
          "ci": {
            "type": "ec2"
          },
          "cpu": 0.5,
          "memory": 1024,
          "minInstances": 1,
          "maxInstances": 1,
          "envVariables": {
            "REVALIDATE_SECONDS": "20"
          }
        },
        {
          "id": "db",
          "name": "Database",
          "type": "rds",
          "engine": "mysql",
          "engineVersion": "8",
          "instanceSize": "db.t4g.micro",
          "storage": 20,
          "private": false
        }
      ]
    }
  ]
}

Notes when working with VPCs and Flightcontrol

There are a couple of things to keep in mind when working with VPCs and Flightcontrol.

  1. This approach only works for new Flightcontrol environments. Existing environments cannot be changed to use a different VPC. If you have an existing environment, you will need to deploy a new environment, route your application traffic to the new environment, then delete the old environment.

  2. The VPC has to be in the same AWS region you supply in your flightcontrol.json file, such as us-east-1.