Skip to content

Commit 8318250

Browse files
author
Fabio Ramos
authored
Merge pull request #5 from DNXLabs/org_name
Adding new VARs to module and S3 bucket new resources
2 parents dfaf937 + c1a1417 commit 8318250

File tree

6 files changed

+27
-5
lines changed

6 files changed

+27
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
| logging\_configuration | The Apache Airflow logs you want to send to Amazon CloudWatch Logs. | `any` | n/a | yes |
3232
| max\_workers | The maximum number of workers that can be automatically scaled up. Value need to be between 1 and 25. Will be 10 by default. | `number` | `10` | no |
3333
| min\_workers | The minimum number of workers that you want to run in your environment. Will be 1 by default. | `number` | `1` | no |
34+
| org\_name | Name of the Organisation | `any` | n/a | yes |
3435
| plugins\_s3\_path | The relative path to the plugins.zip file on your Amazon S3 storage bucket. For example, plugins.zip. | `string` | `"plugins.zip"` | no |
3536
| private\_subnet\_ids | The private subnet IDs in which the environment should be created. MWAA requires two subnets. | `list(string)` | n/a | yes |
3637
| requirements\_s3\_path | The relative path to the requirements.txt file on your Amazon S3 storage bucket. For example, requirements.txt. | `string` | `"requirements.txt"` | no |

_variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ variable "environment_name" {
22
description = "Name of MWAA Environment"
33
}
44

5+
variable "org_name" {
6+
description = "Name of the Organisation"
7+
}
8+
59
variable "airflow_version" {
610
description = "Airflow version of the MWAA environment"
711
}

mwaa-environment.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ resource "aws_mwaa_environment" "mwaa" {
2626
# Airflow webserver timeout
2727
"webserver.web_server_master_timeout" = var.airflow_configuration_options["webserver_timeout"]["master"]
2828
"webserver.web_server_worker_timeout" = var.airflow_configuration_options["webserver_timeout"]["worker"]
29+
30+
# Replace fixed values
31+
"secrets.backend" = var.airflow_configuration_options["secrets.backend"]
32+
"secrets.backend_kwargs" = var.airflow_configuration_options["secrets.backend_kwargs"]
2933
}
3034

3135
logging_configuration {

mwaa-iam.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ data "aws_iam_policy_document" "mwaa_assume_role" {
3333
}
3434

3535
resource "aws_iam_role" "mwaa_role" {
36-
name = "mwaa-executor-${var.environment_name}"
36+
name = "mwaa-executor-${var.environment_name}-${data.aws_region.current.name}"
3737
assume_role_policy = data.aws_iam_policy_document.mwaa_assume_role.json
3838
}
3939

4040
resource "aws_iam_role_policy" "mwaa_policy" {
41-
name = "mwaa-executor-policy-${var.environment_name}"
41+
name = "mwaa-executor-policy-${var.environment_name}-${data.aws_region.current.name}"
4242
role = aws_iam_role.mwaa_role.id
4343
policy = data.aws_iam_policy_document.mwaa_policy.json
4444
}

mwaa-s3.tf

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,18 @@
22
# - S3 bucket needs to start with prefix "airflow"
33
# - Mandatory to set Block Public Access
44
resource "aws_s3_bucket" "mwaa_content" {
5-
bucket = "mwaa-${var.environment_name}-${data.aws_region.current.name}"
5+
bucket = "mwaa-${var.org_name}-${var.environment_name}-${data.aws_region.current.name}"
6+
}
7+
8+
resource "aws_s3_bucket_acl" "mwaa_content" {
9+
bucket = aws_s3_bucket.mwaa_content.id
610
acl = "private"
11+
}
712

8-
versioning {
9-
enabled = true
13+
resource "aws_s3_bucket_versioning" "mwaa_content" {
14+
bucket = aws_s3_bucket.mwaa_content.id
15+
versioning_configuration {
16+
status = "Enabled"
1017
}
1118
}
1219

ssm.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
resource "aws_ssm_parameter" "mwaa_env" {
2+
name = "/mwaa/ENV"
3+
description = "MWAA Environment"
4+
value = var.environment_name
5+
type = "String"
6+
}

0 commit comments

Comments
 (0)