Skip to content

Commit 43d63ff

Browse files
authored
Merge pull request #37 from datarootsio/open-pr-here
Add more RDS options
2 parents c6c15d6 + 4544a6e commit 43d63ff

File tree

6 files changed

+89
-57
lines changed

6 files changed

+89
-57
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,16 @@ For now the only authentication option is 'RBAC'. When enabling this, this modul
113113
| rbac\_admin\_lastname | RBAC Lastname (only when airflow\_authentication = 'rbac') | `string` | `"airflow"` | no |
114114
| rbac\_admin\_password | RBAC Password (only when airflow\_authentication = 'rbac') | `string` | `"admin"` | no |
115115
| rbac\_admin\_username | RBAC Username (only when airflow\_authentication = 'rbac') | `string` | `"admin"` | no |
116+
| rds\_allocated\_storage | The allocated storage for the rds db in gibibytes | `number` | `20` | no |
116117
| rds\_availability\_zone | Availability zone for the rds instance | `string` | `"eu-west-1a"` | no |
117118
| rds\_deletion\_protection | Deletion protection for the rds instance | `bool` | `false` | no |
119+
| rds\_engine | The database engine to use. For supported values, see the Engine parameter in [API action CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html) | `string` | `"postgres"` | no |
118120
| rds\_instance\_class | The class of instance you want to give to your rds db | `string` | `"db.t2.micro"` | no |
119121
| rds\_password | Password of rds | `string` | `""` | no |
120122
| rds\_skip\_final\_snapshot | Whether or not to skip the final snapshot before deleting (mainly for tests) | `bool` | `false` | no |
123+
| rds\_storage\_type | One of `"standard"` (magnetic), `"gp2"` (general purpose SSD), or `"io1"` (provisioned IOPS SSD) | `string` | `"standard"` | no |
121124
| rds\_username | Username of rds | `string` | `"airflow"` | no |
125+
| rds\_version | The DB version to use for the RDS instance | `string` | `"12.7"` | no |
122126
| region | The region to deploy your solution to | `string` | `"eu-west-1"` | no |
123127
| resource\_prefix | A prefix for the create resources, example your company name (be aware of the resource name length) | `string` | n/a | yes |
124128
| resource\_suffix | A suffix for the created resources, example the environment for airflow to run in (be aware of the resource name length) | `string` | n/a | yes |

examples/basic-local-with-requirements/main.tf

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ provider "aws" {
1212
}
1313

1414
module "airflow" {
15-
source = "datarootsio/ecs-airflow/aws"
15+
source = "datarootsio/ecs-airflow/aws"
1616

17-
resource_prefix = "my-awesome-company"
18-
resource_suffix = "env"
17+
resource_prefix = "my-awesome-company"
18+
resource_suffix = "env"
1919

20-
vpc_id = "vpc-123456"
21-
public_subnet_ids = ["subnet-456789", "subnet-098765"]
20+
vpc_id = "vpc-123456"
21+
public_subnet_ids = ["subnet-456789", "subnet-098765"]
2222

23-
use_https = false
23+
use_https = false
2424

25-
airflow_executor = "Local"
26-
airflow_py_requirements_path = "./requirements.txt"
27-
airflow_variables = {
28-
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
29-
}
25+
airflow_executor = "Local"
26+
airflow_py_requirements_path = "./requirements.txt"
27+
airflow_variables = {
28+
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
29+
}
3030

31-
rds_username = "airflow"
32-
rds_password = "super-secret-pass"
33-
rds_availability_zone = "eu-west-1a"
34-
rds_deletion_protection = false
31+
rds_username = "airflow"
32+
rds_password = "super-secret-pass"
33+
rds_availability_zone = "eu-west-1a"
34+
rds_deletion_protection = false
3535
}
3636

