main.tf 3.0 KB

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