sam-template.json 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. {
  2. "AWSTemplateFormatVersion": "2010-09-09",
  3. "Transform": "AWS::Serverless-2016-10-31",
  4. "Description": "Slack Inviter",
  5. "Parameters": {
  6. "CommunityName": {
  7. "Type": "String",
  8. "Description": "Name of your Slack community (e.g., \"Example Team\")"
  9. },
  10. "SlackUrl": {
  11. "Type": "String",
  12. "Description": "URL host for your Slack community (e.g., \"exampleteam.slack.com\")"
  13. },
  14. "SlackToken": {
  15. "Type": "String",
  16. "NoEcho": true,
  17. "Description": "Slack access token"
  18. },
  19. "InviteToken": {
  20. "Type": "String",
  21. "Description": "Optional invite token"
  22. },
  23. "RecaptchaSiteKey": {
  24. "Type": "String",
  25. "Description": "Optional Recaptcha site key"
  26. },
  27. "RecaptchaSecretKey": {
  28. "Type": "String",
  29. "NoEcho": true,
  30. "Description": "Optional Recaptcha secret key"
  31. },
  32. "Locale": {
  33. "Type": "String",
  34. "Description": "Optional locale string (e.g., \"it\")"
  35. }
  36. },
  37. "Resources": {
  38. "SlackInviterApi": {
  39. "Type": "AWS::Serverless::Api",
  40. "Properties": {
  41. "DefinitionUri": "api-swagger.json",
  42. "StageName": "Express",
  43. "Variables": {
  44. "ExpressFunction": { "Ref": "ExpressFunction" }
  45. }
  46. }
  47. },
  48. "ExpressFunction": {
  49. "Type": "AWS::Serverless::Function",
  50. "Properties": {
  51. "FunctionName": { "Fn::Sub": "${AWS::StackName}-Express" },
  52. "Description": "Express API handler",
  53. "CodeUri": "build/",
  54. "Handler": "lambda.handler",
  55. "Runtime": "nodejs8.10",
  56. "MemorySize": 1024,
  57. "Timeout": 10,
  58. "Tracing": "Active",
  59. "Policies": ["AWSXrayWriteOnlyAccess"],
  60. "Environment": {
  61. "Variables": {
  62. "COMMUNITY_NAME": { "Ref": "CommunityName" },
  63. "SLACK_URL": { "Ref": "SlackUrl" },
  64. "SLACK_TOKEN": { "Ref": "SlackToken" },
  65. "INVITE_TOKEN": { "Ref": "InviteToken" },
  66. "RECAPTCHA_SITE": { "Ref": "RecaptchaSiteKey" },
  67. "RECAPTCHA_SECRET": { "Ref": "RecaptchaSecretKey" },
  68. "LOCALE": { "Ref": "Locale" }
  69. }
  70. },
  71. "Events": {
  72. "ExpressProxyApiRoot": {
  73. "Type": "Api",
  74. "Properties": {
  75. "RestApiId": { "Ref": "SlackInviterApi" },
  76. "Path": "/",
  77. "Method": "ANY"
  78. }
  79. },
  80. "ExpressProxyApiGreedy": {
  81. "Type": "Api",
  82. "Properties": {
  83. "RestApiId": { "Ref": "SlackInviterApi" },
  84. "Path": "/{proxy+}",
  85. "Method": "ANY"
  86. }
  87. }
  88. }
  89. }
  90. }
  91. },
  92. "Outputs": {
  93. "Url": {
  94. "Value": {
  95. "Fn::Sub": "https://${SlackInviterApi}.execute-api.${AWS::Region}.amazonaws.com/${SlackInviterApi.Stage}/"
  96. }
  97. }
  98. }
  99. }