3737
output "airflow_alb_dns" {

examples/basic-sequential-rbac/main.tf

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,22 +12,22 @@ provider "aws" {
1212
}
1313

1414
module "airflow" {
15-
source = "datarootsio/ecs-airflow/aws"
15+
source = "datarootsio/ecs-airflow/aws"
1616

17-
resource_prefix = "my-awesome-company"
18-
resource_suffix = "env"
17+
resource_prefix = "my-awesome-company"
18+
resource_suffix = "env"
1919

20-
vpc_id = "vpc-123456"
21-
public_subnet_ids = ["subnet-456789", "subnet-098765"]
20+
vpc_id = "vpc-123456"
21+
public_subnet_ids = ["subnet-456789", "subnet-098765"]
2222

23-
airflow_executor = "Sequential"
24-
airflow_py_requirements_path = "./requirements.txt"
25-
airflow_authentication = "rbac"
26-
airflow_variables = {
27-
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
28-
}
23+
airflow_executor = "Sequential"
24+
airflow_py_requirements_path = "./requirements.txt"
25+
airflow_authentication = "rbac"
26+
airflow_variables = {
27+
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
28+
}
2929

30-
use_https = false
30+
use_https = false
3131
}
3232

3333
output "airflow_alb_dns" {

examples/basic-sequential/main.tf

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,20 @@ provider "aws" {
1212
}
1313

1414
module "airflow" {
15-
source = "datarootsio/ecs-airflow/aws"
15+
source = "datarootsio/ecs-airflow/aws"
1616

17-
resource_prefix = "my-awesome-company"
18-
resource_suffix = "env"
17+
resource_prefix = "my-awesome-company"
18+
resource_suffix = "env"
1919

20-
vpc_id = "vpc-123456"
21-
public_subnet_ids = ["subnet-456789", "subnet-098765"]
20+
vpc_id = "vpc-123456"
21+
public_subnet_ids = ["subnet-456789", "subnet-098765"]
2222

23-
airflow_executor = "Sequential"
24-
airflow_variables = {
25-
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
26-
}
23+
airflow_executor = "Sequential"
24+
airflow_variables = {
25+
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
26+
}
2727

28-
use_https = false
28+
use_https = false
2929
}
3030

3131
output "airflow_alb_dns" {

rds.tf

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
11
resource "aws_db_instance" "airflow" {
2-
count = var.postgres_uri != "" || var.airflow_executor == "Sequential" ? 0 : 1
3-
name = replace(title(local.rds_name), "-", "")
4-
allocated_storage = 20
5-
storage_type = "standard"
6-
engine = "postgres"
7-
engine_version = "11.8"
8-
instance_class = var.rds_instance_class
9-
username = var.rds_username
10-
password = var.rds_password
11-
multi_az = false
12-
availability_zone = var.rds_availability_zone
13-
publicly_accessible = false
14-
deletion_protection = var.rds_deletion_protection
15-
skip_final_snapshot = var.rds_skip_final_snapshot
16-
final_snapshot_identifier = "${var.resource_prefix}-airflow-${var.resource_suffix}-${local.timestamp_sanitized}"
17-
identifier = local.rds_name
18-
vpc_security_group_ids = [aws_security_group.airflow.id]
19-
db_subnet_group_name = aws_db_subnet_group.airflow[0].name
2+
count = var.postgres_uri != "" || var.airflow_executor == "Sequential" ? 0 : 1
3+
name = replace(title(local.rds_name), "-", "")
4+
allocated_storage = var.rds_allocated_storage
5+
storage_type = var.rds_storage_type
6+
engine = var.rds_engine
7+
engine_version = var.rds_version
8+
auto_minor_version_upgrade = false
9+
instance_class = var.rds_instance_class
10+
username = var.rds_username
11+
password = var.rds_password
12+
multi_az = false
13+
availability_zone = var.rds_availability_zone
14+
publicly_accessible = false
15+
deletion_protection = var.rds_deletion_protection
16+
skip_final_snapshot = var.rds_skip_final_snapshot
17+
final_snapshot_identifier = "${var.resource_prefix}-airflow-${var.resource_suffix}-${local.timestamp_sanitized}"
18+
identifier = local.rds_name
19+
vpc_security_group_ids = [aws_security_group.airflow.id]
20+
db_subnet_group_name = aws_db_subnet_group.airflow[0].name
2021

2122
tags = local.common_tags
2223
}
@@ -27,4 +28,4 @@ resource "aws_db_subnet_group" "airflow" {
2728
subnet_ids = local.rds_ecs_subnet_ids
2829

2930
tags = local.common_tags
30-
}
31+
}

variables.tf

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,28 @@ variable "postgres_uri" {
206206
default = ""
207207
}
208208

209-
// TODO: Add more rds params
209+
variable "rds_allocated_storage" {
210+
type = number
211+
description = "The allocated storage for the rds db in gibibytes"
212+
default = 20
213+
}
214+
215+
variable "rds_storage_type" {
216+
type = string
217+
description = <<EOT
218+
One of `"standard"` (magnetic), `"gp2"` (general purpose SSD), or `"io1"` (provisioned IOPS SSD)
219+
EOT
220+
default = "standard"
221+
}
222+
223+
variable "rds_engine" {
224+
type = string
225+
description = <<EOT
226+
The database engine to use. For supported values, see the Engine parameter in [API action CreateDBInstance](https://docs.aws.amazon.com/AmazonRDS/latest/APIReference/API_CreateDBInstance.html)
227+
EOT
228+
default = "postgres"
229+
}
230+
210231
variable "rds_username" {
211232
type = string
212233
description = "Username of rds"
@@ -243,6 +264,12 @@ variable "rds_deletion_protection" {
243264
default = false
244265
}
245266

267+
variable "rds_version" {
268+
type = string
269+
description = "The DB version to use for the RDS instance"
270+
default = "12.7"
271+
}
272+
246273
// S3 Bucket
247274
variable "s3_bucket_name" {
248275
type = string

0 commit comments

Comments
 (0)