main.tf 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. /*
  2. * https://wiki.nuxeo.com/display/INFRA/Cloud+Provisioning
  3. */
  4. ///////////////////////////////////////////////////////////////////////
  5. // RESOURCES
  6. ///////////////////////////////////////////////////////////////////////
  7. module "net" {
  8. source = "./net/"
  9. stack_name = "${var.stack_name}"
  10. region = "${var.region}"
  11. vpc_id = "${var.vpc_id}"
  12. public_subnets = ["10.0.10.0/24"]
  13. private_subnets = ["10.0.11.0/24"]
  14. private_db_subnets = ["10.0.100.0/24","10.0.101.0/24"]
  15. }
  16. #-------------
  17. #DNS Entry for Cloud Customer
  18. #-------------
  19. resource "aws_route53_record" "dns" {
  20. zone_id = "Z1EFT3O5K9NMCJ" // Zone ID for nuxeocloud.com
  21. name = "${name}"
  22. type = "CNAME"
  23. ttl = "300"
  24. weighted_routing_policy {
  25. weight = 90
  26. }
  27. set_identifier = "${var.stack_name}"
  28. records = ["${var.stack_name}.nuxeocloud.com"]
  29. }
  30. # -------------------------------------
  31. # S3 buckets:w for Nuxeo and for Backups
  32. # -------------------------------------
  33. module "s3" {
  34. source = "./s3/"
  35. stack_name = "${var.stack_name}"
  36. cust_id = "${uuid()}"
  37. }
  38. # -------------------------
  39. # RDS Postgres Database
  40. # -------------------------
  41. module "rds" {
  42. source = "./rds/"
  43. region = "${var.region}"
  44. stack_name = "${var.stack_name}"
  45. database_name = "nuxeo"
  46. rds_allocated_storage = "${var.rds_allocated_storage}"
  47. rds_engine_version = "${rds_engine_version}"
  48. security_group_ids = ["${module.net.sg_internal_id}"]
  49. #subnet_ids = ["${aws_subnet.db_private.0.id}", "${aws_subnet.db_private.1.id}"]
  50. #db_private_subnets = ["${element(module.net.db_private, 0)}", "${element(module.net.db_private, 1)}"]
  51. subnet_ids = ["${element(module.net.db_private, 0)}", "${element(module.net.db_private, 1)}"]
  52. }
  53. #-------------------------
  54. # Elastic Cache Redis
  55. #-------------------------
  56. module "elasticcache" {
  57. source = "./elasticcache"
  58. stack_name = "${var.stack_name}-redis"
  59. engine_version = "${engine_version}"
  60. node_type = "$${var.node_type}"
  61. security_group_ids = ["${module.net.sg_internal_id}"]
  62. private_subnet_ids = ["${module.net.db_private}"]
  63. }
  64. #-------------------------
  65. # EC2 Instances
  66. #-------------------------
  67. module "nuxeo" {
  68. source = "./instance/"
  69. # Variables for creating an instance
  70. stack_name = "${var.stack_name}-nuxeo"
  71. instance_name = "${var.stack_name}-nuxeo-instance"
  72. os_release = "${os_release}"
  73. instance_type = "${var.instance_type}"
  74. public_key_path ="${var.public_key_path}"
  75. # public_key_path="/path/to/my/pub_key"
  76. subnet_id="${element(module.net.private_subnets, 0)}"
  77. }
  78. #-------------------------
  79. # Bastion EC2 Instances
  80. #-------------------------
  81. module "bastion" {
  82. source = "bastion/"
  83. vpc_id = "${var.vpc_id}"
  84. allowed_network="10.0.0.0/16"
  85. subnet_id="${element(module.net.private_subnets, 0)}"
  86. }