Skip to content

Commit 29b3899

Browse files
authored
adds sidecars (#12)
* adds makes provider sidecar of gateway * add nats and queue worker in same task definition Signed-off-by: Edward Wilde <[email protected]>
1 parent b261e9d commit 29b3899

File tree

6 files changed

+181
-206
lines changed

6 files changed

+181
-206
lines changed

debug.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,16 +118,6 @@ resource "aws_security_group_rule" "bastion_egress_services" {
118118
protocol = "tcp"
119119
}
120120

121-
resource "aws_security_group_rule" "bastion_egress_ecs_provider" {
122-
count = "${var.debug}"
123-
type = "egress"
124-
security_group_id = "${aws_security_group.bastion.id}"
125-
source_security_group_id = "${aws_security_group.ecs_provider.id}"
126-
from_port = 8081
127-
to_port = 8081
128-
protocol = "tcp"
129-
}
130-
131121
resource "aws_key_pair" "bastion_ssh" {
132122
key_name = "${var.bastion_keypair_name}"
133123
public_key = "${file("${path.module}/keys/${var.bastion_keypair_name}.pub")}"

fargate-provider.tf

Lines changed: 0 additions & 108 deletions
This file was deleted.

gateway.tf

Lines changed: 94 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ resource "aws_ecs_task_definition" "gateway" {
4545
"environment": [
4646
{
4747
"name": "functions_provider_url",
48-
"value": "http://${module.ecs_provider.service_discovery_name}.${aws_service_discovery_private_dns_namespace.openfaas.name}:8081/"
48+
"value": "http://localhost:8081/"
4949
},
5050
{
5151
"name": "faas_nats_address",
@@ -93,10 +93,47 @@ resource "aws_ecs_task_definition" "gateway" {
9393
"interval": 5,
9494
"startPeriod": 5
9595
}
96+
},
97+
{
98+
"name": "fargate-provider",
99+
"cpu": 64,
100+
"memory": 64,
101+
"image": "ewilde/faas-fargate:latest",
102+
"environment": [
103+
{
104+
"name" : "port",
105+
"value" : "8081"
106+
},
107+
{
108+
"name" : "subnet_ids",
109+
"value" : "${join(",", aws_subnet.internal.*.id)}"
110+
},
111+
{
112+
"name" : "security_group_id",
113+
"value" : "${aws_security_group.service.id}"
114+
}
115+
116+
],
117+
"essential": true,
118+
"logConfiguration": {
119+
"logDriver": "awslogs",
120+
"options": {
121+
"awslogs-group": "${aws_cloudwatch_log_group.gateway_log_fargate_provider.name}",
122+
"awslogs-region": "${var.aws_region}",
123+
"awslogs-stream-prefix": "gateway-fargate-provider"
124+
}
125+
},
126+
"healthCheck": {
127+
"retries": 1,
128+
"command": ["CMD-SHELL","ls"],
129+
"timeout": 3,
130+
"interval": 5,
131+
"startPeriod": 5
132+
}
96133
},
97134
{
98135
"name": "gateway-kms",
99-
"cpu": 128,
136+
"cpu": 64,
100137
"memory": 32,
101138
"environment": [
102139
{
@@ -134,6 +171,10 @@ resource "aws_cloudwatch_log_group" "gateway_log" {
134171
name = "${var.namespace}-gateway"
135172
}
136173

174+
resource "aws_cloudwatch_log_group" "gateway_log_fargate_provider" {
175+
name = "${var.namespace}-gateway-fargate-provider"
176+
}
177+
137178
resource "aws_cloudwatch_log_group" "gateway_log_kms" {
138179
name = "${var.namespace}-gateway-kms"
139180
}
@@ -228,15 +269,6 @@ resource "aws_security_group_rule" "gateway_egress_nats_management" {
228269
protocol = "tcp"
229270
}
230271

231-
resource "aws_security_group_rule" "gateway_egress_ecs" {
232-
type = "egress"
233-
security_group_id = "${aws_security_group.gateway.id}"
234-
source_security_group_id = "${aws_security_group.ecs_provider.id}"
235-
from_port = 8081
236-
to_port = 8081
237-
protocol = "tcp"
238-
}
239-
240272
resource "aws_security_group_rule" "gateway_egress_functions" {
241273
type = "egress"
242274
security_group_id = "${aws_security_group.gateway.id}"
@@ -315,12 +347,61 @@ resource "aws_iam_role_policy" "gateway_role_policy" {
315347
{
316348
"Effect": "Allow",
317349
"Action": [
318-
"secretsmanager:GetSecretValue"
350+
"secretsmanager:GetSecretValue",
351+
"secretsmanager:DescribeSecret"
319352
],
320353
"Resource": [
321354
"${aws_secretsmanager_secret.basic_auth_user.id}",
322-
"${aws_secretsmanager_secret.basic_auth_password.id}"
355+
"${aws_secretsmanager_secret.basic_auth_password.id}",
356+
"arn:aws:secretsmanager:*:*:secret:openfaas-*"
357+
]
358+
},
359+
{
360+
"Effect": "Allow",
361+
"Action": [
362+
"iam:CreateRole",
363+
"iam:PutRolePolicy"
364+
],
365+
"Resource": [
366+
"arn:aws:iam::*:role/openfaas-*"
367+
]
368+
},
369+
{
370+
"Effect": "Allow",
371+
"Action": [
372+
"iam:PassRole"
373+
],
374+
"Resource": [
375+
"*"
323376
]
377+
},
378+
{
379+
"Effect": "Allow",
380+
"Action": [
381+
"ecs:*"
382+
],
383+
"Resource": [
384+
"*"
385+
]
386+
},
387+
{
388+
"Effect": "Allow",
389+
"Action": [
390+
"ec2:DescribeVpcs",
391+
"ec2:DescribeSubnets"
392+
],
393+
"Resource": [
394+
"*"
395+
]
396+
},
397+
{
398+
"Effect": "Allow",
399+
"Action": [
400+
"servicediscovery:*"
401+
],
402+
"Resource": [
403+
"*"
404+
]
324405
}
325406
]
326407
}

nats-queue-worker.tf

Lines changed: 0 additions & 71 deletions
This file was deleted.

0 commit comments

Comments
 (0)