vpc.tf 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. # =============
  2. # VPC resources
  3. # =============
  4. # Define Keycloak Network
  5. data "yandex_vpc_network" "kc_net" {
  6. folder_id = "${data.yandex_resourcemanager_folder.kc_folder.id}"
  7. name = var.kc_network_name
  8. }
  9. # Define Keycloak Subnet
  10. data "yandex_vpc_subnet" "kc_subnet" {
  11. folder_id = "${data.yandex_resourcemanager_folder.kc_folder.id}"
  12. name = var.kc_subnet_name
  13. }
  14. # Create public ip address for Keycloak VM
  15. resource "yandex_vpc_address" "kc_pub_ip" {
  16. folder_id = "${data.yandex_resourcemanager_folder.kc_folder.id}"
  17. name = var.kc_hostname
  18. external_ipv4_address {
  19. zone_id = var.kc_zone_id
  20. }
  21. }
  22. # Create Security Group for Keycloak VM
  23. resource "yandex_vpc_security_group" "kc_sg" {
  24. name = var.kc_vm_sg_name
  25. folder_id = "${data.yandex_resourcemanager_folder.kc_folder.id}"
  26. network_id = "${data.yandex_vpc_network.kc_net.id}"
  27. egress {
  28. description = "Permit ALL"
  29. protocol = "ANY"
  30. v4_cidr_blocks = ["0.0.0.0/0"]
  31. }
  32. ingress {
  33. description = "icmp"
  34. protocol = "ICMP"
  35. v4_cidr_blocks = ["0.0.0.0/0"]
  36. }
  37. ingress {
  38. description = "ssh"
  39. protocol = "TCP"
  40. port = 22
  41. v4_cidr_blocks = ["0.0.0.0/0"]
  42. }
  43. ingress {
  44. description = "https"
  45. protocol = "TCP"
  46. port = var.kc_port
  47. v4_cidr_blocks = ["0.0.0.0/0"]
  48. }
  49. }