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.

169 lines
4.5 KiB

  1. AWSTemplateFormatVersion: 2010-09-09
  2. Description: AWS CloudFormation Template for doccano.
  3. Resources:
  4. AppSG:
  5. Type: 'AWS::EC2::SecurityGroup'
  6. Properties:
  7. GroupDescription: 'for the app nodes that allow ssh, http and docker ports'
  8. SecurityGroupIngress:
  9. - IpProtocol: tcp
  10. FromPort: '80'
  11. ToPort: '80'
  12. CidrIp: 0.0.0.0/0
  13. - IpProtocol: tcp
  14. FromPort: '443'
  15. ToPort: '443'
  16. CidrIp: 0.0.0.0/0
  17. - IpProtocol: tcp
  18. FromPort: '22'
  19. ToPort: '22'
  20. CidrIp: 0.0.0.0/0
  21. Metadata:
  22. 'AWS::CloudFormation::Designer':
  23. id: 116a7f7b-14c5-489a-a3c8-faf276be7ab0
  24. App:
  25. Type: 'AWS::EC2::Instance'
  26. Properties:
  27. InstanceType: t2.micro
  28. ImageId: ami-0ac019f4fcb7cb7e6
  29. KeyName: !Ref KeyName
  30. SecurityGroups:
  31. - !Ref AppSG
  32. UserData: !Base64
  33. 'Fn::Join':
  34. - ''
  35. - - |
  36. #!/usr/bin/env bash
  37. - |
  38. sudo apt update
  39. - >
  40. sudo apt install -y apt-transport-https ca-certificates curl
  41. software-properties-common
  42. - >
  43. curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo
  44. apt-key add -
  45. - >
  46. sudo add-apt-repository "deb [arch=amd64]
  47. https://download.docker.com/linux/ubuntu bionic stable"
  48. - |
  49. sudo apt update
  50. - |
  51. apt-cache policy docker-ce
  52. - |
  53. sudo apt install -y docker-ce
  54. - |
  55. sudo usermod -aG docker ${USER}
  56. - |
  57. touch /env.list
  58. - sudo tee -a /env.list <<< ADMIN=
  59. - !Ref AdminUserName
  60. - |+
  61. - sudo tee -a /env.list <<< EMAIL=
  62. - !Ref AdminEmail
  63. - |+
  64. - sudo tee -a /env.list <<< PASSWORD=
  65. - !Ref AdminPassword
  66. - |+
  67. - sudo tee -a /env.list <<< DEBUG=
  68. - !Ref Debug
  69. - |+
  70. - sudo tee -a /env.list <<< SECRET_KEY=
  71. - !Ref SecretKey
  72. - |+
  73. - |
  74. set -a
  75. - |
  76. source /env.list
  77. - |
  78. set +a
  79. - |
  80. sudo docker pull chakkiworks/doccano:latest
  81. - >
  82. sudo docker run -d --name doccano --env-file /env.list -p 80:80
  83. chakkiworks/doccano:latest
  84. - >
  85. sudo docker exec doccano tools/create-admin.sh ${ADMIN} ${EMAIL}
  86. ${PASSWORD}
  87. Metadata:
  88. 'AWS::CloudFormation::Designer':
  89. id: 3547c02e-5393-4b26-a9af-6f00dc2cbcdb
  90. Metadata:
  91. 'AWS::CloudFormation::Designer':
  92. 116a7f7b-14c5-489a-a3c8-faf276be7ab0:
  93. size:
  94. width: 60
  95. height: 60
  96. position:
  97. x: 60
  98. 'y': 210
  99. z: 1
  100. embeds: []
  101. 3547c02e-5393-4b26-a9af-6f00dc2cbcdb:
  102. size:
  103. width: 60
  104. height: 60
  105. position:
  106. x: 180
  107. 'y': 210
  108. z: 1
  109. embeds: []
  110. isassociatedwith:
  111. - 116a7f7b-14c5-489a-a3c8-faf276be7ab0
  112. Parameters:
  113. InstanceType:
  114. Description: Server EC2 instance type
  115. Type: String
  116. Default: t2.micro
  117. AllowedValues:
  118. - t1.micro
  119. - t2.micro
  120. - t2.small
  121. - t2.medium
  122. ConstraintDescription: must be a valid EC2 instance type.
  123. KeyName:
  124. Description: Name of an EC2 KeyPair to enable SSH access to the instance.
  125. Type: 'AWS::EC2::KeyPair::KeyName'
  126. ConstraintDescription: must be the name of an existing EC2 KeyPair.
  127. AdminUserName:
  128. Description: The admin account user name
  129. Type: String
  130. MinLength: 1
  131. MaxLength: 16
  132. AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
  133. AdminEmail:
  134. Default: admin@gmail.com
  135. Description: The admin account user email
  136. Type: String
  137. AllowedPattern: '^[\x20-\x45]?[\w-\+]+(\.[\w]+)*@[\w-]+(\.[\w]+)*(\.[a-z]{2,})$'
  138. AdminPassword:
  139. Description: The admin account password
  140. Type: String
  141. NoEcho: true
  142. MinLength: 1
  143. MaxLength: 16
  144. AllowedPattern: '^[a-zA-Z0-9]*$'
  145. Debug:
  146. Default: 'False'
  147. AllowedValues:
  148. - 'False'
  149. - 'True'
  150. Description: Debug mode or not
  151. Type: String
  152. AllowedPattern: '^[a-zA-Z0-9]*$'
  153. SecretKey:
  154. Default: zICc59rlKXmlFRpG
  155. Description: Secret key for Django
  156. Type: String
  157. AllowedPattern: '^[a-zA-Z0-9]*$'
  158. Outputs:
  159. PublicDNS:
  160. Value: !GetAtt
  161. - App
  162. - PublicDnsName
  163. Description: Newly created server DNS address