Skip to content

Commit b2bf130

Browse files
committed
Fix aws logs stream error
1. Add terraform.tfvars description 2. Fix issue with awslogs stream Signed-off-by: Edward Wilde <[email protected]>
1 parent 7c19204 commit b2bf130

File tree

8 files changed

+40
-14
lines changed

8 files changed

+40
-14
lines changed

README.md

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,27 +22,45 @@ terraform --version
2222
You will need to create a new file in the root of this repo called `terraform.tfvars`
2323
which configures variables used to install `faas-ecs`
2424

25-
|Name|Description|
26-
|----|-----------|
27-
|aws_region|The aws region to create the openfaas ecs cluster in|
28-
|debug| `1` to create an ec2 bastion in the external subnet and a test instance in the internal subnet|
29-
|developer_ip| your ip address, used to whitelist incoming ssh to bastion|
25+
| Name | Description |
26+
|---------------------|----------------------------------------------------------------------------------------------------------------------------------|
27+
| acme_enabled | (Recommend)`1` to use the official [acme]() terraform provider to create TLS certificates. Defaults to `0` |
28+
| acme_email_address | (Recommend) Email address used to register TLS account, used in conjunction with `acme_enabled` |
29+
| aws_region | (Required) The aws region to create the openfaas ecs cluster in |
30+
| alb_logs_bucket | (Required) S3 bucket to store alb logs |
31+
| debug | (Optional) `1` to create an ec2 bastion in the external subnet and a test instance in the internal subnet. Defaults to `0` |
32+
| developer_ip | your ip address, used to whitelist incoming ssh to the bastion, debug is enabled |
33+
| route53_zone_name | (Recommended) a route 53 zone to create DNS records for the OpenFaaS gateway, i.e. openfaas.example.com, requires `acme_enabled` |
34+
| self_signed_enabled | (Not recommended) Use a self-signed TLS certificate for the OpenFaaS gateway if not using `acme_enabled`. Defaults to `0` |
35+
36+
3037

3138
**_Example file_**
3239
```
3340
cat > ./terraform.tfvars <<EOF
34-
aws_region = "eu-west-1"
35-
debug = "0"
36-
developer_ip = "217.46.68.185"
41+
acme_enabled = "1"
42+
acme_email_address = "[email protected]"
43+
alb_logs_bucket = "ewilde-logs"
44+
aws_region = "eu-west-1"
45+
debug = "1"
46+
developer_ip = "31.53.195.58"
47+
route53_zone_name = "openfaas.edwardwilde.com"
48+
self_signed_enabled = "0"
3749
EOF
3850
```
3951
3. **Create a public key for ssh**
4052

41-
Ssh access is only required if `debug = "1"`, however the ssh key is still required for the
53+
> Ssh access is only required if `debug = "1"`, however the ssh key is still required for the
4254
install to work even if debug disabled. To create the key run:
4355

4456
`make keys`
4557

58+
4. Create bucket for alb logs
59+
If you don't already have a bucket, please create the bucket you listed in your `terraform.tfvars` in the variable
60+
`alb_logs_bucket`
61+
62+
i.e. `aws s3api create-bucket --bucket ewilde-logs --region eu-west-1 --create-bucket-configuration LocationConstraint=eu-west-1`
63+
4664
4. **Run terraform**
4765

4866
`make`

alb-acme.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@ resource "aws_iam_server_certificate" "acme" {
3232
}
3333

3434
data "aws_route53_zone" "main" {
35-
name = "${var.acme_domain_name}"
35+
name = "${var.route53_zone_name}"
36+
count = "${var.acme_enabled}"
3637
}
3738

3839
resource "aws_route53_record" "main" {

gateway.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ resource "aws_ecs_task_definition" "gateway" {
8686
"options": {
8787
"awslogs-group": "${aws_cloudwatch_log_group.gateway_log.name}",
8888
"awslogs-region": "${var.aws_region}",
89+
"awslogs-stream-prefix": "gateway-"
8990
}
9091
},
9192
"healthCheck": {
@@ -126,6 +127,7 @@ resource "aws_ecs_task_definition" "gateway" {
126127
"options": {
127128
"awslogs-group": "${aws_cloudwatch_log_group.gateway_log_fargate_provider.name}",
128129
"awslogs-region": "${var.aws_region}",
130+
"awslogs-stream-prefix": "provider-"
129131
}
130132
},
131133
"healthCheck": {
@@ -153,6 +155,7 @@ resource "aws_ecs_task_definition" "gateway" {
153155
"options": {
154156
"awslogs-group": "${aws_cloudwatch_log_group.gateway_log_kms.name}",
155157
"awslogs-region": "${var.aws_region}",
158+
"awslogs-stream-prefix": "kms-template-"
156159
}
157160
},
158161
"healthCheck": {

nats.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ resource "aws_ecs_task_definition" "nats" {
4343
"options": {
4444
"awslogs-group": "${aws_cloudwatch_log_group.nats.name}",
4545
"awslogs-region": "${var.aws_region}",
46+
"awslogs-stream-prefix": "nats-"
4647
}
4748
},
4849
"healthCheck": {
@@ -90,6 +91,7 @@ resource "aws_ecs_task_definition" "nats" {
9091
"options": {
9192
"awslogs-group": "${aws_cloudwatch_log_group.nats_queue_worker.name}",
9293
"awslogs-region": "${var.aws_region}",
94+
"awslogs-stream-prefix": "queue-worker-"
9395
}
9496
},
9597
"healthCheck": {

output.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ output "alb_uri" {
1515
}
1616

1717
output "openfass_uri" {
18-
value = "https://${aws_lb.openfaas.dns_name}"
18+
value = "https://gateway.${var.route53_zone_name}/ui/"
1919
}
2020

2121
output "login" {
2222
value = "echo -n \"${random_string.basic_auth_password.result}\" | faas-cli login --gateway https://${aws_lb.openfaas.dns_name} --username=admin --password-stdin --tls-no-verify"
2323
}
2424

2525
output "login_secure" {
26-
value = "echo -n \"${random_string.basic_auth_password.result}\" | faas-cli login --gateway https://gateway.${var.acme_domain_name} --username=admin --password-stdin"
26+
value = "echo -n \"${random_string.basic_auth_password.result}\" | faas-cli login --gateway https://gateway.${var.route53_zone_name} --username=admin --password-stdin"
2727
}

service-internal-with-lb/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ resource "aws_ecs_task_definition" "main" {
9191
"options": {
9292
"awslogs-group": "${aws_cloudwatch_log_group.main.name}",
9393
"awslogs-region": "${var.aws_region}",
94+
"awslogs-stream-prefix": "${var.name}-"
9495
}
9596
},
9697
"healthCheck": {

service-internal/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ resource "aws_ecs_task_definition" "main" {
6060
"options": {
6161
"awslogs-group": "${aws_cloudwatch_log_group.main.name}",
6262
"awslogs-region": "${var.aws_region}",
63+
"awslogs-stream-prefix": "${var.name}-"
6364
}
6465
},
6566
"healthCheck": {

variables.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ variable "acme_email_address" {
4545
default = "[email protected]"
4646
}
4747

48-
variable "acme_domain_name" {
49-
default = ""
48+
variable "route53_zone_name" {
49+
default = "foo"
5050
}
5151

5252
variable "alb_logs_bucket" {}

0 commit comments

Comments
 (0)