main.tf 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * https://wiki.nuxeo.com/display/INFRA/Cloud+Provisioning
  3. * 1) Create Public Subnet with a /24 size. One private Subnet to run Nuxeo and at least 2 Private Subnets for Data
  4. * 2) Create a NAT Gateway in one of the Public Subnets
  5. * 3) Create a Route with the Internet Gateway as default route, associate it with the Public Subnet(s)
  6. * 4) Create a Route with the NAT Gateway as default route, *that should be associated to all Private Subnets when they are created*
  7. * 5) Create a Security Group for Bastion Hosts that accepts SSH from anywhere
  8. * 6) Create a Security Group for ELBs that accepts HTTP and HTTPS from anywhere
  9. * 7) Create a Bastion Host with bastion host SG associated to ti, install NTP and Userify on it
  10. */
  11. ///////////////////////////////////////////////////////////////////////
  12. // RESOURCES
  13. ///////////////////////////////////////////////////////////////////////
  14. resource "random_id" "customer" {
  15. byte_length = 8
  16. }
  17. module "net" {
  18. source = "./net/"
  19. stack_name = "${var.stack_name}"
  20. region = "us-west-2"
  21. vpc_id = "${var.vpc_id}"
  22. public_subnets = ["10.0.10.0/24"]
  23. private_subnets = ["10.0.11.0/24"]
  24. private_db_subnets = ["10.0.100.0/24","10.0.101.0/24"]
  25. }
  26. #-------------
  27. # DNS Entry for Cloud Customer
  28. #-------------
  29. #resource "aws_route53_record" "dns" {
  30. # zone_id = "Z1EFT3O5K9NMCJ" // Zone ID for nuxeocloud.com
  31. # name = "${name}"
  32. # type = "CNAME"
  33. # ttl = "300"
  34. # weighted_routing_policy {
  35. # weight = 90
  36. # }
  37. # set_identifier = "${var.stack_name}"
  38. # records = ["${var.stack_name}.nuxeocloud.com"]
  39. #}
  40. #-------------------------------------
  41. # S3 buckets:w for Nuxeo and for Backups
  42. #-------------------------------------
  43. module "s3" {
  44. source = "./s3/"
  45. stack_name = "${var.stack_name}"
  46. cust_id = "${random_id.customer.b64}"
  47. }
  48. #-------------------------
  49. # RDS Postgres Database
  50. #-------------------------
  51. module "rds" {
  52. source = "./rds/"
  53. region = "${var.aws_region}"
  54. stack_name = "${var.stack_name}"
  55. database_name = "nuxeo"
  56. rds_allocated_storage = "10"
  57. rds_engine_version = "9.4.7"
  58. security_group_ids = ["${module.net.sg_internal_id}"]
  59. #subnet_ids = ["${aws_subnet.db_private.0.id}", "${aws_subnet.db_private.1.id}"]
  60. #db_private_subnets = ["${element(module.net.db_private, 0)}", "${element(module.net.db_private, 1)}"]
  61. subnet_ids = ["${element(module.net.db_private, 0)}", "${element(module.net.db_private, 1)}"]
  62. }
  63. #-------------------------
  64. # Elastic Cache Redis
  65. #-------------------------
  66. module "elasticcache" {
  67. source = "./elasticcache"
  68. stack_name = "${var.stack_name}-redis"
  69. engine_version = "3.2.4"
  70. node_type = "cache.t2.micro"
  71. security_group_ids = ["${module.net.sg_internal_id}"]
  72. private_subnet_ids = ["${module.net.db_private}"]
  73. }
  74. # #-------------------------------
  75. # # Create Nuxeo Ubuntu Instance
  76. # #-------------------------------
  77. # # Create a new instance of the latest Ubuntu on an
  78. # # t2.micro node with an AWS Tag naming it "Nuxeo"
  79. # data "aws_ami" "ubuntu" {
  80. # most_recent = true
  81. # filter {
  82. # name = "name"
  83. # values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"]
  84. # }
  85. # filter {
  86. # name = "virtualization-type"
  87. # values = ["hvm"]
  88. # }
  89. # owners = ["099720109477"] # Canonical
  90. # }
  91. # resource "aws_instance" "nuxeo" {
  92. # ami = "${data.aws_ami.ubuntu.id}"
  93. # instance_type = "t2.micro"
  94. # key_name = "${aws_key_pair.deployer.id}"
  95. # subnet_id = "${aws_subnet.private.id}"
  96. # tags {
  97. # Name = "Nuxeo"
  98. # billing-category = "customers"
  99. # billing-subcategory = "${var.stack_name}"
  100. # role= "nuxeo.instance"
  101. # }
  102. # }
  103. # #---------------------
  104. # # Deployer SSH keys
  105. # #--------------------
  106. # resource "aws_key_pair" "deployer" {
  107. # key_name = "deployer-key"
  108. # public_key = "${file(var.public_key_path)}"
  109. # }