@swovohq/fuel 0.2.2-alpha.9 → 0.2.2-alpha.90
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.
- package/README.md +108 -4
- package/dist/bin/fuel.js +76 -30
- package/dist/bin/fuel.js.map +1 -1
- package/dist/commands/config-verify.d.ts.map +1 -1
- package/dist/commands/config-verify.js +14 -6
- package/dist/commands/config-verify.js.map +1 -1
- package/dist/commands/create-app.d.ts.map +1 -1
- package/dist/commands/create-app.js +36 -4
- package/dist/commands/create-app.js.map +1 -1
- package/dist/commands/infra-deploy.d.ts +15 -1
- package/dist/commands/infra-deploy.d.ts.map +1 -1
- package/dist/commands/infra-deploy.js +144 -15
- package/dist/commands/infra-deploy.js.map +1 -1
- package/dist/commands/infra-destroy.js +3 -3
- package/dist/commands/infra-destroy.js.map +1 -1
- package/dist/commands/infra-init.d.ts +91 -0
- package/dist/commands/infra-init.d.ts.map +1 -1
- package/dist/commands/infra-init.js +510 -80
- package/dist/commands/infra-init.js.map +1 -1
- package/dist/commands/infra-pull.d.ts +8 -0
- package/dist/commands/infra-pull.d.ts.map +1 -0
- package/dist/commands/infra-pull.js +80 -0
- package/dist/commands/infra-pull.js.map +1 -0
- package/dist/engines/convention.d.ts +2 -2
- package/dist/engines/convention.d.ts.map +1 -1
- package/dist/engines/convention.js +6 -4
- package/dist/engines/convention.js.map +1 -1
- package/dist/engines/dependencies.d.ts +2 -0
- package/dist/engines/dependencies.d.ts.map +1 -1
- package/dist/engines/dependencies.js.map +1 -1
- package/dist/infra/azure-defaults.d.ts +49 -0
- package/dist/infra/azure-defaults.d.ts.map +1 -0
- package/dist/infra/azure-defaults.js +52 -0
- package/dist/infra/azure-defaults.js.map +1 -0
- package/dist/infra/azure-keyvault-client.d.ts +4 -0
- package/dist/infra/azure-keyvault-client.d.ts.map +1 -0
- package/dist/infra/azure-keyvault-client.js +57 -0
- package/dist/infra/azure-keyvault-client.js.map +1 -0
- package/dist/infra/azure-rbac.d.ts +11 -0
- package/dist/infra/azure-rbac.d.ts.map +1 -0
- package/dist/infra/azure-rbac.js +47 -0
- package/dist/infra/azure-rbac.js.map +1 -0
- package/dist/infra/azure-state-storage.d.ts +20 -0
- package/dist/infra/azure-state-storage.d.ts.map +1 -0
- package/dist/infra/azure-state-storage.js +229 -0
- package/dist/infra/azure-state-storage.js.map +1 -0
- package/dist/infra/credentials.d.ts +2 -2
- package/dist/infra/credentials.d.ts.map +1 -1
- package/dist/infra/credentials.js +8 -4
- package/dist/infra/credentials.js.map +1 -1
- package/dist/infra/deployment-detect.d.ts +9 -0
- package/dist/infra/deployment-detect.d.ts.map +1 -0
- package/dist/infra/deployment-detect.js +53 -0
- package/dist/infra/deployment-detect.js.map +1 -0
- package/dist/infra/git-client.d.ts.map +1 -1
- package/dist/infra/git-client.js +6 -10
- package/dist/infra/git-client.js.map +1 -1
- package/dist/infra/github-client.d.ts +7 -0
- package/dist/infra/github-client.d.ts.map +1 -1
- package/dist/infra/github-client.js +44 -4
- package/dist/infra/github-client.js.map +1 -1
- package/dist/infra/github-token-link.d.ts +4 -0
- package/dist/infra/github-token-link.d.ts.map +1 -0
- package/dist/infra/github-token-link.js +28 -0
- package/dist/infra/github-token-link.js.map +1 -0
- package/dist/infra/orchestrator.d.ts +4 -1
- package/dist/infra/orchestrator.d.ts.map +1 -1
- package/dist/infra/orchestrator.js +209 -59
- package/dist/infra/orchestrator.js.map +1 -1
- package/dist/infra/preflight.d.ts.map +1 -1
- package/dist/infra/preflight.js +17 -9
- package/dist/infra/preflight.js.map +1 -1
- package/dist/infra/remote-secret.d.ts +14 -0
- package/dist/infra/remote-secret.d.ts.map +1 -0
- package/dist/infra/remote-secret.js +42 -0
- package/dist/infra/remote-secret.js.map +1 -0
- package/dist/infra/template-engine.d.ts +14 -5
- package/dist/infra/template-engine.d.ts.map +1 -1
- package/dist/infra/template-engine.js +145 -39
- package/dist/infra/template-engine.js.map +1 -1
- package/dist/infra/tofu-runner.d.ts +4 -3
- package/dist/infra/tofu-runner.d.ts.map +1 -1
- package/dist/infra/tofu-runner.js +36 -27
- package/dist/infra/tofu-runner.js.map +1 -1
- package/dist/infra/types.d.ts +240 -16
- package/dist/infra/types.d.ts.map +1 -1
- package/dist/infra/types.js +207 -18
- package/dist/infra/types.js.map +1 -1
- package/dist/infra-templates/TODO-azure-prod.md +119 -0
- package/dist/infra-templates/modules/azure-container-app/main.tf +124 -0
- package/dist/infra-templates/modules/azure-container-app/outputs.tf +24 -0
- package/dist/infra-templates/modules/azure-container-app/variables.tf +80 -0
- package/dist/infra-templates/modules/azure-container-apps-environment/main.tf +18 -0
- package/dist/infra-templates/modules/azure-container-apps-environment/outputs.tf +14 -0
- package/dist/infra-templates/modules/azure-container-apps-environment/variables.tf +24 -0
- package/dist/infra-templates/modules/azure-container-registry/main.tf +10 -0
- package/dist/infra-templates/modules/azure-container-registry/outputs.tf +14 -0
- package/dist/infra-templates/modules/azure-container-registry/variables.tf +20 -0
- package/dist/infra-templates/modules/azure-front-door/main.tf +80 -0
- package/dist/infra-templates/modules/azure-front-door/outputs.tf +20 -0
- package/dist/infra-templates/modules/azure-front-door/variables.tf +26 -0
- package/dist/infra-templates/modules/azure-github-oidc/main.tf +48 -0
- package/dist/infra-templates/modules/azure-github-oidc/outputs.tf +9 -0
- package/dist/infra-templates/modules/azure-github-oidc/variables.tf +69 -0
- package/dist/infra-templates/modules/azure-key-vault/main.tf +21 -0
- package/dist/infra-templates/modules/azure-key-vault/outputs.tf +11 -0
- package/dist/infra-templates/modules/azure-key-vault/variables.tf +43 -0
- package/dist/infra-templates/modules/azure-monitor/main.tf +29 -0
- package/dist/infra-templates/modules/azure-monitor/outputs.tf +17 -0
- package/dist/infra-templates/modules/azure-monitor/variables.tf +32 -0
- package/dist/infra-templates/modules/azure-network/main.tf +134 -0
- package/dist/infra-templates/modules/azure-network/outputs.tf +44 -0
- package/dist/infra-templates/modules/azure-network/variables.tf +56 -0
- package/dist/infra-templates/modules/azure-postgresql-flexible/main.tf +34 -0
- package/dist/infra-templates/modules/azure-postgresql-flexible/outputs.tf +20 -0
- package/dist/infra-templates/modules/azure-postgresql-flexible/variables.tf +54 -0
- package/dist/infra-templates/modules/azure-redis-cache/main.tf +32 -0
- package/dist/infra-templates/modules/azure-redis-cache/outputs.tf +15 -0
- package/dist/infra-templates/modules/azure-redis-cache/variables.tf +30 -0
- package/dist/infra-templates/modules/azure-resource-group/main.tf +5 -0
- package/dist/infra-templates/modules/azure-resource-group/outputs.tf +11 -0
- package/dist/infra-templates/modules/azure-resource-group/variables.tf +16 -0
- package/dist/infra-templates/modules/azure-sql-database/main.tf +63 -0
- package/dist/infra-templates/modules/azure-sql-database/outputs.tf +20 -0
- package/dist/infra-templates/modules/azure-sql-database/variables.tf +78 -0
- package/dist/infra-templates/modules/azure-storage-account/main.tf +13 -0
- package/dist/infra-templates/modules/azure-storage-account/outputs.tf +16 -0
- package/dist/infra-templates/modules/azure-storage-account/variables.tf +38 -0
- package/dist/infra-templates/modules/cloud-watch/event-bridge.tf +15 -0
- package/dist/infra-templates/modules/cloud-watch/lambda.tf +84 -0
- package/dist/infra-templates/modules/cloud-watch/lambda_function.zip +0 -0
- package/dist/infra-templates/modules/cloud-watch/lambda_function_deploy.zip +0 -0
- package/dist/infra-templates/modules/cloud-watch/main.tf +156 -0
- package/dist/infra-templates/modules/cloud-watch/sns.tf +3 -0
- package/dist/infra-templates/modules/cloud-watch/variables.tf +38 -0
- package/dist/infra-templates/modules/ecs-core/alb.tf +126 -0
- package/dist/infra-templates/modules/ecs-core/cloudwatch.tf +48 -0
- package/dist/infra-templates/modules/ecs-core/iam.tf +95 -0
- package/dist/infra-templates/modules/ecs-core/main.tf +12 -0
- package/dist/infra-templates/modules/ecs-core/outputs.tf +44 -0
- package/dist/infra-templates/modules/ecs-core/secrets.tf +9 -0
- package/dist/infra-templates/modules/ecs-core/security_groups.tf +73 -0
- package/dist/infra-templates/modules/ecs-core/variables.tf +96 -0
- package/dist/infra-templates/modules/ecs-service/ecs_autoscaling.tf +51 -0
- package/dist/infra-templates/modules/ecs-service/ecs_service.tf +39 -0
- package/dist/infra-templates/modules/ecs-service/ecs_task_definition.tf +56 -0
- package/dist/infra-templates/modules/ecs-service/variables.tf +170 -0
- package/dist/infra-templates/modules/elastic-container-registry/main.tf +32 -0
- package/dist/infra-templates/modules/elastic-container-registry/outputs.tf +9 -0
- package/dist/infra-templates/modules/elastic-container-registry/variables.tf +25 -0
- package/dist/infra-templates/modules/github-oidc-role/main.tf +46 -0
- package/dist/infra-templates/modules/github-oidc-role/outputs.tf +4 -0
- package/dist/infra-templates/modules/github-oidc-role/variables.tf +11 -0
- package/dist/infra-templates/modules/guardduty/main.tf +8 -0
- package/dist/infra-templates/modules/iam/main.tf +205 -0
- package/dist/infra-templates/modules/iam/outputs.tf +3 -0
- package/dist/infra-templates/modules/iam/variables.tf +4 -0
- package/dist/infra-templates/modules/random-key/main.tf +11 -0
- package/dist/infra-templates/modules/random-key/outputs.tf +4 -0
- package/dist/infra-templates/modules/random-key/variables.tf +10 -0
- package/dist/infra-templates/modules/redis/main.tf +47 -0
- package/dist/infra-templates/modules/redis/outputs.tf +8 -0
- package/dist/infra-templates/modules/redis/variables.tf +20 -0
- package/dist/infra-templates/modules/relational-database-service/main.tf +44 -0
- package/dist/infra-templates/modules/relational-database-service/outputs.tf +13 -0
- package/dist/infra-templates/modules/relational-database-service/security-group.tf +15 -0
- package/dist/infra-templates/modules/relational-database-service/variables.tf +50 -0
- package/dist/infra-templates/modules/secret/main.tf +14 -0
- package/dist/infra-templates/modules/secret/outputs.tf +3 -0
- package/dist/infra-templates/modules/secret/variables.tf +8 -0
- package/dist/infra-templates/modules/simple-storage-service/main.tf +28 -0
- package/dist/infra-templates/modules/simple-storage-service/variables.tf +4 -0
- package/dist/infra-templates/modules/vpc/data.tf +2 -0
- package/dist/infra-templates/modules/vpc/main.tf +76 -0
- package/dist/infra-templates/modules/vpc/outputs.tf +23 -0
- package/dist/infra-templates/modules/vpc/variables.tf +5 -0
- package/dist/infra-templates/package.json +6 -0
- package/dist/infra-templates/templates/azure/MANUAL_DEPLOY.md +168 -0
- package/dist/infra-templates/templates/azure/backend.tf +8 -0
- package/dist/infra-templates/templates/azure/data.tf +21 -0
- package/dist/infra-templates/templates/azure/default.tfvars +0 -0
- package/dist/infra-templates/templates/azure/locals.tf +116 -0
- package/dist/infra-templates/templates/azure/main.tf +421 -0
- package/dist/infra-templates/templates/azure/outputs.tf +40 -0
- package/dist/infra-templates/templates/azure/providers.tf +65 -0
- package/dist/infra-templates/templates/azure/variables.tf +69 -0
- package/dist/infra-templates/templates/azure/workflows/build_and_deploy.yml +155 -0
- package/dist/infra-templates/templates/azure/workflows/tests.yml +63 -0
- package/dist/infra-templates/templates/ecs/README.md +225 -0
- package/dist/infra-templates/templates/ecs/backend.tf +7 -0
- package/dist/infra-templates/templates/ecs/data.tf +6 -0
- package/dist/infra-templates/templates/ecs/default.tfvars +1 -0
- package/dist/infra-templates/templates/ecs/locals.tf +97 -0
- package/dist/infra-templates/templates/ecs/main.tf +185 -0
- package/dist/infra-templates/templates/ecs/outputs.tf +42 -0
- package/dist/infra-templates/templates/ecs/providers.tf +21 -0
- package/dist/infra-templates/templates/ecs/variables.tf +105 -0
- package/dist/infra-templates/templates/ecs/workflows/build_and_deploy.yml +188 -0
- package/dist/infra-templates/templates/ecs/workflows/tests.yml +65 -0
- package/package.json +10 -2
- package/schema/fuel.schema.json +570 -91
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
data "external" "oidc_check" {
|
|
2
|
+
program = ["bash", "-c", <<-EOT
|
|
3
|
+
OIDC_ARN="arn:aws:iam::${data.aws_caller_identity.current.account_id}:oidc-provider/token.actions.githubusercontent.com"
|
|
4
|
+
if aws iam get-open-id-connect-provider --open-id-connect-provider-arn "$OIDC_ARN" >/dev/null 2>&1; then
|
|
5
|
+
echo "{\"exists\":\"true\",\"arn\":\"$OIDC_ARN\"}"
|
|
6
|
+
else
|
|
7
|
+
echo '{"exists":"false","arn":""}'
|
|
8
|
+
fi
|
|
9
|
+
EOT
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
for_each = data.external.oidc_check.result.exists == "true" ? toset([data.external.oidc_check.result.arn]) : toset([])
|
|
15
|
+
to = module.github_oidc.aws_iam_openid_connect_provider.github
|
|
16
|
+
id = each.value
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
module "github_oidc" {
|
|
20
|
+
source = "../../modules/github-oidc-role"
|
|
21
|
+
project_name = var.project_name
|
|
22
|
+
github_organization = var.github_organization
|
|
23
|
+
aws_account_id = data.aws_caller_identity.current.account_id
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module "iam" {
|
|
27
|
+
source = "../../modules/iam"
|
|
28
|
+
project_name = var.project_name
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
module "redis" {
|
|
32
|
+
for_each = { for app in local.app_list : app.app_name => app if app.redis }
|
|
33
|
+
source = "../../modules/redis"
|
|
34
|
+
vpc_id = module.vpc.vpc_id
|
|
35
|
+
subnet_ids = module.vpc.private_subnets
|
|
36
|
+
app_name = each.value.app_name
|
|
37
|
+
node_type = try(each.value.redis_instance_type)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
module "vpc" {
|
|
41
|
+
source = "../../modules/vpc"
|
|
42
|
+
project_name = var.project_name
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module "s3" {
|
|
46
|
+
source = "../../modules/simple-storage-service"
|
|
47
|
+
project_name = var.project_name
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
module "ecr" {
|
|
51
|
+
source = "../../modules/elastic-container-registry"
|
|
52
|
+
project_name = var.project_name
|
|
53
|
+
apps = toset(local.app_list)
|
|
54
|
+
workers = toset(local.worker_list)
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
module "database" {
|
|
58
|
+
for_each = { for app in local.app_list : app.app_name => app if app.postgres }
|
|
59
|
+
source = "../../modules/relational-database-service"
|
|
60
|
+
app_name = each.value.app_name
|
|
61
|
+
db_instance_type = try(each.value.db_instance_type)
|
|
62
|
+
db_allocated_storage = try(each.value.db_allocated_storage)
|
|
63
|
+
allowed_ip_list = var.access_ip_range
|
|
64
|
+
vpc_id = module.vpc.vpc_id
|
|
65
|
+
subnet_ids = module.vpc.public_subnets
|
|
66
|
+
vpc_security_group_default = module.vpc.default_security_group_id
|
|
67
|
+
db_username = var.db_username
|
|
68
|
+
db_password = var.db_password
|
|
69
|
+
db_name = var.db_name
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
module "ecs_core" {
|
|
73
|
+
source = "../../modules/ecs-core"
|
|
74
|
+
|
|
75
|
+
log_group_name = var.project_name
|
|
76
|
+
aws_region = var.aws_region
|
|
77
|
+
ingress_ssl_arn = local.credentials.ssl
|
|
78
|
+
namespace = var.project_name
|
|
79
|
+
project_name = var.project_name
|
|
80
|
+
vpc_id = module.vpc.vpc_id
|
|
81
|
+
public_subnets = module.vpc.public_subnets
|
|
82
|
+
private_subnets = module.vpc.private_subnets
|
|
83
|
+
default_security_group_id = module.vpc.default_security_group_id
|
|
84
|
+
healthcheck_endpoint = "/health"
|
|
85
|
+
apps = toset(local.app_list)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
module "secret_manager" {
|
|
89
|
+
for_each = { for app in local.app_list : "${app.app_name}-secrets" => app }
|
|
90
|
+
name = each.key
|
|
91
|
+
env_vars = local.env_vars[each.value.app_name]
|
|
92
|
+
source = "../../modules/secret"
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
module "ecs_services" {
|
|
96
|
+
for_each = { for app in local.app_list : app.app_name => app }
|
|
97
|
+
source = "../../modules/ecs-service"
|
|
98
|
+
|
|
99
|
+
app_name = each.value.app_name
|
|
100
|
+
container_port = each.value.port
|
|
101
|
+
connect_to_alb = true
|
|
102
|
+
repository_url = "${module.ecr.repository_url}:${each.value.app_name}"
|
|
103
|
+
ecs_secret_arn = local.secret_arns["${each.value.app_name}-secrets"]
|
|
104
|
+
cpu_units = try(each.value.cpu_units)
|
|
105
|
+
memory = try(each.value.memory_units)
|
|
106
|
+
|
|
107
|
+
secret_name = "${each.value.app_name}-secrets"
|
|
108
|
+
|
|
109
|
+
aws_region = var.aws_region
|
|
110
|
+
default_security_group_id = module.vpc.default_security_group_id
|
|
111
|
+
ecs_task_execution_role_arn = module.ecs_core.ecs_task_execution_role_arn
|
|
112
|
+
ecs_task_role_arn = module.ecs_core.ecs_task_role_arn
|
|
113
|
+
ecs_log_group_name = module.ecs_core.ecs_log_group_name
|
|
114
|
+
ecs_cluster_id = module.ecs_core.ecs_cluster_id
|
|
115
|
+
ecs_cluster_name = module.ecs_core.ecs_cluster_name
|
|
116
|
+
ecs_container_security_group_id = module.ecs_core.ecs_container_security_group_id
|
|
117
|
+
private_subnets = module.vpc.private_subnets
|
|
118
|
+
|
|
119
|
+
aws_alb_target_group_arn = module.ecs_core.aws_alb_target_groups[each.key].arn
|
|
120
|
+
env_vars = local.env_vars[each.value.app_name]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
module "ecs_worker_services" {
|
|
125
|
+
for_each = { for app in local.worker_list : app.app_name => app }
|
|
126
|
+
source = "../../modules/ecs-service"
|
|
127
|
+
|
|
128
|
+
app_name = "${each.value.worker_name}"
|
|
129
|
+
connect_to_alb = false
|
|
130
|
+
repository_url = "${module.ecr.repository_url}:${each.value.worker_name}"
|
|
131
|
+
ecs_secret_arn = local.secret_arns["${each.value.app_name}-secrets"]
|
|
132
|
+
secret_name = "${each.value.app_name}-secrets"
|
|
133
|
+
cpu_units = try(each.value.cpu_units)
|
|
134
|
+
memory = try(each.value.memory_units)
|
|
135
|
+
|
|
136
|
+
aws_region = var.aws_region
|
|
137
|
+
default_security_group_id = module.vpc.default_security_group_id
|
|
138
|
+
ecs_task_execution_role_arn = module.ecs_core.ecs_task_execution_role_arn
|
|
139
|
+
ecs_task_role_arn = module.ecs_core.ecs_task_role_arn
|
|
140
|
+
ecs_log_group_name = module.ecs_core.ecs_log_group_name
|
|
141
|
+
ecs_cluster_id = module.ecs_core.ecs_cluster_id
|
|
142
|
+
ecs_cluster_name = module.ecs_core.ecs_cluster_name
|
|
143
|
+
ecs_container_security_group_id = module.ecs_core.ecs_container_security_group_id
|
|
144
|
+
private_subnets = module.vpc.private_subnets
|
|
145
|
+
|
|
146
|
+
aws_alb_target_group_arn = ""
|
|
147
|
+
env_vars = local.env_vars[each.value.app_name]
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
module "random_key" {
|
|
151
|
+
source = "../../modules/random-key"
|
|
152
|
+
name = "nest_encryption_password"
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
module "cloud-watch" {
|
|
156
|
+
source = "../../modules/cloud-watch"
|
|
157
|
+
project_name = var.project_name
|
|
158
|
+
slack_webhook_url = try(local.credentials.slack_webhook_url, "")
|
|
159
|
+
aws_region = var.aws_region
|
|
160
|
+
ecs = true
|
|
161
|
+
apps = toset(local.app_list)
|
|
162
|
+
ecs_cluster_id = module.ecs_core.ecs_cluster_id
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
data "external" "guardduty_check" {
|
|
166
|
+
program = ["bash", "-c", <<-EOT
|
|
167
|
+
DETECTOR_ID=$(aws guardduty list-detectors --query 'DetectorIds[0]' --output text 2>/dev/null)
|
|
168
|
+
if [ -n "$DETECTOR_ID" ] && [ "$DETECTOR_ID" != "None" ]; then
|
|
169
|
+
echo "{\"exists\":\"true\",\"id\":\"$DETECTOR_ID\"}"
|
|
170
|
+
else
|
|
171
|
+
echo '{"exists":"false","id":""}'
|
|
172
|
+
fi
|
|
173
|
+
EOT
|
|
174
|
+
]
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
import {
|
|
178
|
+
for_each = data.external.guardduty_check.result.exists == "true" ? toset([data.external.guardduty_check.result.id]) : toset([])
|
|
179
|
+
to = module.guardduty.aws_guardduty_detector.main
|
|
180
|
+
id = each.value
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
module "guardduty" {
|
|
184
|
+
source = "../../modules/guardduty"
|
|
185
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
output "elasticache_cluster_hostname" {
|
|
2
|
+
value = [{ for i in module.redis : "${i.app_name}" => "${i.elasticache_cluster_hostname}" }][0]
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
output "db_hostname" {
|
|
6
|
+
value = [{ for i in module.database : "${i.app_name}" => "${i.db_hostname}" }][0]
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
output "aws_region" {
|
|
10
|
+
value = "${var.aws_region}"
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
output "alb_dns" {
|
|
14
|
+
value = module.ecs_core.alb_dns
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
output "vpc_cidr_block" {
|
|
18
|
+
value = module.vpc.vpc_cidr_block
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
output "apps" {
|
|
22
|
+
value = local.app_list
|
|
23
|
+
sensitive = true
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
output "workers" {
|
|
27
|
+
value = local.worker_list
|
|
28
|
+
sensitive = true
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
output "ecr_url" {
|
|
32
|
+
value = module.ecr.repository_url
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
output "github_http_repo_url" {
|
|
36
|
+
value = "https://github.com/${var.github_organization}/${var.github_repo_name}.git"
|
|
37
|
+
sensitive = true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
output "oidc_role_arn" {
|
|
41
|
+
value = module.github_oidc.role_arn
|
|
42
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
terraform {
|
|
2
|
+
required_version = ">= 1.5.0"
|
|
3
|
+
required_providers {
|
|
4
|
+
aws = {
|
|
5
|
+
source = "hashicorp/aws"
|
|
6
|
+
version = ">= 5.8.0"
|
|
7
|
+
}
|
|
8
|
+
kubectl = {
|
|
9
|
+
source = "gavinbunney/kubectl"
|
|
10
|
+
version = "1.16.0"
|
|
11
|
+
}
|
|
12
|
+
random = {
|
|
13
|
+
source = "hashicorp/random"
|
|
14
|
+
version = ">= 3.5.1"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
provider "aws" {
|
|
20
|
+
region = var.aws_region
|
|
21
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
variable "project_name" {
|
|
2
|
+
description = "A unique name for your project. This will be used as part of resource names."
|
|
3
|
+
default = ""
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
variable "access_ip_range" {
|
|
7
|
+
description = "The range of office IP range"
|
|
8
|
+
default = ""
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
variable "default_security_group_id" {
|
|
12
|
+
description = "Default security group ID"
|
|
13
|
+
default = ""
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variable "vpc_id" {
|
|
17
|
+
description = "ID of the VPC for the ECS cluster"
|
|
18
|
+
default = ""
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
variable "private_subnets" {
|
|
22
|
+
description = "Private subnets for the ECS cluster"
|
|
23
|
+
default = ""
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
variable "slack_namespace" {
|
|
27
|
+
description = "Additional security group"
|
|
28
|
+
default = ""
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
variable "slack_token" {
|
|
32
|
+
description = "Additional security group"
|
|
33
|
+
default = ""
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
variable "github_repo_name" {
|
|
37
|
+
description = "Name of the GitHub repository (created by CLI)"
|
|
38
|
+
type = string
|
|
39
|
+
default = ""
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
variable "github_organization" {
|
|
43
|
+
description = "Github organization where repositories should be created"
|
|
44
|
+
default = ""
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
variable "aws_access_key_id" {
|
|
48
|
+
description = "AWS Access Key ID"
|
|
49
|
+
default = ""
|
|
50
|
+
sensitive = true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
variable "aws_secret_access_key" {
|
|
54
|
+
description = "AWS Secret Access Key"
|
|
55
|
+
default = ""
|
|
56
|
+
sensitive = true
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
variable "aws_region" {
|
|
60
|
+
description = "AWS Region"
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
variable "db_password" {
|
|
64
|
+
description = "Password for postgres. Leave empty to auto-generate."
|
|
65
|
+
default = ""
|
|
66
|
+
sensitive = true
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
variable "db_username" {
|
|
70
|
+
description = "Username for postgres"
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
variable "db_name" {
|
|
74
|
+
description = "DB name for postgres"
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
variable "db_instance_type" {
|
|
78
|
+
description = "Database instance type"
|
|
79
|
+
default = "db.t3.small"
|
|
80
|
+
type = string
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
variable "db_allocated_storage" {
|
|
84
|
+
description = "Database allocated storage"
|
|
85
|
+
default = 30
|
|
86
|
+
type = number
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
variable "redis_instance_type" {
|
|
90
|
+
description = "Redis instance type"
|
|
91
|
+
default = "cache.t3.small"
|
|
92
|
+
type = string
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
variable "cpu_units" {
|
|
96
|
+
description = "CPU units for ECS tasks"
|
|
97
|
+
default = 1024
|
|
98
|
+
type = number
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
variable "memory_units" {
|
|
102
|
+
description = "Memory units for ECS tasks"
|
|
103
|
+
default = 2048
|
|
104
|
+
type = number
|
|
105
|
+
}
|
|
@@ -0,0 +1,188 @@
|
|
|
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: |
|
|
16
|
+
${{
|
|
17
|
+
github.ref_name == 'main' && 'production' ||
|
|
18
|
+
github.ref_name == 'staging' && 'staging' ||
|
|
19
|
+
github.ref_name == 'dev' && 'development'
|
|
20
|
+
}}
|
|
21
|
+
|
|
22
|
+
jobs:
|
|
23
|
+
build:
|
|
24
|
+
runs-on: ubuntu-latest
|
|
25
|
+
timeout-minutes: 30
|
|
26
|
+
if: github.ref == 'refs/heads/BRANCHREPLACE'
|
|
27
|
+
permissions:
|
|
28
|
+
id-token: write
|
|
29
|
+
contents: read
|
|
30
|
+
deployments: write
|
|
31
|
+
|
|
32
|
+
steps:
|
|
33
|
+
- name: Checkout Repository
|
|
34
|
+
uses: actions/checkout@v7
|
|
35
|
+
with:
|
|
36
|
+
fetch-depth: 0
|
|
37
|
+
|
|
38
|
+
- name: Set Outputs
|
|
39
|
+
id: vars
|
|
40
|
+
run: echo "::set-output name=sha_short::$(git rev-parse --short HEAD)"
|
|
41
|
+
|
|
42
|
+
- name: Free Disk Space
|
|
43
|
+
run: |
|
|
44
|
+
echo "🧹 Cleaning up system to free space..."
|
|
45
|
+
sudo swapoff -a
|
|
46
|
+
sudo rm -f /swapfile
|
|
47
|
+
sudo rm -rf /usr/share/dotnet /opt/ghc /usr/local/lib/android
|
|
48
|
+
sudo apt-get clean
|
|
49
|
+
docker system prune -af
|
|
50
|
+
docker volume prune -f
|
|
51
|
+
|
|
52
|
+
- name: Set up Node.js
|
|
53
|
+
uses: actions/setup-node@v6
|
|
54
|
+
with:
|
|
55
|
+
node-version: "lts/*"
|
|
56
|
+
cache: yarn
|
|
57
|
+
|
|
58
|
+
- name: Configure AWS Credentials
|
|
59
|
+
uses: aws-actions/configure-aws-credentials@v6
|
|
60
|
+
with:
|
|
61
|
+
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
|
|
62
|
+
aws-region: ${{ secrets.AWS_REGION }}
|
|
63
|
+
|
|
64
|
+
- name: Login to Amazon ECR
|
|
65
|
+
id: login-ecr
|
|
66
|
+
uses: aws-actions/amazon-ecr-login@v2
|
|
67
|
+
|
|
68
|
+
- name: Set up Docker Buildx
|
|
69
|
+
uses: docker/setup-buildx-action@v4
|
|
70
|
+
with:
|
|
71
|
+
driver-opts: |
|
|
72
|
+
image=moby/buildkit:v0.12.0
|
|
73
|
+
|
|
74
|
+
- name: Build and tag REPLACEME image
|
|
75
|
+
uses: docker/build-push-action@v7
|
|
76
|
+
env:
|
|
77
|
+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
78
|
+
ECR_REPOSITORY: ${{ secrets.PROJECT_NAME }}-application
|
|
79
|
+
CURRENT_BRANCH: ${{ github.ref_name }}
|
|
80
|
+
IMAGE_SHA: ${{ steps.vars.outputs.sha_short }}
|
|
81
|
+
with:
|
|
82
|
+
context: ./
|
|
83
|
+
file: DOCKERFILE
|
|
84
|
+
push: true
|
|
85
|
+
tags: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:REPLACEME-${{ steps.vars.outputs.sha_short }}
|
|
86
|
+
build-args: |
|
|
87
|
+
BUILDARGS
|
|
88
|
+
- name: Download existing ECS task definition
|
|
89
|
+
run: |
|
|
90
|
+
aws ecs describe-task-definition --task-definition REPLACEME --query taskDefinition > task-definition.json
|
|
91
|
+
|
|
92
|
+
- name: Fill in the new image ID in the Amazon ECS task definition
|
|
93
|
+
id: task-def
|
|
94
|
+
uses: aws-actions/amazon-ecs-render-task-definition@v1
|
|
95
|
+
env:
|
|
96
|
+
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
|
|
97
|
+
ECR_REPOSITORY: ${{ secrets.PROJECT_NAME }}-application
|
|
98
|
+
CURRENT_BRANCH: ${{ github.ref_name }}
|
|
99
|
+
IMAGE_SHA: ${{ steps.vars.outputs.sha_short }}
|
|
100
|
+
with:
|
|
101
|
+
task-definition: task-definition.json
|
|
102
|
+
container-name: REPLACEME
|
|
103
|
+
image: ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:REPLACEME-${{ steps.vars.outputs.sha_short }}
|
|
104
|
+
- name: Start GitHub Deployment
|
|
105
|
+
uses: bobheadxi/deployments@v1
|
|
106
|
+
id: deployment-start
|
|
107
|
+
with:
|
|
108
|
+
step: start
|
|
109
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
110
|
+
env: ${{ env.DEPLOY_ENV }}
|
|
111
|
+
ref: ${{ github.sha }}
|
|
112
|
+
desc: "Deploying REPLACEME image to ECS"
|
|
113
|
+
- name: Deploy Amazon ECS task definition
|
|
114
|
+
uses: aws-actions/amazon-ecs-deploy-task-definition@v2
|
|
115
|
+
with:
|
|
116
|
+
task-definition: ${{ steps.task-def.outputs.task-definition }}
|
|
117
|
+
service: REPLACEME
|
|
118
|
+
cluster: ${{ secrets.PROJECT_NAME }}
|
|
119
|
+
wait-for-service-stability: true
|
|
120
|
+
|
|
121
|
+
- name: Finish GitHub Deployment
|
|
122
|
+
if: always() # Ensures this runs even if previous step fails
|
|
123
|
+
uses: bobheadxi/deployments@v1
|
|
124
|
+
with:
|
|
125
|
+
step: finish
|
|
126
|
+
token: ${{ secrets.GITHUB_TOKEN }}
|
|
127
|
+
env: ${{ env.DEPLOY_ENV }}
|
|
128
|
+
status: ${{ job.status }}
|
|
129
|
+
deployment_id: ${{ steps.deployment-start.outputs.deployment_id }}
|
|
130
|
+
|
|
131
|
+
notify-slack:
|
|
132
|
+
needs: build
|
|
133
|
+
runs-on: ubuntu-latest
|
|
134
|
+
if: failure()
|
|
135
|
+
steps:
|
|
136
|
+
- name: Send Slack Notification on Failure
|
|
137
|
+
uses: slackapi/slack-github-action@v1.26.0
|
|
138
|
+
with:
|
|
139
|
+
payload: |
|
|
140
|
+
{
|
|
141
|
+
"blocks": [
|
|
142
|
+
{
|
|
143
|
+
"type": "header",
|
|
144
|
+
"text": {
|
|
145
|
+
"type": "plain_text",
|
|
146
|
+
"text": "🚨 Workflow Failed: `${{ github.workflow }}`"
|
|
147
|
+
}
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"type": "section",
|
|
151
|
+
"fields": [
|
|
152
|
+
{
|
|
153
|
+
"type": "mrkdwn",
|
|
154
|
+
"text": "*Repository:*\n<${{ github.server_url }}/${{ github.repository }}|${{ github.repository }}>"
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
"type": "mrkdwn",
|
|
158
|
+
"text": "*Branch:*\n`${{ github.ref_name }}`"
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
"type": "mrkdwn",
|
|
162
|
+
"text": "*Triggered by:*\n`${{ github.triggering_actor }}`"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
"type": "mrkdwn",
|
|
166
|
+
"text": "*Commit:*\n<${{ github.server_url }}/${{ github.repository }}/commit/${{ github.sha }}|${{ github.sha_short }}>"
|
|
167
|
+
}
|
|
168
|
+
]
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
"type": "actions",
|
|
172
|
+
"elements": [
|
|
173
|
+
{
|
|
174
|
+
"type": "button",
|
|
175
|
+
"text": {
|
|
176
|
+
"type": "plain_text",
|
|
177
|
+
"text": "View Workflow Run"
|
|
178
|
+
},
|
|
179
|
+
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}",
|
|
180
|
+
"style": "danger"
|
|
181
|
+
}
|
|
182
|
+
]
|
|
183
|
+
}
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
env:
|
|
187
|
+
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
188
|
+
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
with:
|
|
58
|
+
persist-credentials: false
|
|
59
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
60
|
+
uses: actions/setup-node@v6
|
|
61
|
+
with:
|
|
62
|
+
node-version: ${{ matrix.node-version }}
|
|
63
|
+
- run: yarn install
|
|
64
|
+
- run: yarn lint
|
|
65
|
+
- run: yarn test
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@swovohq/fuel",
|
|
3
|
-
"version": "0.2.2-alpha.
|
|
3
|
+
"version": "0.2.2-alpha.90",
|
|
4
4
|
"bin": {
|
|
5
5
|
"fuel": "dist/bin/fuel.js"
|
|
6
6
|
},
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
"url": "https://github.com/swovohq/fuel-nest.git"
|
|
23
23
|
},
|
|
24
24
|
"scripts": {
|
|
25
|
-
"build": "tsc -p tsconfig.json",
|
|
25
|
+
"build": "yarn generate:schema && tsc -p tsconfig.json && node scripts/copy-infra-templates.js",
|
|
26
|
+
"generate:schema": "ts-node scripts/generate-schema.ts",
|
|
26
27
|
"dev": "ts-node src/bin/fuel.ts",
|
|
27
28
|
"test": "jest --passWithNoTests",
|
|
28
29
|
"lint": "eslint \"src/**/*.ts\""
|
|
@@ -30,6 +31,13 @@
|
|
|
30
31
|
"dependencies": {
|
|
31
32
|
"@aws-sdk/client-s3": "^3.1022.0",
|
|
32
33
|
"@aws-sdk/client-secrets-manager": "^3.1022.0",
|
|
34
|
+
"@azure/arm-authorization": "^9.0.0",
|
|
35
|
+
"@azure/arm-keyvault": "^3.1.0",
|
|
36
|
+
"@azure/arm-resources": "^5.2.0",
|
|
37
|
+
"@azure/arm-storage": "^18.3.0",
|
|
38
|
+
"@azure/identity": "^4.4.1",
|
|
39
|
+
"@azure/keyvault-secrets": "^4.9.0",
|
|
40
|
+
"@azure/storage-blob": "^12.25.0",
|
|
33
41
|
"@octokit/rest": "^22.0.1",
|
|
34
42
|
"chalk": "^4.1.2",
|
|
35
43
|
"commander": "^14.0.3",
|