Skip to content

Commit

Permalink
Merge pull request #37 from datarootsio/open-pr-here
Browse files Browse the repository at this point in the history
Add more RDS options
  • Loading branch information
dpfeif authored Sep 27, 2021
2 parents c6c15d6 + 4544a6e commit 43d63ff
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 57 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,12 +113,16 @@ For now the only authentication option is 'RBAC'. When enabling this, this modul
| rbac\_admin\_lastname | RBAC Lastname (only when airflow\_authentication = 'rbac') | `string` | `"airflow"` | no |
| rbac\_admin\_password | RBAC Password (only when airflow\_authentication = 'rbac') | `string` | `"admin"` | no |
| rbac\_admin\_username | RBAC Username (only when airflow\_authentication = 'rbac') | `string` | `"admin"` | no |
| rds\_allocated\_storage | The allocated storage for the rds db in gibibytes | `number` | `20` | no |
| rds\_availability\_zone | Availability zone for the rds instance | `string` | `"eu-west-1a"` | no |
| rds\_deletion\_protection | Deletion protection for the rds instance | `bool` | `false` | no |
| 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 |
| rds\_instance\_class | The class of instance you want to give to your rds db | `string` | `"db.t2.micro"` | no |
| rds\_password | Password of rds | `string` | `""` | no |
| rds\_skip\_final\_snapshot | Whether or not to skip the final snapshot before deleting (mainly for tests) | `bool` | `false` | no |
| rds\_storage\_type | One of `"standard"` (magnetic), `"gp2"` (general purpose SSD), or `"io1"` (provisioned IOPS SSD) | `string` | `"standard"` | no |
| rds\_username | Username of rds | `string` | `"airflow"` | no |
| rds\_version | The DB version to use for the RDS instance | `string` | `"12.7"` | no |
| region | The region to deploy your solution to | `string` | `"eu-west-1"` | no |
| resource\_prefix | A prefix for the create resources, example your company name (be aware of the resource name length) | `string` | n/a | yes |
| 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 |
Expand Down
30 changes: 15 additions & 15 deletions examples/basic-local-with-requirements/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,26 +12,26 @@ provider "aws" {
}

module "airflow" {
source = "datarootsio/ecs-airflow/aws"
source = "datarootsio/ecs-airflow/aws"

resource_prefix = "my-awesome-company"
resource_suffix = "env"
resource_prefix = "my-awesome-company"
resource_suffix = "env"

vpc_id = "vpc-123456"
public_subnet_ids = ["subnet-456789", "subnet-098765"]
vpc_id = "vpc-123456"
public_subnet_ids = ["subnet-456789", "subnet-098765"]

use_https = false
use_https = false

airflow_executor = "Local"
airflow_py_requirements_path = "./requirements.txt"
airflow_variables = {
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
}
airflow_executor = "Local"
airflow_py_requirements_path = "./requirements.txt"
airflow_variables = {
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
}

rds_username = "airflow"
rds_password = "super-secret-pass"
rds_availability_zone = "eu-west-1a"
rds_deletion_protection = false
rds_username = "airflow"
rds_password = "super-secret-pass"
rds_availability_zone = "eu-west-1a"
rds_deletion_protection = false
}

