You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

233 lines
6.7 KiB

11 months ago
  1. {
  2. "AWSTemplateFormatVersion": "2010-09-09",
  3. "Description": "Create a stack that runs AnythingLLM on a single instance",
  4. "Parameters": {
  5. "InstanceType": {
  6. "Description": "EC2 instance type",
  7. "Type": "String",
  8. "Default": "t3.small"
  9. },
  10. "InstanceVolume": {
  11. "Description": "Storage size of disk on Instance in GB",
  12. "Type": "Number",
  13. "Default": 10,
  14. "MinValue": 4
  15. }
  16. },
  17. "Resources": {
  18. "AnythingLLMInstance": {
  19. "Type": "AWS::EC2::Instance",
  20. "Properties": {
  21. "ImageId": {
  22. "Fn::FindInMap": [
  23. "Region2AMI",
  24. {
  25. "Ref": "AWS::Region"
  26. },
  27. "AMI"
  28. ]
  29. },
  30. "InstanceType": {
  31. "Ref": "InstanceType"
  32. },
  33. "SecurityGroupIds": [
  34. {
  35. "Ref": "AnythingLLMInstanceSecurityGroup"
  36. }
  37. ],
  38. "BlockDeviceMappings": [
  39. {
  40. "DeviceName": {
  41. "Fn::FindInMap": [
  42. "Region2AMI",
  43. {
  44. "Ref": "AWS::Region"
  45. },
  46. "RootDeviceName"
  47. ]
  48. },
  49. "Ebs": {
  50. "VolumeSize": {
  51. "Ref": "InstanceVolume"
  52. }
  53. }
  54. }
  55. ],
  56. "UserData": {
  57. "Fn::Base64": {
  58. "Fn::Join": [
  59. "",
  60. [
  61. "Content-Type: multipart/mixed; boundary=\"//\"\n",
  62. "MIME-Version: 1.0\n",
  63. "\n",
  64. "--//\n",
  65. "Content-Type: text/cloud-config; charset=\"us-ascii\"\n",
  66. "MIME-Version: 1.0\n",
  67. "Content-Transfer-Encoding: 7bit\n",
  68. "Content-Disposition: attachment; filename=\"cloud-config.txt\"\n",
  69. "\n",
  70. "\n",
  71. "#cloud-config\n",
  72. "cloud_final_modules:\n",
  73. "- [scripts-user, once-per-instance]\n",
  74. "\n",
  75. "\n",
  76. "--//\n",
  77. "Content-Type: text/x-shellscript; charset=\"us-ascii\"\n",
  78. "MIME-Version: 1.0\n",
  79. "Content-Transfer-Encoding: 7bit\n",
  80. "Content-Disposition: attachment; filename=\"userdata.txt\"\n",
  81. "\n",
  82. "\n",
  83. "#!/bin/bash\n",
  84. "# check output of userdata script with sudo tail -f /var/log/cloud-init-output.log\n",
  85. "sudo yum install docker iptables -y\n",
  86. "sudo iptables -A OUTPUT -m owner ! --uid-owner root -d 169.254.169.254 -j DROP\n",
  87. "sudo systemctl enable docker\n",
  88. "sudo systemctl start docker\n",
  89. "mkdir -p /home/ec2-user/anythingllm\n",
  90. "touch /home/ec2-user/anythingllm/.env\n",
  91. "sudo chown ec2-user:ec2-user -R /home/ec2-user/anythingllm\n",
  92. "docker pull mintplexlabs/anythingllm\n",
  93. "docker run -d -p 3001:3001 --cap-add SYS_ADMIN -v /home/ec2-user/anythingllm:/app/server/storage -v /home/ec2-user/anythingllm/.env:/app/server/.env -e STORAGE_DIR=\"/app/server/storage\" mintplexlabs/anythingllm\n",
  94. "echo \"Container ID: $(sudo docker ps --latest --quiet)\"\n",
  95. "export ONLINE=$(curl -Is http://localhost:3001/api/ping | head -n 1|cut -d$' ' -f2)\n",
  96. "echo \"Health check: $ONLINE\"\n",
  97. "echo \"Setup complete! AnythingLLM instance is now online!\"\n",
  98. "\n",
  99. "--//--\n"
  100. ]
  101. ]
  102. }
  103. }
  104. }
  105. },
  106. "AnythingLLMInstanceSecurityGroup": {
  107. "Type": "AWS::EC2::SecurityGroup",
  108. "Properties": {
  109. "GroupDescription": "AnythingLLM Instance Security Group",
  110. "SecurityGroupIngress": [
  111. {
  112. "IpProtocol": "tcp",
  113. "FromPort": "22",
  114. "ToPort": "22",
  115. "CidrIp": "0.0.0.0/0"
  116. },
  117. {
  118. "IpProtocol": "tcp",
  119. "FromPort": "3001",
  120. "ToPort": "3001",
  121. "CidrIp": "0.0.0.0/0"
  122. },
  123. {
  124. "IpProtocol": "tcp",
  125. "FromPort": "3001",
  126. "ToPort": "3001",
  127. "CidrIpv6": "::/0"
  128. }
  129. ]
  130. }
  131. }
  132. },
  133. "Outputs": {
  134. "ServerIp": {
  135. "Description": "IP address of the AnythingLLM instance",
  136. "Value": {
  137. "Fn::GetAtt": [
  138. "AnythingLLMInstance",
  139. "PublicIp"
  140. ]
  141. }
  142. },
  143. "ServerURL": {
  144. "Description": "URL of the AnythingLLM server",
  145. "Value": {
  146. "Fn::Join": [
  147. "",
  148. [
  149. "http://",
  150. {
  151. "Fn::GetAtt": [
  152. "AnythingLLMInstance",
  153. "PublicIp"
  154. ]
  155. },
  156. ":3001"
  157. ]
  158. ]
  159. }
  160. }
  161. },
  162. "Mappings": {
  163. "Region2AMI": {
  164. "ap-south-1": {
  165. "AMI": "ami-0e6329e222e662a52",
  166. "RootDeviceName": "/dev/xvda"
  167. },
  168. "eu-north-1": {
  169. "AMI": "ami-08c308b1bb265e927",
  170. "RootDeviceName": "/dev/xvda"
  171. },
  172. "eu-west-3": {
  173. "AMI": "ami-069d1ea6bc64443f0",
  174. "RootDeviceName": "/dev/xvda"
  175. },
  176. "eu-west-2": {
  177. "AMI": "ami-06a566ca43e14780d",
  178. "RootDeviceName": "/dev/xvda"
  179. },
  180. "eu-west-1": {
  181. "AMI": "ami-0a8dc52684ee2fee2",
  182. "RootDeviceName": "/dev/xvda"
  183. },
  184. "ap-northeast-3": {
  185. "AMI": "ami-0c8a89b455fae8513",
  186. "RootDeviceName": "/dev/xvda"
  187. },
  188. "ap-northeast-2": {
  189. "AMI": "ami-0ff56409a6e8ea2a0",
  190. "RootDeviceName": "/dev/xvda"
  191. },
  192. "ap-northeast-1": {
  193. "AMI": "ami-0ab0bbbd329f565e6",
  194. "RootDeviceName": "/dev/xvda"
  195. },
  196. "ca-central-1": {
  197. "AMI": "ami-033c256a10931f206",
  198. "RootDeviceName": "/dev/xvda"
  199. },
  200. "sa-east-1": {
  201. "AMI": "ami-0dabf4dab6b183eef",
  202. "RootDeviceName": "/dev/xvda"
  203. },
  204. "ap-southeast-1": {
  205. "AMI": "ami-0dc5785603ad4ff54",
  206. "RootDeviceName": "/dev/xvda"
  207. },
  208. "ap-southeast-2": {
  209. "AMI": "ami-0c5d61202c3b9c33e",
  210. "RootDeviceName": "/dev/xvda"
  211. },
  212. "eu-central-1": {
  213. "AMI": "ami-004359656ecac6a95",
  214. "RootDeviceName": "/dev/xvda"
  215. },
  216. "us-east-1": {
  217. "AMI": "ami-0cff7528ff583bf9a",
  218. "RootDeviceName": "/dev/xvda"
  219. },
  220. "us-east-2": {
  221. "AMI": "ami-02238ac43d6385ab3",
  222. "RootDeviceName": "/dev/xvda"
  223. },
  224. "us-west-1": {
  225. "AMI": "ami-01163e76c844a2129",
  226. "RootDeviceName": "/dev/xvda"
  227. },
  228. "us-west-2": {
  229. "AMI": "ami-0ceecbb0f30a902a6",
  230. "RootDeviceName": "/dev/xvda"
  231. }
  232. }
  233. }
  234. }