@swovohq/fuel 0.2.2-alpha.88 → 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.
- package/README.md +65 -2
- package/dist/commands/create-app.d.ts.map +1 -1
- package/dist/commands/create-app.js +9 -3
- package/dist/commands/create-app.js.map +1 -1
- package/dist/commands/infra-deploy.d.ts.map +1 -1
- package/dist/commands/infra-deploy.js +3 -0
- package/dist/commands/infra-deploy.js.map +1 -1
- package/dist/commands/infra-init.d.ts.map +1 -1
- package/dist/commands/infra-init.js +63 -6
- package/dist/commands/infra-init.js.map +1 -1
- package/dist/infra/credentials.d.ts.map +1 -1
- package/dist/infra/credentials.js +5 -2
- package/dist/infra/credentials.js.map +1 -1
- package/dist/infra/github-client.d.ts +6 -0
- package/dist/infra/github-client.d.ts.map +1 -1
- package/dist/infra/github-client.js +30 -0
- 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 +16 -7
- package/dist/infra/orchestrator.js.map +1 -1
- package/dist/infra/preflight.d.ts.map +1 -1
- package/dist/infra/preflight.js +9 -1
- package/dist/infra/preflight.js.map +1 -1
- package/dist/infra/template-engine.d.ts +0 -4
- package/dist/infra/template-engine.d.ts.map +1 -1
- package/dist/infra/template-engine.js +36 -12
- package/dist/infra/template-engine.js.map +1 -1
- package/dist/infra/types.d.ts.map +1 -1
- package/dist/infra/types.js +58 -6
- 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 +2 -2
- package/schema/fuel.schema.json +78 -44
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
########################################################################################################################
|
|
2
|
+
## Service variables
|
|
3
|
+
########################################################################################################################
|
|
4
|
+
|
|
5
|
+
variable "app_name" {
|
|
6
|
+
description = "A Docker image-compatible name for the service"
|
|
7
|
+
type = string
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
variable "scenario" {
|
|
11
|
+
description = "Scenario name for tags"
|
|
12
|
+
default = "scenario-ecs-fargate"
|
|
13
|
+
type = string
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
########################################################################################################################
|
|
17
|
+
## ECS variables
|
|
18
|
+
########################################################################################################################
|
|
19
|
+
|
|
20
|
+
variable "ecs_task_desired_count" {
|
|
21
|
+
description = "How many ECS tasks should run in parallel"
|
|
22
|
+
type = number
|
|
23
|
+
default = 1
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
variable "ecs_task_min_count" {
|
|
27
|
+
description = "How many ECS tasks should minimally run in parallel"
|
|
28
|
+
default = 1
|
|
29
|
+
type = number
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
variable "ecs_task_max_count" {
|
|
33
|
+
description = "How many ECS tasks should maximally run in parallel"
|
|
34
|
+
default = 10
|
|
35
|
+
type = number
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
# if you have multiple tasks running this should be 50%, but for 1 task
|
|
39
|
+
# it has to be zero so ecs can drain the task to replace it (making the service unstable for a few minutes)
|
|
40
|
+
variable "ecs_task_deployment_minimum_healthy_percent" {
|
|
41
|
+
description = "How many percent of a service must be running to still execute a safe deployment"
|
|
42
|
+
default = 100
|
|
43
|
+
type = number
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
variable "ecs_task_deployment_maximum_percent" {
|
|
47
|
+
description = "How many additional tasks are allowed to run (in percent) while a deployment is executed"
|
|
48
|
+
default = 200
|
|
49
|
+
type = number
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
variable "cpu_target_tracking_desired_value" {
|
|
53
|
+
description = "Target tracking for CPU usage in %"
|
|
54
|
+
default = 70
|
|
55
|
+
type = number
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
variable "memory_target_tracking_desired_value" {
|
|
59
|
+
description = "Target tracking for memory usage in %"
|
|
60
|
+
default = 80
|
|
61
|
+
type = number
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
variable "target_capacity" {
|
|
65
|
+
description = "Amount of resources of container instances that should be used for task placement in %"
|
|
66
|
+
default = 100
|
|
67
|
+
type = number
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
variable "container_port" {
|
|
71
|
+
description = "Port of the container"
|
|
72
|
+
type = number
|
|
73
|
+
default = 3000
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
variable "cpu_units" {
|
|
77
|
+
description = "Amount of CPU units for a single ECS task"
|
|
78
|
+
default = 1024
|
|
79
|
+
type = number
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
variable "memory" {
|
|
83
|
+
description = "Amount of memory in MB for a single ECS task"
|
|
84
|
+
default = 2048
|
|
85
|
+
type = number
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
variable "aws_region" {
|
|
89
|
+
description = "AWS Region"
|
|
90
|
+
type = string
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
variable "repository_url" {
|
|
94
|
+
description = "Image URL"
|
|
95
|
+
type = string
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
variable "default_security_group_id" {
|
|
99
|
+
description = "VPC Security Group"
|
|
100
|
+
type = string
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
variable "ecs_task_execution_role_arn" {
|
|
104
|
+
description = "ARN for the task execution role"
|
|
105
|
+
type = string
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
variable "ecs_task_role_arn" {
|
|
109
|
+
description = "ARN for the task role"
|
|
110
|
+
type = string
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
variable "ecs_log_group_name" {
|
|
114
|
+
description = "Log group name for ECS"
|
|
115
|
+
type = string
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
variable "ecs_cluster_id" {
|
|
119
|
+
description = "ECS cluster id to attach services to"
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
variable "ecs_cluster_name" {
|
|
123
|
+
description = "ECS cluster name"
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
variable "aws_alb_target_group_arn" {
|
|
127
|
+
description = "AWS ALB target group ARN"
|
|
128
|
+
type = string
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
variable "ecs_container_security_group_id" {
|
|
132
|
+
description = "ECS Container Security Group ID"
|
|
133
|
+
type = string
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
variable "private_subnets" {
|
|
137
|
+
description = "Private subnets for the ECS cluster"
|
|
138
|
+
default = ""
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
variable "ecs_secret_arn" {
|
|
142
|
+
description = "ARN for secrets"
|
|
143
|
+
type = string
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
variable "connect_to_alb" {
|
|
147
|
+
description = "Is this a public service?"
|
|
148
|
+
type = bool
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
variable "secret_name" {
|
|
152
|
+
description = "Name of the secret to use"
|
|
153
|
+
type = string
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
variable "env_vars" {
|
|
157
|
+
type = map(string)
|
|
158
|
+
default = {}
|
|
159
|
+
}
|
|
160
|
+
variable "ecs_circuit_breaker" {
|
|
161
|
+
description = "Enable Circuit Breaker"
|
|
162
|
+
type = bool
|
|
163
|
+
default = true
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
variable "ecs_rollback" {
|
|
167
|
+
description = "Automatically rollback if failure occurs"
|
|
168
|
+
type = bool
|
|
169
|
+
default = true
|
|
170
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
locals {
|
|
2
|
+
all_apps = merge(
|
|
3
|
+
{ for app in var.apps : app.app_name => app },
|
|
4
|
+
{ for worker in var.workers : worker.worker_name => worker }
|
|
5
|
+
)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
module "ecr" {
|
|
9
|
+
source = "terraform-aws-modules/ecr/aws"
|
|
10
|
+
version = "2.2.0"
|
|
11
|
+
|
|
12
|
+
repository_name = "${var.project_name}-application"
|
|
13
|
+
repository_force_delete = true
|
|
14
|
+
repository_image_tag_mutability = "MUTABLE"
|
|
15
|
+
repository_lifecycle_policy = jsonencode({
|
|
16
|
+
rules = [
|
|
17
|
+
for idx, app_key in zipmap(range(length(keys(local.all_apps))), keys(local.all_apps)) : {
|
|
18
|
+
rulePriority = idx + 1
|
|
19
|
+
description = "Keep 5 most recent images with prefix '${app_key}'"
|
|
20
|
+
selection = {
|
|
21
|
+
tagStatus = "tagged"
|
|
22
|
+
tagPrefixList = [app_key]
|
|
23
|
+
countType = "imageCountMoreThan"
|
|
24
|
+
countNumber = 5
|
|
25
|
+
}
|
|
26
|
+
action = {
|
|
27
|
+
type = "expire"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
]
|
|
31
|
+
})
|
|
32
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
variable "project_name" {
|
|
2
|
+
description = "Repository name will be created based on project name"
|
|
3
|
+
default = ""
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
variable "apps" {
|
|
7
|
+
description = "An array of apps from config.json"
|
|
8
|
+
type = set(object({
|
|
9
|
+
app_name = string
|
|
10
|
+
technology = string
|
|
11
|
+
dockerfile = string
|
|
12
|
+
build_env = string
|
|
13
|
+
}))
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
variable "workers" {
|
|
17
|
+
description = "An array of workers from config.json"
|
|
18
|
+
type = set(object({
|
|
19
|
+
app_name = string
|
|
20
|
+
technology = string
|
|
21
|
+
dockerfile = string
|
|
22
|
+
worker_name = string
|
|
23
|
+
build_env = string
|
|
24
|
+
}))
|
|
25
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
locals {
|
|
2
|
+
oidc_provider_arn = "arn:aws:iam::${var.aws_account_id}:oidc-provider/token.actions.githubusercontent.com"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
moved {
|
|
6
|
+
from = aws_iam_openid_connect_provider.github[0]
|
|
7
|
+
to = aws_iam_openid_connect_provider.github
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
resource "aws_iam_openid_connect_provider" "github" {
|
|
11
|
+
url = "https://token.actions.githubusercontent.com"
|
|
12
|
+
client_id_list = ["sts.amazonaws.com"]
|
|
13
|
+
thumbprint_list = ["6938fd4d98bab03faadb97b34396831e3780aea1"]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
resource "aws_iam_role" "github_actions_role" {
|
|
17
|
+
name = "${var.project_name}-github-actions-role"
|
|
18
|
+
|
|
19
|
+
assume_role_policy = jsonencode({
|
|
20
|
+
Version = "2012-10-17"
|
|
21
|
+
Statement = [
|
|
22
|
+
{
|
|
23
|
+
Effect = "Allow"
|
|
24
|
+
Principal = {
|
|
25
|
+
Federated = local.oidc_provider_arn
|
|
26
|
+
}
|
|
27
|
+
Action = "sts:AssumeRoleWithWebIdentity"
|
|
28
|
+
Condition = {
|
|
29
|
+
StringLike = {
|
|
30
|
+
"token.actions.githubusercontent.com:sub" = "repo:${var.github_organization}/*"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
})
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resource "aws_iam_role_policy_attachment" "ecr_image_builder_policy" {
|
|
39
|
+
role = aws_iam_role.github_actions_role.name
|
|
40
|
+
policy_arn = "arn:aws:iam::aws:policy/EC2InstanceProfileForImageBuilderECRContainerBuilds"
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
resource "aws_iam_role_policy_attachment" "ecs_full_access" {
|
|
44
|
+
role = aws_iam_role.github_actions_role.name
|
|
45
|
+
policy_arn = "arn:aws:iam::aws:policy/AmazonECS_FullAccess"
|
|
46
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
variable "project_name" {
|
|
2
|
+
description = "Project name used as prefix for resource names"
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
variable "github_organization" {
|
|
6
|
+
description = "GitHub organization name for OIDC trust policy"
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
variable "aws_account_id" {
|
|
10
|
+
description = "AWS account ID for constructing OIDC provider ARN"
|
|
11
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
resource "aws_iam_policy" "this" {
|
|
2
|
+
name = "${var.project_name}AWSLoadBalancerControllerIAMPolicy"
|
|
3
|
+
description = "IAM policy for Load Balancer"
|
|
4
|
+
policy = jsonencode({
|
|
5
|
+
Version = "2012-10-17"
|
|
6
|
+
Statement = [
|
|
7
|
+
{
|
|
8
|
+
Effect = "Allow"
|
|
9
|
+
Action = [
|
|
10
|
+
"iam:CreateServiceLinkedRole"
|
|
11
|
+
]
|
|
12
|
+
Resource = "*"
|
|
13
|
+
Condition = {
|
|
14
|
+
StringEquals = {
|
|
15
|
+
"iam:AWSServiceName" : "elasticloadbalancing.amazonaws.com"
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
Effect = "Allow"
|
|
21
|
+
Action = [
|
|
22
|
+
"ec2:DescribeAccountAttributes",
|
|
23
|
+
"ec2:DescribeAddresses",
|
|
24
|
+
"ec2:DescribeAvailabilityZones",
|
|
25
|
+
"ec2:DescribeInternetGateways",
|
|
26
|
+
"ec2:DescribeVpcs",
|
|
27
|
+
"ec2:DescribeVpcPeeringConnections",
|
|
28
|
+
"ec2:DescribeSubnets",
|
|
29
|
+
"ec2:DescribeSecurityGroups",
|
|
30
|
+
"ec2:DescribeInstances",
|
|
31
|
+
"ec2:DescribeNetworkInterfaces",
|
|
32
|
+
"ec2:DescribeTags",
|
|
33
|
+
"ec2:GetCoipPoolUsage",
|
|
34
|
+
"ec2:DescribeCoipPools",
|
|
35
|
+
"elasticloadbalancing:DescribeLoadBalancers",
|
|
36
|
+
"elasticloadbalancing:DescribeLoadBalancerAttributes",
|
|
37
|
+
"elasticloadbalancing:DescribeListeners",
|
|
38
|
+
"elasticloadbalancing:DescribeListenerCertificates",
|
|
39
|
+
"elasticloadbalancing:DescribeSSLPolicies",
|
|
40
|
+
"elasticloadbalancing:DescribeRules",
|
|
41
|
+
"elasticloadbalancing:DescribeTargetGroups",
|
|
42
|
+
"elasticloadbalancing:DescribeTargetGroupAttributes",
|
|
43
|
+
"elasticloadbalancing:DescribeTargetHealth",
|
|
44
|
+
"elasticloadbalancing:DescribeTags"
|
|
45
|
+
]
|
|
46
|
+
Resource = "*"
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
Effect = "Allow"
|
|
50
|
+
Action = [
|
|
51
|
+
"cognito-idp:DescribeUserPoolClient",
|
|
52
|
+
"acm:ListCertificates",
|
|
53
|
+
"acm:DescribeCertificate",
|
|
54
|
+
"iam:ListServerCertificates",
|
|
55
|
+
"iam:GetServerCertificate",
|
|
56
|
+
"waf-regional:GetWebACL",
|
|
57
|
+
"waf-regional:GetWebACLForResource",
|
|
58
|
+
"waf-regional:AssociateWebACL",
|
|
59
|
+
"waf-regional:DisassociateWebACL",
|
|
60
|
+
"wafv2:GetWebACL",
|
|
61
|
+
"wafv2:GetWebACLForResource",
|
|
62
|
+
"wafv2:AssociateWebACL",
|
|
63
|
+
"wafv2:DisassociateWebACL",
|
|
64
|
+
"shield:GetSubscriptionState",
|
|
65
|
+
"shield:DescribeProtection",
|
|
66
|
+
"shield:CreateProtection",
|
|
67
|
+
"shield:DeleteProtection"
|
|
68
|
+
]
|
|
69
|
+
Resource = "*"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
Effect = "Allow"
|
|
73
|
+
Action = [
|
|
74
|
+
"ec2:AuthorizeSecurityGroupIngress",
|
|
75
|
+
"ec2:RevokeSecurityGroupIngress"
|
|
76
|
+
]
|
|
77
|
+
Resource = "*"
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
Effect = "Allow"
|
|
81
|
+
Action = [
|
|
82
|
+
"ec2:CreateSecurityGroup"
|
|
83
|
+
]
|
|
84
|
+
Resource = "*"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
Effect = "Allow"
|
|
88
|
+
Action = [
|
|
89
|
+
"ec2:CreateTags"
|
|
90
|
+
]
|
|
91
|
+
Resource = "arn:aws:ec2:*:*:security-group/*"
|
|
92
|
+
Condition = {
|
|
93
|
+
StringEquals = {
|
|
94
|
+
"ec2:CreateAction" : "CreateSecurityGroup"
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
Effect = "Allow"
|
|
100
|
+
Action = [
|
|
101
|
+
"ec2:AuthorizeSecurityGroupIngress",
|
|
102
|
+
"ec2:RevokeSecurityGroupIngress",
|
|
103
|
+
"ec2:DeleteSecurityGroup"
|
|
104
|
+
]
|
|
105
|
+
Resource = "*"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
Effect = "Allow"
|
|
109
|
+
Action = [
|
|
110
|
+
"elasticloadbalancing:CreateLoadBalancer",
|
|
111
|
+
"elasticloadbalancing:CreateTargetGroup"
|
|
112
|
+
]
|
|
113
|
+
Resource = "*"
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
Effect = "Allow"
|
|
117
|
+
Action = [
|
|
118
|
+
"elasticloadbalancing:CreateListener",
|
|
119
|
+
"elasticloadbalancing:DeleteListener",
|
|
120
|
+
"elasticloadbalancing:CreateRule",
|
|
121
|
+
"elasticloadbalancing:DeleteRule"
|
|
122
|
+
]
|
|
123
|
+
Resource = "*"
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
Effect = "Allow"
|
|
127
|
+
Action = [
|
|
128
|
+
"elasticloadbalancing:AddTags",
|
|
129
|
+
"elasticloadbalancing:RemoveTags"
|
|
130
|
+
]
|
|
131
|
+
Resource = [
|
|
132
|
+
"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*",
|
|
133
|
+
"arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*",
|
|
134
|
+
"arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
Effect = "Allow"
|
|
139
|
+
Action = [
|
|
140
|
+
"elasticloadbalancing:AddTags",
|
|
141
|
+
"elasticloadbalancing:RemoveTags"
|
|
142
|
+
]
|
|
143
|
+
Resource = [
|
|
144
|
+
"arn:aws:elasticloadbalancing:*:*:listener/net/*/*/*",
|
|
145
|
+
"arn:aws:elasticloadbalancing:*:*:listener/app/*/*/*",
|
|
146
|
+
"arn:aws:elasticloadbalancing:*:*:listener-rule/net/*/*/*",
|
|
147
|
+
"arn:aws:elasticloadbalancing:*:*:listener-rule/app/*/*/*"
|
|
148
|
+
]
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
Effect = "Allow"
|
|
152
|
+
Action = [
|
|
153
|
+
"elasticloadbalancing:ModifyLoadBalancerAttributes",
|
|
154
|
+
"elasticloadbalancing:SetIpAddressType",
|
|
155
|
+
"elasticloadbalancing:SetSecurityGroups",
|
|
156
|
+
"elasticloadbalancing:SetSubnets",
|
|
157
|
+
"elasticloadbalancing:DeleteLoadBalancer",
|
|
158
|
+
"elasticloadbalancing:ModifyTargetGroup",
|
|
159
|
+
"elasticloadbalancing:ModifyTargetGroupAttributes",
|
|
160
|
+
"elasticloadbalancing:DeleteTargetGroup"
|
|
161
|
+
]
|
|
162
|
+
Resource = "*"
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
Effect = "Allow"
|
|
166
|
+
Action = [
|
|
167
|
+
"elasticloadbalancing:AddTags"
|
|
168
|
+
]
|
|
169
|
+
Resource = [
|
|
170
|
+
"arn:aws:elasticloadbalancing:*:*:targetgroup/*/*",
|
|
171
|
+
"arn:aws:elasticloadbalancing:*:*:loadbalancer/net/*/*",
|
|
172
|
+
"arn:aws:elasticloadbalancing:*:*:loadbalancer/app/*/*"
|
|
173
|
+
]
|
|
174
|
+
Condition = {
|
|
175
|
+
StringEquals = {
|
|
176
|
+
"elasticloadbalancing:CreateAction" : [
|
|
177
|
+
"CreateTargetGroup",
|
|
178
|
+
"CreateLoadBalancer"
|
|
179
|
+
]
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
Effect = "Allow"
|
|
185
|
+
Action = [
|
|
186
|
+
"elasticloadbalancing:RegisterTargets",
|
|
187
|
+
"elasticloadbalancing:DeregisterTargets"
|
|
188
|
+
]
|
|
189
|
+
Resource = "arn:aws:elasticloadbalancing:*:*:targetgroup/*/*"
|
|
190
|
+
},
|
|
191
|
+
{
|
|
192
|
+
Effect = "Allow"
|
|
193
|
+
Action = [
|
|
194
|
+
"elasticloadbalancing:SetWebAcl",
|
|
195
|
+
"elasticloadbalancing:ModifyListener",
|
|
196
|
+
"elasticloadbalancing:AddListenerCertificates",
|
|
197
|
+
"elasticloadbalancing:RemoveListenerCertificates",
|
|
198
|
+
"elasticloadbalancing:ModifyRule"
|
|
199
|
+
]
|
|
200
|
+
Resource = "*"
|
|
201
|
+
}
|
|
202
|
+
]
|
|
203
|
+
})
|
|
204
|
+
}
|
|
205
|
+
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
variable "name" {
|
|
2
|
+
type = string
|
|
3
|
+
description = "Keeper value — disambiguates this instance so unrelated random-key module calls don't collide or force each other to regenerate."
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
variable "length" {
|
|
7
|
+
type = number
|
|
8
|
+
description = "Length of the generated random string."
|
|
9
|
+
default = 32
|
|
10
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
resource "aws_security_group" "staging" {
|
|
2
|
+
name = "${var.app_name}-redis-sg"
|
|
3
|
+
description = "Allow Redis traffic"
|
|
4
|
+
vpc_id = var.vpc_id
|
|
5
|
+
|
|
6
|
+
ingress {
|
|
7
|
+
from_port = 6379
|
|
8
|
+
to_port = 6379
|
|
9
|
+
protocol = "tcp"
|
|
10
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
egress {
|
|
14
|
+
from_port = 0
|
|
15
|
+
to_port = 0
|
|
16
|
+
protocol = "-1"
|
|
17
|
+
cidr_blocks = ["0.0.0.0/0"]
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
resource "aws_elasticache_subnet_group" "staging" {
|
|
22
|
+
name = "${var.app_name}-ecsg"
|
|
23
|
+
subnet_ids = var.subnet_ids
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
resource "aws_elasticache_cluster" "staging" {
|
|
27
|
+
cluster_id = var.app_name
|
|
28
|
+
engine = "redis"
|
|
29
|
+
node_type = var.node_type
|
|
30
|
+
num_cache_nodes = 1
|
|
31
|
+
parameter_group_name = aws_elasticache_parameter_group.staging.name
|
|
32
|
+
engine_version = "7.1"
|
|
33
|
+
port = 6379
|
|
34
|
+
subnet_group_name = aws_elasticache_subnet_group.staging.name
|
|
35
|
+
security_group_ids = [aws_security_group.staging.id]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
resource "aws_elasticache_parameter_group" "staging" {
|
|
39
|
+
name = "${var.app_name}-ec-param-group"
|
|
40
|
+
family = "redis7"
|
|
41
|
+
description = "Custom parameter group for Redis cluster"
|
|
42
|
+
|
|
43
|
+
parameter {
|
|
44
|
+
name = "maxmemory-policy"
|
|
45
|
+
value = "noeviction"
|
|
46
|
+
}
|
|
47
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
variable "vpc_id" {
|
|
2
|
+
description = "The id of environment VPC"
|
|
3
|
+
default = ""
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
variable "subnet_ids" {
|
|
7
|
+
type = list(string)
|
|
8
|
+
description = "List of private subnet IDs"
|
|
9
|
+
default = []
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
variable "app_name" {
|
|
13
|
+
description = "Cognito user pool name"
|
|
14
|
+
default = ""
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
variable "node_type" {
|
|
18
|
+
description = "ElastiCache node type"
|
|
19
|
+
default = "cache.t3.small"
|
|
20
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
resource "random_password" "db" {
|
|
2
|
+
length = 32
|
|
3
|
+
special = false
|
|
4
|
+
|
|
5
|
+
keepers = {
|
|
6
|
+
app_name = var.app_name
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
locals {
|
|
11
|
+
effective_db_password = coalesce(var.db_password, random_password.db.result)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
module "db" {
|
|
15
|
+
source = "terraform-aws-modules/rds/aws"
|
|
16
|
+
version = "6.13.1"
|
|
17
|
+
|
|
18
|
+
identifier = var.app_name
|
|
19
|
+
|
|
20
|
+
engine = "postgres"
|
|
21
|
+
engine_version = "14.22"
|
|
22
|
+
instance_class = var.db_instance_type
|
|
23
|
+
allocated_storage = var.db_allocated_storage
|
|
24
|
+
|
|
25
|
+
db_name = var.db_name
|
|
26
|
+
username = var.db_username
|
|
27
|
+
password = local.effective_db_password
|
|
28
|
+
|
|
29
|
+
iam_database_authentication_enabled = false
|
|
30
|
+
manage_master_user_password = false
|
|
31
|
+
publicly_accessible = true
|
|
32
|
+
|
|
33
|
+
vpc_security_group_ids = [aws_security_group.this.id, var.vpc_security_group_default]
|
|
34
|
+
|
|
35
|
+
maintenance_window = "Mon:00:00-Mon:03:00"
|
|
36
|
+
backup_window = "03:00-06:00"
|
|
37
|
+
|
|
38
|
+
create_db_subnet_group = true
|
|
39
|
+
subnet_ids = var.subnet_ids
|
|
40
|
+
|
|
41
|
+
family = "postgres14"
|
|
42
|
+
major_engine_version = "14"
|
|
43
|
+
deletion_protection = false
|
|
44
|
+
}
|