Skip to content

Commit

Permalink
add support for a non default secretsmanager key
Browse files Browse the repository at this point in the history
  • Loading branch information
lobeck committed May 7, 2019
1 parent 2a4d7ee commit 456c8d0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
6 changes: 6 additions & 0 deletions policies.tf
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,22 @@ data "aws_iam_policy_document" "task_execution_permissions" {
}
}

data "aws_kms_key" "secretsmanager_key" {
key_id = "${var.repository_credentials_kms_key}"
}

data "aws_iam_policy_document" "read_repository_credentials" {
statement {
effect = "Allow"

resources = [
"${var.repository_credentials}",
"${data.aws_kms_key.secretsmanager_key.arn}",
]

actions = [
"secretsmanager:GetSecretValue",
"kms:Decrypt",
]
}
}
5 changes: 5 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@ variable "repository_credentials" {
description = "name or ARN of a secrets manager secret (arn:aws:secretsmanager:region:aws_account_id:secret:secret_name)"
}

variable "repository_credentials_kms_key" {
default = "alias/aws/secretsmanager"
description = "key id, key ARN, alias name or alias ARN of the key that encrypted the repository credentials"
}

locals {
# if the variable is set, create the fragment based on the variable value
# if not, just return a empty string to not mess up the json
Expand Down

0 comments on commit 456c8d0

Please sign in to comment.