@swovohq/fuel 0.2.2-alpha.9 → 0.2.2-alpha.91

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (232) hide show
  1. package/README.md +173 -69
  2. package/dist/bin/fuel.js +77 -31
  3. package/dist/bin/fuel.js.map +1 -1
  4. package/dist/cleanup/finalize.d.ts.map +1 -1
  5. package/dist/cleanup/finalize.js +11 -3
  6. package/dist/cleanup/finalize.js.map +1 -1
  7. package/dist/commands/config-verify.d.ts.map +1 -1
  8. package/dist/commands/config-verify.js +14 -6
  9. package/dist/commands/config-verify.js.map +1 -1
  10. package/dist/commands/create-app.d.ts.map +1 -1
  11. package/dist/commands/create-app.js +41 -7
  12. package/dist/commands/create-app.js.map +1 -1
  13. package/dist/commands/infra-deploy.d.ts +15 -1
  14. package/dist/commands/infra-deploy.d.ts.map +1 -1
  15. package/dist/commands/infra-deploy.js +164 -18
  16. package/dist/commands/infra-deploy.js.map +1 -1
  17. package/dist/commands/infra-destroy.d.ts.map +1 -1
  18. package/dist/commands/infra-destroy.js +3 -3
  19. package/dist/commands/infra-destroy.js.map +1 -1
  20. package/dist/commands/infra-init.d.ts +91 -0
  21. package/dist/commands/infra-init.d.ts.map +1 -1
  22. package/dist/commands/infra-init.js +644 -113
  23. package/dist/commands/infra-init.js.map +1 -1
  24. package/dist/commands/infra-pull.d.ts +8 -0
  25. package/dist/commands/infra-pull.d.ts.map +1 -0
  26. package/dist/commands/infra-pull.js +81 -0
  27. package/dist/commands/infra-pull.js.map +1 -0
  28. package/dist/commands/list-modules.d.ts.map +1 -1
  29. package/dist/commands/list-modules.js +10 -3
  30. package/dist/commands/list-modules.js.map +1 -1
  31. package/dist/engines/convention.d.ts +2 -2
  32. package/dist/engines/convention.d.ts.map +1 -1
  33. package/dist/engines/convention.js +8 -6
  34. package/dist/engines/convention.js.map +1 -1
  35. package/dist/engines/dependencies.d.ts +2 -0
  36. package/dist/engines/dependencies.d.ts.map +1 -1
  37. package/dist/engines/dependencies.js.map +1 -1
  38. package/dist/engines/monorepo.d.ts.map +1 -1
  39. package/dist/engines/monorepo.js.map +1 -1
  40. package/dist/engines/template-source.d.ts.map +1 -1
  41. package/dist/engines/template-source.js +3 -1
  42. package/dist/engines/template-source.js.map +1 -1
  43. package/dist/index.d.ts.map +1 -1
  44. package/dist/index.js.map +1 -1
  45. package/dist/infra/azure-defaults.d.ts +49 -0
  46. package/dist/infra/azure-defaults.d.ts.map +1 -0
  47. package/dist/infra/azure-defaults.js +52 -0
  48. package/dist/infra/azure-defaults.js.map +1 -0
  49. package/dist/infra/azure-keyvault-client.d.ts +4 -0
  50. package/dist/infra/azure-keyvault-client.d.ts.map +1 -0
  51. package/dist/infra/azure-keyvault-client.js +57 -0
  52. package/dist/infra/azure-keyvault-client.js.map +1 -0
  53. package/dist/infra/azure-rbac.d.ts +11 -0
  54. package/dist/infra/azure-rbac.d.ts.map +1 -0
  55. package/dist/infra/azure-rbac.js +49 -0
  56. package/dist/infra/azure-rbac.js.map +1 -0
  57. package/dist/infra/azure-state-storage.d.ts +20 -0
  58. package/dist/infra/azure-state-storage.d.ts.map +1 -0
  59. package/dist/infra/azure-state-storage.js +229 -0
  60. package/dist/infra/azure-state-storage.js.map +1 -0
  61. package/dist/infra/config-loader.d.ts.map +1 -1
  62. package/dist/infra/config-loader.js.map +1 -1
  63. package/dist/infra/config-writer.js +1 -1
  64. package/dist/infra/credentials.d.ts +2 -2
  65. package/dist/infra/credentials.d.ts.map +1 -1
  66. package/dist/infra/credentials.js +8 -4
  67. package/dist/infra/credentials.js.map +1 -1
  68. package/dist/infra/dependency-checker.d.ts.map +1 -1
  69. package/dist/infra/dependency-checker.js.map +1 -1
  70. package/dist/infra/deployment-detect.d.ts +9 -0
  71. package/dist/infra/deployment-detect.d.ts.map +1 -0
  72. package/dist/infra/deployment-detect.js +53 -0
  73. package/dist/infra/deployment-detect.js.map +1 -0
  74. package/dist/infra/git-client.d.ts.map +1 -1
  75. package/dist/infra/git-client.js +6 -10
  76. package/dist/infra/git-client.js.map +1 -1
  77. package/dist/infra/github-client.d.ts +7 -0
  78. package/dist/infra/github-client.d.ts.map +1 -1
  79. package/dist/infra/github-client.js +47 -7
  80. package/dist/infra/github-client.js.map +1 -1
  81. package/dist/infra/github-secrets-client.d.ts.map +1 -1
  82. package/dist/infra/github-secrets-client.js +2 -2
  83. package/dist/infra/github-secrets-client.js.map +1 -1
  84. package/dist/infra/github-token-link.d.ts +4 -0
  85. package/dist/infra/github-token-link.d.ts.map +1 -0
  86. package/dist/infra/github-token-link.js +32 -0
  87. package/dist/infra/github-token-link.js.map +1 -0
  88. package/dist/infra/orchestrator.d.ts +4 -1
  89. package/dist/infra/orchestrator.d.ts.map +1 -1
  90. package/dist/infra/orchestrator.js +218 -63
  91. package/dist/infra/orchestrator.js.map +1 -1
  92. package/dist/infra/port-utils.d.ts.map +1 -1
  93. package/dist/infra/port-utils.js.map +1 -1
  94. package/dist/infra/preflight.d.ts.map +1 -1
  95. package/dist/infra/preflight.js +25 -11
  96. package/dist/infra/preflight.js.map +1 -1
  97. package/dist/infra/remote-secret.d.ts +14 -0
  98. package/dist/infra/remote-secret.d.ts.map +1 -0
  99. package/dist/infra/remote-secret.js +42 -0
  100. package/dist/infra/remote-secret.js.map +1 -0
  101. package/dist/infra/s3-state-bucket.d.ts.map +1 -1
  102. package/dist/infra/s3-state-bucket.js +8 -4
  103. package/dist/infra/s3-state-bucket.js.map +1 -1
  104. package/dist/infra/secrets-manager-client.d.ts.map +1 -1
  105. package/dist/infra/secrets-manager-client.js +8 -5
  106. package/dist/infra/secrets-manager-client.js.map +1 -1
  107. package/dist/infra/subprocess.js +1 -1
  108. package/dist/infra/template-engine.d.ts +14 -5
  109. package/dist/infra/template-engine.d.ts.map +1 -1
  110. package/dist/infra/template-engine.js +157 -39
  111. package/dist/infra/template-engine.js.map +1 -1
  112. package/dist/infra/tofu-runner.d.ts +4 -3
  113. package/dist/infra/tofu-runner.d.ts.map +1 -1
  114. package/dist/infra/tofu-runner.js +40 -34
  115. package/dist/infra/tofu-runner.js.map +1 -1
  116. package/dist/infra/types.d.ts +241 -17
  117. package/dist/infra/types.d.ts.map +1 -1
  118. package/dist/infra/types.js +419 -22
  119. package/dist/infra/types.js.map +1 -1
  120. package/dist/infra-templates/TODO-azure-prod.md +127 -0
  121. package/dist/infra-templates/modules/azure-container-app/main.tf +124 -0
  122. package/dist/infra-templates/modules/azure-container-app/outputs.tf +24 -0
  123. package/dist/infra-templates/modules/azure-container-app/variables.tf +80 -0
  124. package/dist/infra-templates/modules/azure-container-apps-environment/main.tf +18 -0
  125. package/dist/infra-templates/modules/azure-container-apps-environment/outputs.tf +14 -0
  126. package/dist/infra-templates/modules/azure-container-apps-environment/variables.tf +24 -0
  127. package/dist/infra-templates/modules/azure-container-registry/main.tf +10 -0
  128. package/dist/infra-templates/modules/azure-container-registry/outputs.tf +14 -0
  129. package/dist/infra-templates/modules/azure-container-registry/variables.tf +20 -0
  130. package/dist/infra-templates/modules/azure-front-door/main.tf +80 -0
  131. package/dist/infra-templates/modules/azure-front-door/outputs.tf +20 -0
  132. package/dist/infra-templates/modules/azure-front-door/variables.tf +26 -0
  133. package/dist/infra-templates/modules/azure-github-oidc/main.tf +48 -0
  134. package/dist/infra-templates/modules/azure-github-oidc/outputs.tf +9 -0
  135. package/dist/infra-templates/modules/azure-github-oidc/variables.tf +69 -0
  136. package/dist/infra-templates/modules/azure-key-vault/main.tf +21 -0
  137. package/dist/infra-templates/modules/azure-key-vault/outputs.tf +11 -0
  138. package/dist/infra-templates/modules/azure-key-vault/variables.tf +43 -0
  139. package/dist/infra-templates/modules/azure-monitor/main.tf +29 -0
  140. package/dist/infra-templates/modules/azure-monitor/outputs.tf +17 -0
  141. package/dist/infra-templates/modules/azure-monitor/variables.tf +32 -0
  142. package/dist/infra-templates/modules/azure-network/main.tf +134 -0
  143. package/dist/infra-templates/modules/azure-network/outputs.tf +44 -0
  144. package/dist/infra-templates/modules/azure-network/variables.tf +56 -0
  145. package/dist/infra-templates/modules/azure-postgresql-flexible/main.tf +34 -0
  146. package/dist/infra-templates/modules/azure-postgresql-flexible/outputs.tf +20 -0
  147. package/dist/infra-templates/modules/azure-postgresql-flexible/variables.tf +54 -0
  148. package/dist/infra-templates/modules/azure-redis-cache/main.tf +32 -0
  149. package/dist/infra-templates/modules/azure-redis-cache/outputs.tf +15 -0
  150. package/dist/infra-templates/modules/azure-redis-cache/variables.tf +30 -0
  151. package/dist/infra-templates/modules/azure-resource-group/main.tf +5 -0
  152. package/dist/infra-templates/modules/azure-resource-group/outputs.tf +11 -0
  153. package/dist/infra-templates/modules/azure-resource-group/variables.tf +16 -0
  154. package/dist/infra-templates/modules/azure-sql-database/main.tf +63 -0
  155. package/dist/infra-templates/modules/azure-sql-database/outputs.tf +20 -0
  156. package/dist/infra-templates/modules/azure-sql-database/variables.tf +78 -0
  157. package/dist/infra-templates/modules/azure-storage-account/main.tf +13 -0
  158. package/dist/infra-templates/modules/azure-storage-account/outputs.tf +16 -0
  159. package/dist/infra-templates/modules/azure-storage-account/variables.tf +38 -0
  160. package/dist/infra-templates/modules/cloud-watch/event-bridge.tf +15 -0
  161. package/dist/infra-templates/modules/cloud-watch/lambda.tf +84 -0
  162. package/dist/infra-templates/modules/cloud-watch/lambda_function.zip +0 -0
  163. package/dist/infra-templates/modules/cloud-watch/lambda_function_deploy.zip +0 -0
  164. package/dist/infra-templates/modules/cloud-watch/main.tf +156 -0
  165. package/dist/infra-templates/modules/cloud-watch/sns.tf +3 -0
  166. package/dist/infra-templates/modules/cloud-watch/variables.tf +38 -0
  167. package/dist/infra-templates/modules/ecs-core/alb.tf +126 -0
  168. package/dist/infra-templates/modules/ecs-core/cloudwatch.tf +48 -0
  169. package/dist/infra-templates/modules/ecs-core/iam.tf +95 -0
  170. package/dist/infra-templates/modules/ecs-core/main.tf +12 -0
  171. package/dist/infra-templates/modules/ecs-core/outputs.tf +44 -0
  172. package/dist/infra-templates/modules/ecs-core/secrets.tf +9 -0
  173. package/dist/infra-templates/modules/ecs-core/security_groups.tf +73 -0
  174. package/dist/infra-templates/modules/ecs-core/variables.tf +96 -0
  175. package/dist/infra-templates/modules/ecs-service/ecs_autoscaling.tf +51 -0
  176. package/dist/infra-templates/modules/ecs-service/ecs_service.tf +39 -0
  177. package/dist/infra-templates/modules/ecs-service/ecs_task_definition.tf +56 -0
  178. package/dist/infra-templates/modules/ecs-service/variables.tf +170 -0
  179. package/dist/infra-templates/modules/elastic-container-registry/main.tf +32 -0
  180. package/dist/infra-templates/modules/elastic-container-registry/outputs.tf +9 -0
  181. package/dist/infra-templates/modules/elastic-container-registry/variables.tf +25 -0
  182. package/dist/infra-templates/modules/github-oidc-role/main.tf +46 -0
  183. package/dist/infra-templates/modules/github-oidc-role/outputs.tf +4 -0
  184. package/dist/infra-templates/modules/github-oidc-role/variables.tf +11 -0
  185. package/dist/infra-templates/modules/guardduty/main.tf +8 -0
  186. package/dist/infra-templates/modules/iam/main.tf +205 -0
  187. package/dist/infra-templates/modules/iam/outputs.tf +3 -0
  188. package/dist/infra-templates/modules/iam/variables.tf +4 -0
  189. package/dist/infra-templates/modules/random-key/main.tf +11 -0
  190. package/dist/infra-templates/modules/random-key/outputs.tf +4 -0
  191. package/dist/infra-templates/modules/random-key/variables.tf +10 -0
  192. package/dist/infra-templates/modules/redis/main.tf +47 -0
  193. package/dist/infra-templates/modules/redis/outputs.tf +8 -0
  194. package/dist/infra-templates/modules/redis/variables.tf +20 -0
  195. package/dist/infra-templates/modules/relational-database-service/main.tf +44 -0
  196. package/dist/infra-templates/modules/relational-database-service/outputs.tf +13 -0
  197. package/dist/infra-templates/modules/relational-database-service/security-group.tf +15 -0
  198. package/dist/infra-templates/modules/relational-database-service/variables.tf +50 -0
  199. package/dist/infra-templates/modules/secret/main.tf +14 -0
  200. package/dist/infra-templates/modules/secret/outputs.tf +3 -0
  201. package/dist/infra-templates/modules/secret/variables.tf +8 -0
  202. package/dist/infra-templates/modules/simple-storage-service/main.tf +28 -0
  203. package/dist/infra-templates/modules/simple-storage-service/variables.tf +4 -0
  204. package/dist/infra-templates/modules/vpc/data.tf +2 -0
  205. package/dist/infra-templates/modules/vpc/main.tf +76 -0
  206. package/dist/infra-templates/modules/vpc/outputs.tf +23 -0
  207. package/dist/infra-templates/modules/vpc/variables.tf +5 -0
  208. package/dist/infra-templates/package.json +6 -0
  209. package/dist/infra-templates/templates/azure/MANUAL_DEPLOY.md +168 -0
  210. package/dist/infra-templates/templates/azure/backend.tf +8 -0
  211. package/dist/infra-templates/templates/azure/data.tf +21 -0
  212. package/dist/infra-templates/templates/azure/default.tfvars +0 -0
  213. package/dist/infra-templates/templates/azure/locals.tf +116 -0
  214. package/dist/infra-templates/templates/azure/main.tf +421 -0
  215. package/dist/infra-templates/templates/azure/outputs.tf +40 -0
  216. package/dist/infra-templates/templates/azure/providers.tf +65 -0
  217. package/dist/infra-templates/templates/azure/variables.tf +69 -0
  218. package/dist/infra-templates/templates/azure/workflows/build_and_deploy.yml +155 -0
  219. package/dist/infra-templates/templates/azure/workflows/tests.yml +63 -0
  220. package/dist/infra-templates/templates/ecs/README.md +235 -0
  221. package/dist/infra-templates/templates/ecs/backend.tf +7 -0
  222. package/dist/infra-templates/templates/ecs/data.tf +6 -0
  223. package/dist/infra-templates/templates/ecs/default.tfvars +1 -0
  224. package/dist/infra-templates/templates/ecs/locals.tf +97 -0
  225. package/dist/infra-templates/templates/ecs/main.tf +185 -0
  226. package/dist/infra-templates/templates/ecs/outputs.tf +42 -0
  227. package/dist/infra-templates/templates/ecs/providers.tf +21 -0
  228. package/dist/infra-templates/templates/ecs/variables.tf +105 -0
  229. package/dist/infra-templates/templates/ecs/workflows/build_and_deploy.yml +188 -0
  230. package/dist/infra-templates/templates/ecs/workflows/tests.yml +65 -0
  231. package/package.json +10 -2
  232. package/schema/fuel.schema.json +570 -91
