-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MLPAB-2237 Allow KMS key and secret to be used across accouts (#243)
- Loading branch information
1 parent
daa60de
commit 22da890
Showing
7 changed files
with
77 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,38 @@ | ||
resource "aws_secretsmanager_secret" "jwt_key" { | ||
name = "${data.aws_default_tags.default.tags.application}/${data.aws_default_tags.default.tags.account}/jwt-key" | ||
description = "JWT key for ${data.aws_default_tags.default.tags.application} in ${data.aws_default_tags.default.tags.account}, for use with Make and Register, and Use a LPA" | ||
# policy = data.aws_iam_policy_document.jwt_key_cross_account_access.json | ||
# kms_key_id = module.jwt_kms.eu_west_1_target_key_id | ||
policy = data.aws_iam_policy_document.jwt_key_cross_account_access.json | ||
kms_key_id = module.jwt_kms.eu_west_1_target_key_id | ||
replica { | ||
region = data.aws_region.eu_west_2.name | ||
# kms_key_id = module.jwt_kms.eu_west_2_target_key_id | ||
region = data.aws_region.eu_west_2.name | ||
kms_key_id = module.jwt_kms.eu_west_2_target_key_id | ||
} | ||
provider = aws.management_eu_west_1 | ||
} | ||
|
||
data "aws_iam_policy_document" "jwt_key_cross_account_access" { | ||
statement { | ||
effect = "Allow" | ||
actions = [ | ||
"secretsmanager:GetSecretValue", | ||
] | ||
resources = [ | ||
"*" | ||
] | ||
actions = [ | ||
"secretsmanager:GetSecretValue", | ||
] | ||
|
||
principals { | ||
type = "AWS" | ||
identifiers = tolist(local.account.jwt_key_cross_account_access_roles) | ||
identifiers = concat(local.account.jwt_key_cross_account_access, ["arn:aws:iam::${data.aws_caller_identity.current.account_id}:root"]) | ||
} | ||
condition { | ||
test = "ArnLike" | ||
variable = "aws:PrincipalArn" | ||
values = concat( | ||
local.account.jwt_key_cross_account_access_roles, | ||
[ | ||
"arn:aws:iam::${data.aws_caller_identity.current.account_id}:role/lpa-store-lambda/*" | ||
]) | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters