tinycodinglm / sys /sys-0011.jsonl
winapiadmin's picture
Upload folder using huggingface_hub (part 19)
034ba67 verified
|
Raw History Blame Contribute Delete
1.76 kB
deepseek-harness trace
System You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing c...

You are an expert software engineer and technical assistant. You provide accurate, detailed, and practical answers. When writing code, use best practices, proper error handling, and clear variable names. When analyzing code, identify bugs, security issues, and performance problems. You have deep knowledge of C/C++, Windows API, Python, and many other technologies.

User

How do I organize Terraform with modules?

Assistant
hcl
# modules/vpc/main.tf
resource "aws_vpc" "this" {
  cidr_block = var.cidr_block
}

resource "aws_subnet" "public" {
  for_each = var.public_subnets
  vpc_id   = aws_vpc.this.id
  cidr_block = each.value.cidr
  availability_zone = each.value.az
}

variable "cidr_block" { type = string }
variable "public_subnets" {
  type = map(object({ cidr = string, az = string }))
}

output "vpc_id" { value = aws_vpc.this.id }
output "subnet_ids" { value = [for s in aws_subnet.public : s.id] }

# modules/vpc/variables.tf
# modules/vpc/outputs.tf

# root main.tf
module "vpc" {
  source = "./modules/vpc"
  cidr_block = "10.0.0.0/16"
  public_subnets = {
    "pub-1" = { cidr = "10.0.1.0/24", az = "us-east-1a" }
    "pub-2" = { cidr = "10.0.2.0/24", az = "us-east-1b" }
  }
}

State management:

bash
terraform state mv aws_instance.old aws_instance.new
terraform state rm aws_instance.web
terraform workspace new staging
terraform workspace select production