@@ -0,0 +1,155 @@
1
+ name: Deploy REPLACEME image
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - BRANCHREPLACE
7
+ paths:
8
+ - PATHSREPLACE
9
+
10
+ concurrency:
11
+ group: ${{ github.workflow }}-${{ github.ref_name }}
12
+ cancel-in-progress: true
13
+
14
+ env:
15
+ DEPLOY_ENV: ${{ github.ref_name == 'main' && 'production' || github.ref_name == 'staging' && 'staging' || github.ref_name == 'dev' && 'development' }}
16
+
17
+ jobs:
18
+ build:
19
+ runs-on: ubuntu-latest
20
+ timeout-minutes: 30
21
+ if: github.ref == 'refs/heads/BRANCHREPLACE'
22
+ permissions:
23
+ id-token: write
24
+ contents: read
25
+ deployments: write
26
+
27
+ steps:
28
+ - name: Checkout Repository
29
+ uses: actions/checkout@v7
30
+ with:
31
+ fetch-depth: 0
32
+
33
+ - name: Set Outputs
34
+ id: vars
35
+ run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
36
+
37
+ - name: Azure Login (OIDC)
38
+ uses: azure/login@v2
39
+ with:
40
+ client-id: ${{ secrets.AZURE_CLIENT_ID }}
41
+ tenant-id: ${{ secrets.AZURE_TENANT_ID }}
42
+ subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
43
+
44
+ - name: Log in to Azure Container Registry
45
+ run: az acr login --name ACR_NAME
46
+
47
+ - name: Set up Docker Buildx
48
+ uses: docker/setup-buildx-action@v4
49
+
50
+ - name: Build and push REPLACEME image
51
+ uses: docker/build-push-action@v7
52
+ env:
53
+ ACR_REGISTRY: ${{ secrets.ACR_LOGIN_SERVER }}
54
+ IMAGE_SHA: ${{ steps.vars.outputs.sha_short }}
55
+ with:
56
+ context: ./
57
+ file: DOCKERFILE
58
+ push: true
59
+ tags: ${{ env.ACR_REGISTRY }}/REPLACEME:${{ steps.vars.outputs.sha_short }}
60
+ build-args: |
61
+ BUILDARGS
62
+
63
+ - name: Start GitHub Deployment
64
+ uses: bobheadxi/deployments@v1
65
+ id: deployment-start
66
+ with:
67
+ step: start
68
+ token: ${{ secrets.GITHUB_TOKEN }}
69
+ env: ${{ env.DEPLOY_ENV }}
70
+ ref: ${{ github.sha }}
71
+ desc: "Deploying REPLACEME image to Azure Container Apps"
72
+
73
+ - name: Configure ACR pull credential
74
+ # Not set by Terraform on purpose — at first `tofu apply` this Container App's
75
+ # system-assigned identity doesn't have AcrPull yet (that role assignment needs
76
+ # the identity to exist first), so configuring the registry at create time made
77
+ # Azure hang validating it. Safe to re-run every deploy (idempotent).
78
+ run: |
79
+ az containerapp registry set \
80
+ --name CONTAINER_APP_NAME \
81
+ --resource-group RESOURCE_GROUP \
82
+ --server ${{ secrets.ACR_LOGIN_SERVER }} \
83
+ --identity system
84
+
85
+ - name: Deploy new revision to Container Apps
86
+ run: |
87
+ az containerapp update \
88
+ --name CONTAINER_APP_NAME \
89
+ --resource-group RESOURCE_GROUP \
90
+ --image ${{ secrets.ACR_LOGIN_SERVER }}/REPLACEME:${{ steps.vars.outputs.sha_short }}
91
+
92
+ - name: Finish GitHub Deployment
93
+ if: always() # Ensures this runs even if previous step fails
94
+ uses: bobheadxi/deployments@v1
95
+ with:
96
+ step: finish
97
+ token: ${{ secrets.GITHUB_TOKEN }}
98
+ env: ${{ env.DEPLOY_ENV }}
99
+ status: ${{ job.status }}
100
+ deployment_id: ${{ steps.deployment-start.outputs.deployment_id }}
101
+
102
+ notify-slack:
103
+ needs: build
104
+ runs-on: ubuntu-latest
105
+ if: failure()
106
+ steps:
107
+ - name: Send Slack Notification on Failure
108
+ uses: slackapi/slack-github-action@v1.26.0
109
+ with:
110
+ payload: |
111
+ {
112
+ "blocks": [
113
+ {
114
+ "type": "header",
115
+ "text": {
116
+ "type": "plain_text",
117
+ "text": "🚨 Workflow Failed: `${{ github.workflow }}`"
118
+ }
119
+ },
120
+ {
121
+ "type": "section",
122
+ "fields": [
123
+ {
124
+ "type": "mrkdwn",
125
+ "text": "*Repository:*\n<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>"
126
+ },
127
+ {
128
+ "type": "mrkdwn",
129
+ "text": "*Branch:*\n`${{ github.ref_name }}`"
130
+ },
131
+ {
132
+ "type": "mrkdwn",
133
+ "text": "*Triggered by:*\n`${{ github.triggering_actor }}`"
134
+ }
135
+ ]
136
+ },
137
+ {
138
+ "type": "actions",
139
+ "elements": [
140
+ {
141
+ "type": "button",
142
+ "text": {
143
+ "type": "plain_text",
144
+ "text": "View Workflow Run"
145
+ },
146
+ "url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
147
+ "style": "danger"
148
+ }
149
+ ]
150
+ }
151
+ ]
152
+ }
153
+ env:
154
+ SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
155
+ SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
@@ -0,0 +1,63 @@
1
+ # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3
+
4
+ name: CI tests
5
+
6
+ on:
7
+ push:
8
+ branches:
9
+ - '*'
10
+ - '!workflow-creation'
11
+ pull_request:
12
+ branches:
13
+ - '*'
14
+ - '!workflow-creation'
15
+
16
+ env:
17
+ REDIS_URL: ""
18
+ DATABASE_URL: "postgresql://postgres:postgres@localhost:5432/postgres"
19
+ SECRET_KEY_BASE: "xx"
20
+ NODE_OPTIONS: --max-old-space-size=8192
21
+
22
+ jobs:
23
+ build:
24
+
25
+ runs-on: ubuntu-latest
26
+ defaults:
27
+ run:
28
+ working-directory: ./
29
+
30
+ # Service containers to run with `container-job`
31
+ services:
32
+ # Label used to access the service container
33
+ postgres:
34
+ # Docker Hub image
35
+ image: postgres:16
36
+ # Provide the password for postgres
37
+ env:
38
+ POSTGRES_PASSWORD: postgres
39
+ # Set health checks to wait until postgres has started
40
+ options: >-
41
+ --health-cmd pg_isready
42
+ --health-interval 10s
43
+ --health-timeout 5s
44
+ --health-retries 5
45
+ ports:
46
+ # Maps tcp port 5432 on service container to the host
47
+ - 5432:5432
48
+
49
+ strategy:
50
+ matrix:
51
+ node-version: [lts/*]
52
+ # ruby-version: ['3.3.1']
53
+ # See supported Node.js release schedule at https://nodejs.org/en/about/releases/
54
+
55
+ steps:
56
+ - uses: actions/checkout@v7
57
+ - name: Use Node.js ${{ matrix.node-version }}
58
+ uses: actions/setup-node@v6
59
+ with:
60
+ node-version: ${{ matrix.node-version }}
61
+ - run: yarn install
62
+ - run: yarn lint
63
+ - run: yarn test
@@ -0,0 +1,235 @@
1
+ # 🌍 Terraform Project: Infrastructure Setup
2
+
3
+ This Terraform project is designed to first create a centralized secret in AWS Secrets Manager, which serves as the foundation for provisioning the rest of the infrastructure.
4
+
5
+ ## ✅ Prerequisites
6
+
7
+ Before you begin, ensure the following:
8
+
9
+ - [Terraform](https://www.terraform.io/downloads.html) is installed and available in your `PATH`
10
+ - AWS CLI is configured with appropriate credentials and region
11
+ - Permissions for creating the environment
12
+ - AmazonECS_FullAccess
13
+ - AmazonElastiCacheFullAccess
14
+ - AmazonRDSFullAccess
15
+ - AmazonS3FullAccess
16
+ - AWSCloudTrail_FullAccess
17
+ - AWSCodeBuildAdminAccess
18
+ - AWSCodePipeline_FullAccess
19
+ - CloudWatchFullAccessV2
20
+ - IAMFullAccess
21
+
22
+ ### 🌐 Creating an ACM Certificate for Your Domain
23
+
24
+ To deploy secure resources using the Infrastructure Automation Script, follow these steps to create an ACM certificate for your domain:
25
+
26
+ 1. **Log in to AWS Console**: Sign in to your AWS Management Console using your AWS account credentials.
27
+
28
+ 2. **Navigate to ACM**: Search for "ACM" in the AWS Management Console search bar and select the "AWS Certificate Manager" service.
29
+
30
+ 3. **Request a Certificate**:
31
+ - Click the "Request a certificate" button.
32
+ - Choose "Request a public certificate" and click "Next".
33
+
34
+ 4. **Add Domain Names**:
35
+ - In the "Add domain names" section, enter your domain name (e.g., `example.com`) and any subdomains you plan to use (e.g., `*.example.com`).
36
+ - Optionally, add additional domain names (SANs) if needed.
37
+ - Click "Next".
38
+
39
+ 5. **Validation**:
40
+ - Choose a validation method (e.g., DNS validation) to prove domain ownership.
41
+ - Follow the provided instructions to complete the validation process.
42
+
43
+ 6. **Review and Confirm**:
44
+ - Review the domain names and validation method you've selected.
45
+ - Click "Confirm and request" to submit your certificate request.
46
+
47
+ 7. **Certificate Issued**:
48
+ - Once validation is successful, the certificate status will change to "Issued".
49
+
50
+ 8. **Copy the ARN**:
51
+ - Click on the issued certificate to view its details.
52
+ - Copy the "Amazon Resource Name (ARN)" of the certificate and paste it into your `config.json` under the SSL session section.
53
+
54
+ ---
55
+
56
+ ### 📝 Additional Observations
57
+
58
+ - **config.json Adjustments**: If you do not have the `config.json` file, please note that there are a few parameters that need to be manually adjusted:
59
+ - **FRONT_END_URL**: Ensure this is updated to the correct domain for your front-end application.
60
+ - **HOST_URL**: Similarly, this URL is currently pointing to Flatirons' domain, and you will need to change it to match your own domain.
61
+ - **ssl**: Copy the certificate arn from the previous step
62
+
63
+ ### 🌱 How to Modify app.json
64
+
65
+ ##### 1. **SSL Certificate ARN**
66
+
67
+ - Replace the `"ssl"` field with the correct ARN for your SSL certificate, which you should have obtained through AWS Certificate Manager (ACM):
68
+
69
+ ```json
70
+ "ssl": "arn:aws:acm:========================="
71
+ ```
72
+
73
+ ##### 2. **Access IP Range**
74
+
75
+ - Update the `"access_ip_range"` field to specify the IP range that can access your database. You can enter your IP address or any other IP range:
76
+
77
+ ```json
78
+ "access_ip_range": "73.153.163.118/32"
79
+ ```
80
+
81
+ ##### 3. **Cognito API Key Header**
82
+
83
+ - Ensure the `"cognito_apikey_header"` field points to the header for API key authentication if you are using Cognito for authentication:
84
+
85
+ ```json
86
+ "cognito_apikey_header": "x-api-key"
87
+ ```
88
+
89
+ ##### 4. **Slack Webhook URL**
90
+
91
+ - Provide your Slack Webhook URL to receive alarms. If you don't have one, you can use the default placeholder URL:
92
+
93
+ ```json
94
+ "slack_webhook_url": "Enter webhook URL to receive alarms or set default value https://hooks.slack.com/services/YOUR_WORKSPACE_ID/YOUR_CHANNEL_ID/YOUR_WEBHOOK_TOKEN"
95
+ ```
96
+
97
+ ##### 5. **Environment Setup**
98
+
99
+ - Update the `"name"` field with your project name:
100
+
101
+ ```json
102
+ "name": "your-project"
103
+ ```
104
+
105
+ - The `"deployment"` field specifies the deployment method (ecs or eks):
106
+
107
+ ```json
108
+ "deployment": "ecs"
109
+ ```
110
+
111
+ Nota: This application only works with ecs
112
+
113
+ ##### 6. **Application Modules Configuration**
114
+
115
+ - Modify the `"modules"` field to set the options for the different modules you are using in your application. For instance:
116
+
117
+ ```json
118
+ "modules": "[{'name': 'auth', 'options': {'two_factor': False, 'invitation_only': False, 'remove_sign_up_phone': False}}, {'name': 'team', 'options': {'remove': True}}, {'name': 'billing', 'options': {'remove_stripe': True}}, {'name': 'e2e', 'options': {'remove': True}}]"
119
+ ```
120
+
121
+ ##### 7. **Application Configurations for API and Web**
122
+
123
+ - Modify the application configuration under the `"apps"` section. For each app (e.g., `projectname-dev-api`, `projectname-staging-api`), update the following:
124
+
125
+ - **Domain Name**: Set the domain for each app.
126
+ - **API Keys and Secrets**: Ensure all required API keys and secrets (like Snowflake, JWT) are correctly configured.
127
+ - **Environment Variables**: Update any specific environment variables (e.g., `HOST_URL`, `FRONT_END_URL`).
128
+
129
+ Example for the **dev API app**:
130
+
131
+ ```json
132
+ "apps": [
133
+ {
134
+ "name": "projectname-dev-api",
135
+ "technology": "nest",
136
+ "dockerfile": "apps/api/Dockerfile",
137
+ "health_check_path": "/health",
138
+ "domain": "projectname-dev-api.******.com",
139
+ "port": 3000,
140
+ "cognito": false,
141
+ "postgres": false,
142
+ "redis": false,
143
+ "variables": {
144
+ "NODE_TLS_REJECT_UNAUTHORIZED": 0,
145
+ "API_KEY_HEADER": "x-api-key",
146
+ "ENCRYPTION_PASSWORD": "xxxxxxxxxxxxxxx",
147
+ "HOST_URL": "https://projectname-dev-api.****.com",
148
+ "FRONT_END_URL": "https://projectname-dev.******.com",
149
+ "APP_NAME": "AppName",
150
+ "APP_COMPANY": "Flatirons",
151
+ "ADMIN_JS_EMAIL": "admin@flatirons.com",
152
+ "ADMIN_JS_PASSWORD": "xxxxxxxxxxxxxxxxx!!!"
153
+ }
154
+ }
155
+ ]
156
+ ```
157
+
158
+ ---
159
+
160
+ ## 🚀 Usage
161
+
162
+ ### 1. Verify Terraform Installation
163
+
164
+ Make sure Terraform is correctly installed by running the following command:
165
+
166
+ ```bash
167
+ terraform -v
168
+ ```
169
+
170
+ ### 2. Initialize and Create the Centralized Secret
171
+
172
+ To begin, initialize the project and apply the `secret-main` module to create the centralized secret. This step is required only once, unless the secret is already created.
173
+ Note: For this step the config.json file is mandatory, please request it from the project administrator and place it at the root of the project directory
174
+
175
+ Region=fill your region below (if it is different from us-east-1)
176
+
177
+ ```bash
178
+ cd modules/secret-main
179
+ terraform init -backend-config="region=us-east-1"
180
+ terraform plan
181
+ terraform apply
182
+ ```
183
+
184
+ ### 3. Apply the Full Infrastructure
185
+
186
+ After the centralized secret is in place, proceed to initialize and apply the full infrastructure:
187
+
188
+ Region=fill your region below (if it is different from us-east-1)
189
+
190
+ ```bash
191
+ terraform init -backend-config="region=us-east-1"
192
+ terraform plan
193
+ terraform apply
194
+ ```
195
+
196
+ ---
197
+
198
+ ## 📁 Project Structure
199
+
200
+ ```bash
201
+ .
202
+ ├── modules/ # ALL Terraform Modules
203
+ │ └── secret-main/ # Module for creating the centralized secret
204
+ ├── main.tf # Main Terraform entrypoint
205
+ ├── variables.tf # Input variable definitions
206
+ ├── outputs.tf # Output values
207
+ ├── providers.tf # Provider settings
208
+ ├── locals.tf # Provider settings
209
+ └── README.md # Project documentation
210
+ ```
211
+
212
+ ---
213
+
214
+ ## 🔐 Security Considerations
215
+
216
+ - **Never hardcode secrets**: Use variables and Secrets Manager for sensitive data.
217
+ - **Restrict access**: Implement AWS IAM policies to control who can access the centralized secret.
218
+ - **Remote state encryption**: Ensure remote state is encrypted, especially when using shared backends like S3.
219
+
220
+ ---
221
+
222
+ ## 🧹 Clean Up
223
+
224
+ To destroy all infrastructure and resources, run the following command:
225
+
226
+ ```bash
227
+ terraform destroy
228
+ ```
229
+
230
+ To only destroy the centralized secret:
231
+
232
+ ```bash
233
+ cd modules/secret-main
234
+ terraform destroy
235
+ ```
@@ -0,0 +1,7 @@
1
+ terraform {
2
+ backend "s3" {
3
+ bucket = "{project_name}-infrastructure-tf-{unique_suffix}"
4
+ key = "terraform.tfstate"
5
+ region = "{aws_region}"
6
+ }
7
+ }
@@ -0,0 +1,6 @@
1
+ data "aws_caller_identity" "current" {
2
+ }
3
+
4
+ data "aws_secretsmanager_secret_version" "this" {
5
+ secret_id = "${var.project_name}-infrastructure-variables"
6
+ }
@@ -0,0 +1 @@
1
+ access_ip_range = ""
@@ -0,0 +1,97 @@
1
+ locals {
2
+ credentials = yamldecode(
3
+ data.aws_secretsmanager_secret_version.this.secret_string
4
+ )
5
+ apps = yamldecode(
6
+ data.aws_secretsmanager_secret_version.this.secret_string
7
+ ).apps
8
+
9
+ # Sensitive variables per app — kept separate so they never leak into plan output
10
+ app_variables = { for i in local.apps : nonsensitive(i.name) => try(i.variables, {}) }
11
+
12
+ worker_list = nonsensitive(flatten([for i in local.apps: [
13
+ [for worker in try(i.workers, []): {
14
+ app_name: i.name,
15
+ technology: i.technology,
16
+ dockerfile: worker.dockerfile,
17
+ worker_name: worker.name,
18
+ branch: i.branch,
19
+ template_repo_branch: i.template_repo_branch,
20
+ cpu_units: try(i.cpu_units, var.cpu_units),
21
+ memory_units: try(i.memory_units, var.memory_units),
22
+ build_env: length(try(i.build_env, {})) > 0 ? join("\n ", [for k, v in i.build_env : "${upper(k)}=${v}"]) : ""
23
+ }]
24
+ ]]))
25
+
26
+ app_list = nonsensitive([for i in local.apps :
27
+ {
28
+ app_name: i.name,
29
+ technology: i.technology,
30
+ port: i.port,
31
+ domain: i.domain,
32
+ health_check_path: i.health_check_path,
33
+
34
+ postgres: try(i.postgres, false),
35
+ redis: try(i.redis, false),
36
+ dockerfile: i.dockerfile,
37
+ branch: i.branch,
38
+ template_repo_branch: i.template_repo_branch,
39
+ db_instance_type: try(i.db_instance_type, var.db_instance_type),
40
+ db_allocated_storage: try(i.db_allocated_storage, var.db_allocated_storage),
41
+ cpu_units: try(i.cpu_units, var.cpu_units),
42
+ memory_units: try(i.memory_units, var.memory_units),
43
+ redis_instance_type: try(i.redis_instance_type, var.redis_instance_type),
44
+ build_env: length(try(i.build_env, {})) > 0 ? join("\n ", [for k, v in i.build_env : "${upper(k)}=${v}"]) : ""
45
+ build_env_map: try(i.build_env, {})
46
+
47
+ }
48
+ ])
49
+
50
+ env_vars = {
51
+ for app in local.app_list :
52
+ app.app_name => merge(
53
+
54
+ app.technology == "react" ? {
55
+ NEXT_PUBLIC_API_HOST = app.build_env_map["NEXT_PUBLIC_API_HOST"]
56
+ } : {},
57
+
58
+ app.technology == "nest" ? {
59
+ NODE_TLS_REJECT_UNAUTHORIZED = "0"
60
+ API_KEY_HEADER = "x-api-key"
61
+ ENCRYPTION_PASSWORD = module.random_key.value
62
+ HOST_URL = try(local.app_variables[app.app_name].host_url, "https://${app.domain}")
63
+ FRONT_END_URL = try(local.app_variables[app.app_name].front_end_url, "https://${app.app_name}")
64
+ APP_NAME = "Fuel App"
65
+ APP_COMPANY = try(local.app_variables[app.app_name].app_company, "Swovo")
66
+ AWS_ACCESS_KEY_ID = var.aws_access_key_id
67
+ AWS_SECRET_ACCESS_KEY = var.aws_secret_access_key
68
+ } : {},
69
+
70
+
71
+ app.redis == true ? {
72
+ REDIS_URL = "redis://${module.redis[app.app_name].elasticache_cluster_hostname}:6379/0"
73
+ } : {},
74
+
75
+ app.postgres == true ? {
76
+ DATABASE_PORT = "5432"
77
+ DATABASE_USERNAME = var.db_username
78
+ DATABASE_PASSWORD = module.database[app.app_name].db_password
79
+ DATABASE_NAME = var.db_name
80
+ DATABASE_HOST = split(":", module.database[app.app_name].db_hostname)[0]
81
+ DATABASE_URL = "postgresql://${var.db_username}:${module.database[app.app_name].db_password}@${module.database[app.app_name].db_hostname}/${var.db_name}"
82
+ } : {},
83
+
84
+ contains(["react", "nest"], app.technology) ? {
85
+ NODE_OPTIONS = "--max-old-space-size=${floor(app.memory_units * 0.75)}"
86
+ } : {},
87
+
88
+ length(try(local.app_variables[app.app_name], {})) > 0 ? {
89
+ for k, v in local.app_variables[app.app_name] : upper(k) => v
90
+ } : {}
91
+ )
92
+ }
93
+ secret_arns = {
94
+ for k, mod in module.secret_manager :
95
+ k => mod.secret_arn
96
+ }
97
+ }