Created
April 2, 2023 18:01
-
-
Save clouditlab/866ef8b9eca02104c7f076d4befc4e72 to your computer and use it in GitHub Desktop.
Talos using Terraform in AWS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module "vpc" { | |
| source = "terraform-aws-modules/vpc/aws" | |
| version = "~> 3.0" | |
| name = "talos-demo" | |
| cidr = "10.0.0.0/18" | |
| public_subnets = ["10.0.0.0/24"] | |
| azs = ["eu-central-1a"] | |
| } | |
| resource "aws_security_group" "security_group" { | |
| vpc_id = module.vpc.vpc_id | |
| egress { | |
| from_port = 0 | |
| to_port = 0 | |
| protocol = "-1" | |
| description = "Egress everywhere" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } | |
| ingress { | |
| from_port = 0 | |
| to_port = 0 | |
| protocol = "-1" | |
| description = "Ingress everywhere" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } | |
| } | |
| data "aws_ami" "talos" { | |
| most_recent = true | |
| filter { | |
| name = "name" | |
| values = ["talos-v1.3.5-eu-central-1-amd64"] | |
| } | |
| owners = ["540036508848"] | |
| } | |
| resource "aws_instance" "ec2" { | |
| ami = data.aws_ami.talos.id | |
| instance_type = "t3.small" | |
| subnet_id = module.vpc.public_subnets[0] | |
| private_ip = "10.0.0.5" | |
| associate_public_ip_address = "true" | |
| vpc_security_group_ids = [aws_security_group.security_group.id] | |
| user_data = talos_machine_configuration_controlplane.machineconfig_cp.machine_config | |
| tags = { | |
| Name = "talos-demo" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| output "talos_talosconfig" { | |
| value = talos_client_configuration.talosconfig.talos_config | |
| sensitive = true | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| terraform { | |
| required_providers { | |
| aws = { | |
| source = "hashicorp/aws" | |
| version = ">= 4.0" | |
| } | |
| talos = { | |
| source = "siderolabs/talos" | |
| version = "0.1.1" | |
| } | |
| } | |
| required_version = ">= 1.0" | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| resource "talos_machine_secrets" "machine_secrets" { | |
| } | |
| resource "talos_machine_configuration_controlplane" "machineconfig_cp" { | |
| cluster_name = "talos-demo" | |
| cluster_endpoint = "https://10.0.0.5:6443" | |
| machine_secrets = talos_machine_secrets.machine_secrets.machine_secrets | |
| config_patches = [ | |
| file("${path.module}/talos-patch.yaml") | |
| ] | |
| docs_enabled = false | |
| examples_enabled = false | |
| kubernetes_version = "1.24.3" | |
| talos_version = "v1.3.5" | |
| } | |
| resource "talos_client_configuration" "talosconfig" { | |
| cluster_name = "talos-demo" | |
| machine_secrets = talos_machine_secrets.machine_secrets.machine_secrets | |
| endpoints = [aws_instance.ec2.public_ip] | |
| nodes = ["10.0.0.5"] | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| machine: | |
| type: init | |
| cluster: | |
| allowSchedulingOnControlPlanes: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment