Skip to content

Commit

Permalink
feat: Add support for AWS Secrets Manager (#151)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtruong authored Nov 13, 2023
1 parent 837f127 commit aa64eb1
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 1 deletion.
4 changes: 4 additions & 0 deletions examples/public-dns-external/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ module "wandb_app" {
# If we dont wait, tf will start trying to deploy while the work group is
# still spinning up
depends_on = [module.wandb_infra]

other_wandb_env = merge({
"GORILLA_CUSTOMER_SECRET_STORE_SOURCE" = "aws-secretmanager://${var.namespace}?namespace=${var.namespace}"
}, var.other_wandb_env)
}

output "bucket_name" {
Expand Down
6 changes: 6 additions & 0 deletions examples/public-dns-external/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,9 @@ variable "allowed_inbound_ipv6_cidr" {
nullable = false
type = list(string)
}

variable "other_wandb_env" {
type = map(string)
description = "Extra environment variables for W&B"
default = {}
}
7 changes: 6 additions & 1 deletion modules/app_eks/iam-policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ resource "aws_iam_policy" "node_s3" {
lifecycle {
create_before_destroy = false
}
}
}

resource "aws_iam_policy" "secrets_manager" {
name = "${var.namespace}-secrets-manager"
policy = data.aws_iam_policy_document.secrets_manager.json
}
15 changes: 15 additions & 0 deletions modules/app_eks/iam-policy-docs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,18 @@ data "aws_iam_policy_document" "node_s3" {
]
}
}

data "aws_iam_policy_document" "secrets_manager" {
statement {
actions = [
"secretsmanager:CreateSecret",
"secretsmanager:UpdateSecret",
"secretsmanager:DeleteSecret",
"secretsmanager:PutSecretValue",
"secretsmanager:GetSecretValue",
"secretsmanager:DeleteSecretVersion"
]
effect = "Allow"
resources = ["arn:aws:secretsmanager:*:${data.aws_caller_identity.current.account_id}:secret:${var.namespace}*"]
}
}
5 changes: 5 additions & 0 deletions modules/app_eks/iam-role-attachments.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,8 @@ resource "aws_iam_role_policy_attachment" "ebs_csi" {
role = aws_iam_role.node.name
policy_arn = "arn:aws:iam::aws:policy/service-role/AmazonEBSCSIDriverPolicy"
}

resource "aws_iam_role_policy_attachment" "node_secrets_manager" {
role = aws_iam_role.node.name
policy_arn = aws_iam_policy.secrets_manager.arn
}
1 change: 1 addition & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,4 @@ variable "elasticache_node_type" {
# type = string
# description = "Weights & Biases license key."
# }

0 comments on commit aa64eb1

Please sign in to comment.