Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Added SES SMTP user for Airflow #163

Merged
merged 1 commit into from
Sep 11, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions infra/terraform/modules/ses_smtp_user/inputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
variable "ses_domain_identity_arn" {}

variable "username" {}
28 changes: 28 additions & 0 deletions infra/terraform/modules/ses_smtp_user/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
resource "aws_iam_user" "smtp_user" {
name = "${var.username}"
}

resource "aws_iam_access_key" "access_key" {
user = "${aws_iam_user.smtp_user.name}"
}

resource "aws_iam_user_policy" "smtp_user_policy" {
name = "${aws_iam_user.smtp_user.name}_policy"
user = "${aws_iam_user.smtp_user.name}"

policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": [
"ses:SendRawEmail",
"ses:SendEmail"
],
"Effect": "Allow",
"Resource": "${var.ses_domain_identity_arn}"
}
]
}
EOF
}
3 changes: 3 additions & 0 deletions infra/terraform/modules/ses_smtp_user/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "password" {
value = "${aws_iam_access_key.access_key.ses_smtp_password}"
}
8 changes: 8 additions & 0 deletions infra/terraform/platform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,14 @@ module "airflow_db" {
subnet_ids = "${module.aws_vpc.storage_subnet_ids}"
}

module "airflow_smtp_user" {
source = "../modules/ses_smtp_user"

ses_domain_identity_arn = "${data.terraform_remote_state.base.xyz_root_domain_ses_identity_arn}"

username = "${terraform.workspace}_airflow_smtp_user"
}

module "cert_manager" {
source = "../modules/ec2_cert_manager_role"
role_name = "${terraform.workspace}-cert-manager"
Expand Down
4 changes: 4 additions & 0 deletions infra/terraform/platform/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ output "airflow_efs_host" {
value = "${module.airflow_storage_efs_volume.dns_name}"
}

output "airflow_smtp_password" {
value = "${module.airflow_smtp_user.password}"
}

output "control_panel_api_db_host" {
value = "${module.control_panel_api.db_host}"
}
Expand Down