@swovohq/fuel 0.2.2-alpha.87 → 0.2.2-alpha.89

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 (190) hide show
  1. package/README.md +65 -2
  2. package/dist/bin/fuel.js +10 -31
  3. package/dist/bin/fuel.js.map +1 -1
  4. package/dist/commands/config-verify.d.ts.map +1 -1
  5. package/dist/commands/config-verify.js +14 -6
  6. package/dist/commands/config-verify.js.map +1 -1
  7. package/dist/commands/create-app.d.ts.map +1 -1
  8. package/dist/commands/create-app.js +10 -3
  9. package/dist/commands/create-app.js.map +1 -1
  10. package/dist/commands/infra-deploy.d.ts +4 -0
  11. package/dist/commands/infra-deploy.d.ts.map +1 -1
  12. package/dist/commands/infra-deploy.js +75 -43
  13. package/dist/commands/infra-deploy.js.map +1 -1
  14. package/dist/commands/infra-destroy.js +3 -3
  15. package/dist/commands/infra-destroy.js.map +1 -1
  16. package/dist/commands/infra-init.d.ts +91 -0
  17. package/dist/commands/infra-init.d.ts.map +1 -1
  18. package/dist/commands/infra-init.js +510 -80
  19. package/dist/commands/infra-init.js.map +1 -1
  20. package/dist/commands/infra-pull.d.ts.map +1 -1
  21. package/dist/commands/infra-pull.js +6 -5
  22. package/dist/commands/infra-pull.js.map +1 -1
  23. package/dist/infra/azure-defaults.d.ts +49 -0
  24. package/dist/infra/azure-defaults.d.ts.map +1 -0
  25. package/dist/infra/azure-defaults.js +52 -0
  26. package/dist/infra/azure-defaults.js.map +1 -0
  27. package/dist/infra/azure-keyvault-client.d.ts +4 -0
  28. package/dist/infra/azure-keyvault-client.d.ts.map +1 -0
  29. package/dist/infra/azure-keyvault-client.js +57 -0
  30. package/dist/infra/azure-keyvault-client.js.map +1 -0
  31. package/dist/infra/azure-rbac.d.ts +11 -0
  32. package/dist/infra/azure-rbac.d.ts.map +1 -0
  33. package/dist/infra/azure-rbac.js +47 -0
  34. package/dist/infra/azure-rbac.js.map +1 -0
  35. package/dist/infra/azure-state-storage.d.ts +20 -0
  36. package/dist/infra/azure-state-storage.d.ts.map +1 -0
  37. package/dist/infra/azure-state-storage.js +229 -0
  38. package/dist/infra/azure-state-storage.js.map +1 -0
  39. package/dist/infra/credentials.d.ts +2 -2
  40. package/dist/infra/credentials.d.ts.map +1 -1
  41. package/dist/infra/credentials.js +8 -4
  42. package/dist/infra/credentials.js.map +1 -1
  43. package/dist/infra/deployment-detect.d.ts +9 -0
  44. package/dist/infra/deployment-detect.d.ts.map +1 -0
  45. package/dist/infra/deployment-detect.js +53 -0
  46. package/dist/infra/deployment-detect.js.map +1 -0
  47. package/dist/infra/github-client.d.ts +6 -0
  48. package/dist/infra/github-client.d.ts.map +1 -1
  49. package/dist/infra/github-client.js +31 -4
  50. package/dist/infra/github-client.js.map +1 -1
  51. package/dist/infra/github-token-link.d.ts +4 -0
  52. package/dist/infra/github-token-link.d.ts.map +1 -0
  53. package/dist/infra/github-token-link.js +28 -0
  54. package/dist/infra/github-token-link.js.map +1 -0
  55. package/dist/infra/orchestrator.d.ts +4 -1
  56. package/dist/infra/orchestrator.d.ts.map +1 -1
  57. package/dist/infra/orchestrator.js +203 -66
  58. package/dist/infra/orchestrator.js.map +1 -1
  59. package/dist/infra/preflight.d.ts.map +1 -1
  60. package/dist/infra/preflight.js +17 -9
  61. package/dist/infra/preflight.js.map +1 -1
  62. package/dist/infra/remote-secret.d.ts +14 -0
  63. package/dist/infra/remote-secret.d.ts.map +1 -0
  64. package/dist/infra/remote-secret.js +42 -0
  65. package/dist/infra/remote-secret.js.map +1 -0
  66. package/dist/infra/template-engine.d.ts +13 -4
  67. package/dist/infra/template-engine.d.ts.map +1 -1
  68. package/dist/infra/template-engine.js +141 -49
  69. package/dist/infra/template-engine.js.map +1 -1
  70. package/dist/infra/tofu-runner.d.ts +4 -3
  71. package/dist/infra/tofu-runner.d.ts.map +1 -1
  72. package/dist/infra/tofu-runner.js +36 -27
  73. package/dist/infra/tofu-runner.js.map +1 -1
  74. package/dist/infra/types.d.ts +239 -16
  75. package/dist/infra/types.d.ts.map +1 -1
  76. package/dist/infra/types.js +206 -18
  77. package/dist/infra/types.js.map +1 -1
  78. package/dist/infra-templates/TODO-azure-prod.md +119 -0
  79. package/dist/infra-templates/modules/azure-container-app/main.tf +124 -0
  80. package/dist/infra-templates/modules/azure-container-app/outputs.tf +24 -0
  81. package/dist/infra-templates/modules/azure-container-app/variables.tf +80 -0
  82. package/dist/infra-templates/modules/azure-container-apps-environment/main.tf +18 -0
  83. package/dist/infra-templates/modules/azure-container-apps-environment/outputs.tf +14 -0
  84. package/dist/infra-templates/modules/azure-container-apps-environment/variables.tf +24 -0
  85. package/dist/infra-templates/modules/azure-container-registry/main.tf +10 -0
  86. package/dist/infra-templates/modules/azure-container-registry/outputs.tf +14 -0
  87. package/dist/infra-templates/modules/azure-container-registry/variables.tf +20 -0
  88. package/dist/infra-templates/modules/azure-front-door/main.tf +80 -0
  89. package/dist/infra-templates/modules/azure-front-door/outputs.tf +20 -0
  90. package/dist/infra-templates/modules/azure-front-door/variables.tf +26 -0
  91. package/dist/infra-templates/modules/azure-github-oidc/main.tf +48 -0
  92. package/dist/infra-templates/modules/azure-github-oidc/outputs.tf +9 -0
  93. package/dist/infra-templates/modules/azure-github-oidc/variables.tf +69 -0
  94. package/dist/infra-templates/modules/azure-key-vault/main.tf +21 -0
  95. package/dist/infra-templates/modules/azure-key-vault/outputs.tf +11 -0
  96. package/dist/infra-templates/modules/azure-key-vault/variables.tf +43 -0
  97. package/dist/infra-templates/modules/azure-monitor/main.tf +29 -0
  98. package/dist/infra-templates/modules/azure-monitor/outputs.tf +17 -0
  99. package/dist/infra-templates/modules/azure-monitor/variables.tf +32 -0
  100. package/dist/infra-templates/modules/azure-network/main.tf +134 -0
  101. package/dist/infra-templates/modules/azure-network/outputs.tf +44 -0
  102. package/dist/infra-templates/modules/azure-network/variables.tf +56 -0
  103. package/dist/infra-templates/modules/azure-postgresql-flexible/main.tf +34 -0
  104. package/dist/infra-templates/modules/azure-postgresql-flexible/outputs.tf +20 -0
  105. package/dist/infra-templates/modules/azure-postgresql-flexible/variables.tf +54 -0
  106. package/dist/infra-templates/modules/azure-redis-cache/main.tf +32 -0
  107. package/dist/infra-templates/modules/azure-redis-cache/outputs.tf +15 -0
  108. package/dist/infra-templates/modules/azure-redis-cache/variables.tf +30 -0
  109. package/dist/infra-templates/modules/azure-resource-group/main.tf +5 -0
  110. package/dist/infra-templates/modules/azure-resource-group/outputs.tf +11 -0
  111. package/dist/infra-templates/modules/azure-resource-group/variables.tf +16 -0
  112. package/dist/infra-templates/modules/azure-sql-database/main.tf +63 -0
  113. package/dist/infra-templates/modules/azure-sql-database/outputs.tf +20 -0
  114. package/dist/infra-templates/modules/azure-sql-database/variables.tf +78 -0
  115. package/dist/infra-templates/modules/azure-storage-account/main.tf +13 -0
  116. package/dist/infra-templates/modules/azure-storage-account/outputs.tf +16 -0
  117. package/dist/infra-templates/modules/azure-storage-account/variables.tf +38 -0
  118. package/dist/infra-templates/modules/cloud-watch/event-bridge.tf +15 -0
  119. package/dist/infra-templates/modules/cloud-watch/lambda.tf +84 -0
  120. package/dist/infra-templates/modules/cloud-watch/lambda_function.zip +0 -0
  121. package/dist/infra-templates/modules/cloud-watch/lambda_function_deploy.zip +0 -0
  122. package/dist/infra-templates/modules/cloud-watch/main.tf +156 -0
  123. package/dist/infra-templates/modules/cloud-watch/sns.tf +3 -0
  124. package/dist/infra-templates/modules/cloud-watch/variables.tf +38 -0
  125. package/dist/infra-templates/modules/ecs-core/alb.tf +126 -0
  126. package/dist/infra-templates/modules/ecs-core/cloudwatch.tf +48 -0
  127. package/dist/infra-templates/modules/ecs-core/iam.tf +95 -0
  128. package/dist/infra-templates/modules/ecs-core/main.tf +12 -0
  129. package/dist/infra-templates/modules/ecs-core/outputs.tf +44 -0
  130. package/dist/infra-templates/modules/ecs-core/secrets.tf +9 -0
  131. package/dist/infra-templates/modules/ecs-core/security_groups.tf +73 -0
  132. package/dist/infra-templates/modules/ecs-core/variables.tf +96 -0
  133. package/dist/infra-templates/modules/ecs-service/ecs_autoscaling.tf +51 -0
  134. package/dist/infra-templates/modules/ecs-service/ecs_service.tf +39 -0
  135. package/dist/infra-templates/modules/ecs-service/ecs_task_definition.tf +56 -0
  136. package/dist/infra-templates/modules/ecs-service/variables.tf +170 -0
  137. package/dist/infra-templates/modules/elastic-container-registry/main.tf +32 -0
  138. package/dist/infra-templates/modules/elastic-container-registry/outputs.tf +9 -0
  139. package/dist/infra-templates/modules/elastic-container-registry/variables.tf +25 -0
  140. package/dist/infra-templates/modules/github-oidc-role/main.tf +46 -0
  141. package/dist/infra-templates/modules/github-oidc-role/outputs.tf +4 -0
  142. package/dist/infra-templates/modules/github-oidc-role/variables.tf +11 -0
  143. package/dist/infra-templates/modules/guardduty/main.tf +8 -0
  144. package/dist/infra-templates/modules/iam/main.tf +205 -0
  145. package/dist/infra-templates/modules/iam/outputs.tf +3 -0
  146. package/dist/infra-templates/modules/iam/variables.tf +4 -0
  147. package/dist/infra-templates/modules/random-key/main.tf +11 -0
  148. package/dist/infra-templates/modules/random-key/outputs.tf +4 -0
  149. package/dist/infra-templates/modules/random-key/variables.tf +10 -0
  150. package/dist/infra-templates/modules/redis/main.tf +47 -0
  151. package/dist/infra-templates/modules/redis/outputs.tf +8 -0
  152. package/dist/infra-templates/modules/redis/variables.tf +20 -0
  153. package/dist/infra-templates/modules/relational-database-service/main.tf +44 -0
  154. package/dist/infra-templates/modules/relational-database-service/outputs.tf +13 -0
  155. package/dist/infra-templates/modules/relational-database-service/security-group.tf +15 -0
  156. package/dist/infra-templates/modules/relational-database-service/variables.tf +50 -0
  157. package/dist/infra-templates/modules/secret/main.tf +14 -0
  158. package/dist/infra-templates/modules/secret/outputs.tf +3 -0
  159. package/dist/infra-templates/modules/secret/variables.tf +8 -0
  160. package/dist/infra-templates/modules/simple-storage-service/main.tf +28 -0
  161. package/dist/infra-templates/modules/simple-storage-service/variables.tf +4 -0
  162. package/dist/infra-templates/modules/vpc/data.tf +2 -0
  163. package/dist/infra-templates/modules/vpc/main.tf +76 -0
  164. package/dist/infra-templates/modules/vpc/outputs.tf +23 -0
  165. package/dist/infra-templates/modules/vpc/variables.tf +5 -0
  166. package/dist/infra-templates/package.json +6 -0
  167. package/dist/infra-templates/templates/azure/MANUAL_DEPLOY.md +168 -0
  168. package/dist/infra-templates/templates/azure/backend.tf +8 -0
  169. package/dist/infra-templates/templates/azure/data.tf +21 -0
  170. package/dist/infra-templates/templates/azure/default.tfvars +0 -0
  171. package/dist/infra-templates/templates/azure/locals.tf +116 -0
  172. package/dist/infra-templates/templates/azure/main.tf +421 -0
  173. package/dist/infra-templates/templates/azure/outputs.tf +40 -0
  174. package/dist/infra-templates/templates/azure/providers.tf +65 -0
  175. package/dist/infra-templates/templates/azure/variables.tf +69 -0
  176. package/dist/infra-templates/templates/azure/workflows/build_and_deploy.yml +155 -0
  177. package/dist/infra-templates/templates/azure/workflows/tests.yml +63 -0
  178. package/dist/infra-templates/templates/ecs/README.md +225 -0
  179. package/dist/infra-templates/templates/ecs/backend.tf +7 -0
  180. package/dist/infra-templates/templates/ecs/data.tf +6 -0
  181. package/dist/infra-templates/templates/ecs/default.tfvars +1 -0
  182. package/dist/infra-templates/templates/ecs/locals.tf +97 -0
  183. package/dist/infra-templates/templates/ecs/main.tf +185 -0
  184. package/dist/infra-templates/templates/ecs/outputs.tf +42 -0
  185. package/dist/infra-templates/templates/ecs/providers.tf +21 -0
  186. package/dist/infra-templates/templates/ecs/variables.tf +105 -0
  187. package/dist/infra-templates/templates/ecs/workflows/build_and_deploy.yml +188 -0
  188. package/dist/infra-templates/templates/ecs/workflows/tests.yml +65 -0
  189. package/package.json +10 -2
  190. 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,225 @@
