flake/infra/modules/aws/main.tf

59 lines
894 B
Terraform
Raw Normal View History

2024-09-27 16:03:31 +00:00
variable "hostname" {
type = string
}
variable "fqdn" {
type = string
}
variable "region" {
type = string
}
variable "plan" {
type = string
}
variable "tags" {
type = list(string)
}
terraform {
required_providers {
aws = {
source = "registry.terraform.io/hashicorp/aws"
}
}
}
resource "aws_lightsail_instance" "server" {
availability_zone = var.region
bundle_id = var.plan
name = var.hostname
tags = zipmap(var.tags, [for _ in var.tags : null])
blueprint_id = "debian_12" # nixos-anywhere
ip_address_type = "dualstack"
lifecycle {
ignore_changes = [
name,
]
}
}
output "ipv4" {
value = aws_lightsail_instance.server.public_ip_address
}
output "ipv6" {
2024-09-27 16:30:20 +00:00
value = aws_lightsail_instance.server.ipv6_addresses[0]
2024-09-27 16:03:31 +00:00
}
output "fqdn" {
value = var.fqdn
}
output "tags" {
value = var.tags
}