Skip to content
Open
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
76 changes: 76 additions & 0 deletions sm2a/infrastructure/iam.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
locals {

base_policies = [
{
Effect = "Allow"
Action = [
"sts:AssumeRole",
"iam:PassRole",
"logs:GetLogEvents"
]
Resource = ["*"]
},
{
Effect = "Allow"
Action = ["glue:DeleteDatabase"]
Resource = [
"arn:aws:glue:us-west-2:*:catalog",
"arn:aws:glue:us-west-2:*:database/*",
"arn:aws:glue:us-west-2:*:table/*",
"arn:aws:glue:us-west-2:*:userDefinedFunction/*"
]
},
]

# Disaster Recovery
disaster_recovery_policy = [
{
Effect = "Allow"
Action = [
"rds:Describe*",
"rds:Start*", "kms:*",
"glue:Get*",
"glue:CreateCrawler",
"glue:StartCrawler",
"glue:UpdateCrawler"
]
Resource = ["*"]
}
]

#Cloudfront Invalidation
cloudfront_invalidation_policy = [
{
Effect = "Allow"
Action = ["cloudfront:CreateInvalidation"]
Resource = ["arn:aws:cloudfront::*:distribution/*"]
}
]

# Conditional Secrets Manager arn for ingest api keycloak client secret in different aws account
secrets_manager_policy = var.ingest_api_keycloak_client_secret_arn != null ? [
{
Effect = "Allow"
Action = ["secretsmanager:GetSecretValue"]
Resource = [var.ingest_api_keycloak_client_secret_arn]
}
] : []

# Conditional KMS policy statement
kms_policy = var.kms_key_arn != null ? [
{
Effect = "Allow"
Action = ["kms:Decrypt"]
Resource = [var.kms_key_arn]
}
] : []

# Final list of all worker policy statements
custom_worker_policy_statement = concat(
local.base_policies,
local.disaster_recovery_policy,
local.cloudfront_invalidation_policy,
local.secrets_manager_policy,
local.kms_policy
)
}
4 changes: 2 additions & 2 deletions sm2a/infrastructure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ terraform {
provider "aws" {
region = var.aws_region
}

resource "random_password" "password" {
length = 8
special = true
Expand All @@ -24,7 +25,6 @@ module "rds_backups" {
snapshot_bucket_name = var.snapshot_bucket_name
}


module "sma-base" {
source = "https://github.com/NASA-IMPACT/self-managed-apache-airflow/releases/download/v1.1.7/self-managed-apache-airflow.zip"
project = var.project_name
Expand All @@ -40,7 +40,7 @@ module "sma-base" {
airflow_admin_username = "admin"
rds_publicly_accessible = var.rds_publicly_accessible
permission_boundaries_arn = var.permission_boundaries_arn
custom_worker_policy_statement = var.custom_worker_policy_statement
custom_worker_policy_statement = local.custom_worker_policy_statement
worker_cpu = tonumber(var.workers_cpu)
worker_memory = tonumber(var.workers_memory)
number_of_schedulers = var.number_of_schedulers
Expand Down
69 changes: 12 additions & 57 deletions sm2a/infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -79,63 +79,6 @@ variable "gh_team_name" {

}

variable "custom_worker_policy_statement" {
type = list(object({
Effect = string
Action = list(string)
Resource = list(string)
}))
default = [
{
Effect = "Allow"
Action = [
"sts:AssumeRole",
"iam:PassRole",
"logs:GetLogEvents"
]
"Resource" : [
"*"
]

},
{
Sid = "VEDA-RDS-Disaster-Recovery"
Effect = "Allow"
Action = [
"rds:Describe*",
"rds:Start*",
"kms:*",
"glue:Get*",
"glue:CreateCrawler",
"glue:StartCrawler",
"glue:UpdateCrawler"
]
Resource = [
"*"
]
},
{
"Effect" : "Allow",
"Action" : [
"glue:DeleteDatabase"
],
"Resource" : [
"arn:aws:glue:us-west-2:*:catalog",
"arn:aws:glue:us-west-2:*:database/*",
"arn:aws:glue:us-west-2:*:table/*",
"arn:aws:glue:us-west-2:*:userDefinedFunction/*"
]
},
{
"Effect": "Allow",
"Action": ["cloudfront:CreateInvalidation"],
"Resource": ["arn:aws:cloudfront::*:distribution/*"]
}

]

}

variable "project_name" {
type = string
default = "SM2A"
Expand Down Expand Up @@ -247,3 +190,15 @@ variable "lambda_dag_trigger_function_name" {
variable ingest_api_keycloak_client_secret {
type = string
}

variable "ingest_api_keycloak_client_secret_arn" {
type = string
description = "Secrets Manager arn for ingest api keycloak client secret in different aws account"
default = null
}

variable "kms_key_arn" {
type = string
description = "The ARN of the KMS key in different aws account"
default = null
}