1
+
2
+ # 🌍 Terraform Project: Infrastructure Setup
3
+
4
+ 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.
5
+
6
+ ## ✅ Prerequisites
7
+
8
+ Before you begin, ensure the following:
9
+
10
+ - [Terraform](https://www.terraform.io/downloads.html) is installed and available in your `PATH`
11
+ - AWS CLI is configured with appropriate credentials and region
12
+ - Permissions for creating the environment
13
+ - AmazonECS_FullAccess
14
+ - AmazonElastiCacheFullAccess
15
+ - AmazonRDSFullAccess
16
+ - AmazonS3FullAccess
17
+ - AWSCloudTrail_FullAccess
18
+ - AWSCodeBuildAdminAccess
19
+ - AWSCodePipeline_FullAccess
20
+ - CloudWatchFullAccessV2
21
+ - IAMFullAccess
22
+
23
+ ### 🌐 Creating an ACM Certificate for Your Domain
24
+
25
+ To deploy secure resources using the Infrastructure Automation Script, follow these steps to create an ACM certificate for your domain:
26
+
27
+ 1. **Log in to AWS Console**: Sign in to your AWS Management Console using your AWS account credentials.
28
+
29
+ 2. **Navigate to ACM**: Search for "ACM" in the AWS Management Console search bar and select the "AWS Certificate Manager" service.
30
+
31
+ 3. **Request a Certificate**:
32
+ - Click the "Request a certificate" button.
33
+ - Choose "Request a public certificate" and click "Next".
34
+
35
+ 4. **Add Domain Names**:
36
+ - 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`).
37
+ - Optionally, add additional domain names (SANs) if needed.
38
+ - Click "Next".
39
+
40
+ 5. **Validation**:
41
+ - Choose a validation method (e.g., DNS validation) to prove domain ownership.
42
+ - Follow the provided instructions to complete the validation process.
43
+
44
+ 6. **Review and Confirm**:
45
+ - Review the domain names and validation method you've selected.
46
+ - Click "Confirm and request" to submit your certificate request.
47
+
48
+ 7. **Certificate Issued**:
49
+ - Once validation is successful, the certificate status will change to "Issued".
50
+
51
+ 8. **Copy the ARN**:
52
+ - Click on the issued certificate to view its details.
53
+ - Copy the "Amazon Resource Name (ARN)" of the certificate and paste it into your `config.json` under the SSL session section.
54
+
55
+ ---
56
+
57
+ ### 📝 Additional Observations
58
+
59
+ - **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:
60
+ - **FRONT_END_URL**: Ensure this is updated to the correct domain for your front-end application.
61
+ - **HOST_URL**: Similarly, this URL is currently pointing to Flatirons' domain, and you will need to change it to match your own domain.
62
+ - **ssl**: Copy the certificate arn from the previous step
63
+
64
+
65
+ ### 🌱 How to Modify app.json
66
+
67
+ ##### 1. **SSL Certificate ARN**
68
+ - Replace the `"ssl"` field with the correct ARN for your SSL certificate, which you should have obtained through AWS Certificate Manager (ACM):
69
+
70
+ ```json
71
+ "ssl": "arn:aws:acm:========================="
72
+ ```
73
+ ##### 2. **Access IP Range**
74
+ - 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:
75
+
76
+ ```json
77
+ "access_ip_range": "73.153.163.118/32"
78
+ ```
79
+
80
+ ##### 3. **Cognito API Key Header**
81
+ - Ensure the `"cognito_apikey_header"` field points to the header for API key authentication if you are using Cognito for authentication:
82
+
83
+ ```json
84
+ "cognito_apikey_header": "x-api-key"
85
+ ```
86
+ ##### 4. **Slack Webhook URL**
87
+ - Provide your Slack Webhook URL to receive alarms. If you don't have one, you can use the default placeholder URL:
88
+
89
+ ```json
90
+ "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"
91
+ ```
92
+
93
+ ##### 5. **Environment Setup**
94
+ - Update the `"name"` field with your project name:
95
+
96
+ ```json
97
+ "name": "your-project"
98
+ ```
99
+
100
+ - The `"deployment"` field specifies the deployment method (ecs or eks):
101
+
102
+ ```json
103
+ "deployment": "ecs"
104
+ ```
105
+
106
+ Nota: This application only works with ecs
107
+
108
+ ##### 6. **Application Modules Configuration**
109
+ - Modify the `"modules"` field to set the options for the different modules you are using in your application. For instance:
110
+
111
+ ```json
112
+ "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}}]"
113
+ ```
114
+
115
+ ##### 7. **Application Configurations for API and Web**
116
+ - Modify the application configuration under the `"apps"` section. For each app (e.g., `projectname-dev-api`, `projectname-staging-api`), update the following:
117
+
118
+ - **Domain Name**: Set the domain for each app.
119
+ - **API Keys and Secrets**: Ensure all required API keys and secrets (like Snowflake, JWT) are correctly configured.
120
+ - **Environment Variables**: Update any specific environment variables (e.g., `HOST_URL`, `FRONT_END_URL`).
121
+
122
+ Example for the **dev API app**:
123
+
124
+ ```json
125
+ "apps": [
126
+ {
127
+ "name": "projectname-dev-api",
128
+ "technology": "nest",
129
+ "dockerfile": "apps/api/Dockerfile",
130
+ "health_check_path": "/health",
131
+ "domain": "projectname-dev-api.******.com",
132
+ "port": 3000,
133
+ "cognito": false,
134
+ "postgres": false,
135
+ "redis": false,
136
+ "variables": {
137
+ "NODE_TLS_REJECT_UNAUTHORIZED": 0,
138
+ "API_KEY_HEADER": "x-api-key",
139
+ "ENCRYPTION_PASSWORD": "xxxxxxxxxxxxxxx",
140
+ "HOST_URL": "https://projectname-dev-api.****.com",
141
+ "FRONT_END_URL": "https://projectname-dev.******.com",
142
+ "APP_NAME": "AppName",
143
+ "APP_COMPANY": "Flatirons",
144
+ "ADMIN_JS_EMAIL": "admin@flatirons.com",
145
+ "ADMIN_JS_PASSWORD": "xxxxxxxxxxxxxxxxx!!!"
146
+ }
147
+ }
148
+ ]
149
+ ```
150
+ ---
151
+
152
+ ## 🚀 Usage
153
+
154
+ ### 1. Verify Terraform Installation
155
+
156
+ Make sure Terraform is correctly installed by running the following command:
157
+
158
+ ```bash
159
+ terraform -v
160
+ ```
161
+
162
+ ### 2. Initialize and Create the Centralized Secret
163
+
164
+ 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.
165
+ 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
166
+
167
+ Region=fill your region below (if it is different from us-east-1)
168
+ ```bash
169
+ cd modules/secret-main
170
+ terraform init -backend-config="region=us-east-1"
171
+ terraform plan
172
+ terraform apply
173
+ ```
174
+
175
+ ### 3. Apply the Full Infrastructure
176
+
177
+ After the centralized secret is in place, proceed to initialize and apply the full infrastructure:
178
+
179
+ Region=fill your region below (if it is different from us-east-1)
180
+ ```bash
181
+ terraform init -backend-config="region=us-east-1"
182
+ terraform plan
183
+ terraform apply
184
+ ```
185
+
186
+ ---
187
+
188
+ ## 📁 Project Structure
189
+
190
+ ```bash
191
+ .
192
+ ├── modules/ # ALL Terraform Modules
193
+ │ └── secret-main/ # Module for creating the centralized secret
194
+ ├── main.tf # Main Terraform entrypoint
195
+ ├── variables.tf # Input variable definitions
196
+ ├── outputs.tf # Output values
197
+ ├── providers.tf # Provider settings
198
+ ├── locals.tf # Provider settings
199
+ └── README.md # Project documentation
200
+ ```
201
+
202
+ ---
203
+
204
+ ## 🔐 Security Considerations
205
+
206
+ - **Never hardcode secrets**: Use variables and Secrets Manager for sensitive data.
207
+ - **Restrict access**: Implement AWS IAM policies to control who can access the centralized secret.
208
+ - **Remote state encryption**: Ensure remote state is encrypted, especially when using shared backends like S3.
209
+
210
+ ---
211
+
212
+ ## 🧹 Clean Up
213
+
214
+ To destroy all infrastructure and resources, run the following command:
215
+
216
+ ```bash
217
+ terraform destroy
218
+ ```
219
+
220
+ To only destroy the centralized secret:
221
+
222
+ ```bash
223
+ cd modules/secret-main
224
+ terraform destroy
225
+ ```
@@ -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
+ }