Skip to content

deff-dev/terraform-timeweb-cloud-firewall

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TimeWeb-Cloud Firewall Terraform module

Release Forks Stars License

📝 Table of Contents

🧐 About

Terraform module which creates firewall on TimeWeb Cloud

🎈 Usage

FireWall with Single Server

module "server" {
  source  = "deff-dev/cloud-server/timeweb"
  version = ">= 1.0.0"

  name = "Single-preset"
  os = {
    name    = "ubuntu"
    version = "22.04"
  }
  location      = "ru-1"
  cpu_frequency = 3.3
  disk_type     = "nvme"

  preset = {
    cpu  = 1
    ram  = 1
    disk = 15

    price = {
      min = 100
      max = 200
    }
  }

  ssh_keys = ["key_name_1", "key_name_2"]
}

module "firewall" {
  source = "deff-dev/cloud-firewall/timeweb"

  name = "Web"
  rules = [
    {
      ports     = [80, 443]
      protocol  = "tcp"
      cidrs     = ["192.168.0.0/24", "192.167.11.112"]
      direction = "ingress"

    },
    {
      ports     = [80, 443]
      protocol  = "udp"
      cidrs     = [""]
      direction = "egress"
    },
  ]
  resources = [
    {
      id   = module.server.server_id
      type = "server"
    }
  ]
  depends_on = [module.server, null_resource.default]
}

# Check when server started
resource "null_resource" "default" {
  for_each = module.server
  connection {
    type        = "ssh"
    user        = "root"
    private_key = file("~/.ssh/id_rsa")
    host        = each.value.server_public_ip
  }

  provisioner "remote-exec" {
    inline = ["uptime"]
  }
}

😊 Example

📋 Requirements

Name Version
terraform >= 1.3
timeweb-cloud >= 1.3.0

☁️ Providers

Name Version
timeweb-cloud >= 1.3.0

📦 Modules

Name Version
server >= 1.0.0

🌐 Resources

Name Type
twc_firewall.default resource
twc_firewall_rule.default resource

📥 Inputs

Name Description Type Default Required
name Name for FireWall string "Managed by terraform" yes
rules Information about rules list(object) null yes
resources Link resources list(object) null no

📤 Outputs

Name Description
firewall_id Return firewall id

✍️ Authors

Module is maintained by Deff.
Thanks for help denismaster.

🔑 License

Apache 2 Licensed. See LICENSE for full details.