output "airflow_alb_dns" {
Expand Down
24 changes: 12 additions & 12 deletions examples/basic-sequential-rbac/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,22 @@ provider "aws" {
}

module "airflow" {
source = "datarootsio/ecs-airflow/aws"
source = "datarootsio/ecs-airflow/aws"

resource_prefix = "my-awesome-company"
resource_suffix = "env"
resource_prefix = "my-awesome-company"
resource_suffix = "env"

vpc_id = "vpc-123456"
public_subnet_ids = ["subnet-456789", "subnet-098765"]
vpc_id = "vpc-123456"
public_subnet_ids = ["subnet-456789", "subnet-098765"]

airflow_executor = "Sequential"
airflow_py_requirements_path = "./requirements.txt"
airflow_authentication = "rbac"
airflow_variables = {
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
}
airflow_executor = "Sequential"
airflow_py_requirements_path = "./requirements.txt"
airflow_authentication = "rbac"
airflow_variables = {
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
}

use_https = false
use_https = false
}

output "airflow_alb_dns" {
Expand Down
20 changes: 10 additions & 10 deletions examples/basic-sequential/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ provider "aws" {
}

module "airflow" {
source = "datarootsio/ecs-airflow/aws"
source = "datarootsio/ecs-airflow/aws"

resource_prefix = "my-awesome-company"
resource_suffix = "env"
resource_prefix = "my-awesome-company"
resource_suffix = "env"

vpc_id = "vpc-123456"
public_subnet_ids = ["subnet-456789", "subnet-098765"]
vpc_id = "vpc-123456"
public_subnet_ids = ["subnet-456789", "subnet-098765"]

airflow_executor = "Sequential"
airflow_variables = {
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
}
airflow_executor = "Sequential"
airflow_variables = {
AIRFLOW__WEBSERVER__NAVBAR_COLOR : "#e27d60"
}

use_https = false
use_https = false
}

output "airflow_alb_dns" {
Expand Down
39 changes: 20 additions & 19 deletions rds.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,23 @@
resource "aws_db_instance" "airflow" {
count = var.postgres_uri != "" || var.airflow_executor == "Sequential" ? 0 : 1
name = replace(title(local.rds_name), "-", "")
allocated_storage = 20
storage_type = "standard"
engine = "postgres"
engine_version = "11.8"
instance_class = var.rds_instance_class
username = var.rds_username
password = var.rds_password
multi_az = false
availability_zone = var.rds_availability_zone
publicly_accessible = false
deletion_protection = var.rds_deletion_protection
skip_final_snapshot = var.rds_skip_final_snapshot
final_snapshot_identifier = "${var.resource_prefix}-airflow-${var.resource_suffix}-${local.timestamp_sanitized}"
identifier = local.rds_name
vpc_security_group_ids = [aws_security_group.airflow.id]
db_subnet_group_name = aws_db_subnet_group.airflow[0].name
count = var.postgres_uri != "" || var.airflow_executor == "Sequential" ? 0 : 1
name = replace(title(local.rds_name), "-", "")
allocated_storage = var.rds_allocated_storage
storage_type = var.rds_storage_type
engine = var.rds_engine
engine_version = var.rds_version
auto_minor_version_upgrade = false
instance_class = var.rds_instance_class
username = var.rds_username
password = var.rds_password
multi_az = false
availability_zone = var.rds_availability_zone
publicly_accessible = false
deletion_protection = var.rds_deletion_protection
skip_final_snapshot = var.rds_skip_final_snapshot
final_snapshot_identifier = "${var.resource_prefix}-airflow-${var.resource_suffix}-${local.timestamp_sanitized}"
identifier = local.rds_name
vpc_security_group_ids = [aws_security_group.airflow.id]
db_subnet_group_name = aws_db_subnet_group.airflow[0].name

tags = local.common_tags
}
Expand All @@ -27,4 +28,4 @@ resource "aws_db_subnet_group" "airflow" {
subnet_ids = local.rds_ecs_subnet_ids

tags = local.common_tags
}
}
29 changes: 28 additions & 1 deletion variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,28 @@ variable "postgres_uri" {
default = ""
}

// TODO: Add more rds params
variable "rds_allocated_storage" {
type = number
description = "The allocated storage for the rds db in gibibytes"
default = 20
}

variable "rds_storage_type" {
type = string
description = <<EOT
One of `"standard"` (magnetic), `"gp2"` (general purpose SSD), or `"io1"` (provisioned IOPS SSD)
EOT
default = "standard"
}

variable "rds_engine" {
type = string
description = <<EOT
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)
EOT
default = "postgres"
}

variable "rds_username" {
type = string
description = "Username of rds"
Expand Down Expand Up @@ -243,6 +264,12 @@ variable "rds_deletion_protection" {
default = false
}

variable "rds_version" {
type = string
description = "The DB version to use for the RDS instance"
default = "12.7"
}

// S3 Bucket
variable "s3_bucket_name" {
type = string
Expand Down

0 comments on commit 43d63ff

Please sign in to comment.