Skip to main content

Creating a cluster via the AWS CLI

In this guide we will create an HA Kubernetes cluster with 3 control plane nodes across 3 availability zones. You should have an existing AWS account and have the AWS CLI installed and configured. If you need more information on AWS specifics, please see the official AWS documentation. To install the dependencies for this tutorial you can use homebrew on macOS or Linux:
If you would like to create infrastructure via terraform or opentofu please see the example in the contrib repository.
Note: this guide is not a production set up and steps were tested in bash and zsh shells.

Create AWS resources

We will be creating a control plane with 3 Ec2 instances spread across 3 availability zones. It is recommended to not use the default VPC so we will create a new one for this tutorial. Change to your desired region and CIDR block and create a VPC:
Make sure your subnet does not overlap with 10.244.0.0/16 or 10.96.0.0/12 the default pod and services subnets in Kubernetes.

Create the subnets

Create 3 smaller CIDRs to use for each subnet in different availability zones. Make sure to adjust these CIDRs if you changed the default value from the last command.
Next create a subnet in each availability zones.
Note: If you’re using zsh you need to run setopt KSH_ARRAYS to have arrays referenced properly.
Create an internet gateway and attach it to the VPC:

Official AMI images

Official AMI image ID can be found in the cloud-images.json file attached to the Talos release. If using the official AMIs, you can skip to Creating the Security group

Create your own AMIs

The use of the official Talos AMIs are recommended, but if you wish to build your own AMIs, follow the procedure below.

Create the S3 bucket

Create the vmimport role

In order to create an AMI, ensure that the vmimport role exists as described in the official AWS documentation. Note that the role should be associated with the S3 bucket we created above.

Create the image snapshot

First, download the AWS image from Image Factory: Copy the RAW disk to S3 and import it as a snapshot:
To check on the status of the import, run:
Once the SnapshotTaskDetail.Status indicates completed, we can register the image.

Register the image

We now have an AMI we can use to create our cluster.

Create a security group

Using the security group from above, allow all internal traffic within the same security group:
Expose the Talos (50000) and Kubernetes API.
Note: This is only required for the control plane nodes. For a production environment you would want separate private subnets for worker nodes.
We will bootstrap Talos with a MachineConfig via user-data it will never be exposed to the internet without certificate authentication. We enable KubeSpan in this tutorial so you need to allow inbound UDP for the Wireguard port:

Create a load balancer

The load balancer is used for a stable Kubernetes API endpoint.
Now create a target group for the load balancer:

Create the machine configuration files

We will create a machine config patch to use the AWS time servers. You can create additional patches to customize the configuration as needed.
Using the DNS name of the loadbalancer created earlier, generate the base configuration files for the Talos machines.
Note that the generated configs are too long for AWS userdata field if the --with-examples and --with-docs flags are not passed.

Create the EC2 instances

Note: There is a known issue that prevents Talos from running on T2 instance types. Please use T3 if you need burstable instance types.

Create the control plane nodes

Create the worker nodes

For the worker nodes we will create a new launch template with the worker.yaml machine configuration and create an autoscaling group.

Configure the load balancer

Now, using the load balancer target group’s ARN, and the PrivateIpAddress from the controlplane instances that you created :

Export the talosconfig file

Export the talosconfig file so commands sent to Talos will be authenticated.

Bootstrap etcd

Set the endpoints (the control plane node to which talosctl commands are sent) and nodes (the nodes that the command operates on):
Bootstrap etcd:
You can now watch as your cluster bootstraps, by using
This command will take a few minutes for the nodes to start etcd, reach quorum and start the Kubernetes control plane. You can also watch the performance of a node, via:

Retrieve the kubeconfig

When the cluster is healthy you can retrieve the admin kubeconfig by running:
And use standard kubectl commands.

Cleanup resources

If you would like to delete all of the resources you created during this tutorial you can run the following commands.