File tree Expand file tree Collapse file tree 4 files changed +41
-8
lines changed
Expand file tree Collapse file tree 4 files changed +41
-8
lines changed Original file line number Diff line number Diff line change 1+ output "aws_hashing_secret_arn" {
2+ value = aws_secretsmanager_secret. hashing_secret . arn
3+ }
Original file line number Diff line number Diff line change 11variable "external_write_access_role_arn" {
2- description = " Arn of the external write access role to provide secret manager access "
3- type = string
2+ description = " List of ARNs for external write access roles "
3+ type = list ( string )
44}
55
66variable "eligibility_lambda_role_arn" {
Original file line number Diff line number Diff line change @@ -530,3 +530,34 @@ resource "aws_iam_role_policy" "external_audit_kms_access_policy" {
530530 role = aws_iam_role. write_access_role [count . index ]. id
531531 policy = data. aws_iam_policy_document . external_role_s3_audit_kms_access_policy . json
532532}
533+
534+ # IAM policy document for Lambda secret access
535+ data "aws_iam_policy_document" "secrets_access_policy" {
536+ statement {
537+ effect = " Allow"
538+
539+ actions = [
540+ " secretsmanager:GetSecretValue" ,
541+ " secretsmanager:DescribeSecret" ,
542+ ]
543+
544+ resources = [
545+ module . secrets_manager . aws_hashing_secret_arn
546+ ]
547+ }
548+ }
549+
550+ # Attach secret read policy to Lambda role
551+ resource "aws_iam_role_policy" "lambda_secret_read_policy_attachment" {
552+ name = " LambdaSecretReadAccess"
553+ role = aws_iam_role. eligibility_lambda_role . id
554+ policy = data. aws_iam_policy_document . secrets_access_policy . json
555+ }
556+
557+ # Attach secret read policy to external write role
558+ resource "aws_iam_role_policy" "external_secret_read_policy_attachment" {
559+ count = length (aws_iam_role. write_access_role )
560+ name = " ExternalSecretReadAccess"
561+ role = aws_iam_role. write_access_role [count . index ]. id
562+ policy = data. aws_iam_policy_document . secrets_access_policy . json
563+ }
Original file line number Diff line number Diff line change 11module "secrets_manager" {
22 source = " ../../modules/secrets_manager"
3- count = length (aws_iam_role. write_access_role )
4- external_write_access_role_arn = aws_iam_role. write_access_role [count . index ]. arn
5- environment = var. environment
6- stack_name = local. stack_name
7- workspace = terraform. workspace
8- eligibility_lambda_role_arn = aws_iam_role. eligibility_lambda_role . arn
3+ external_write_access_role_arn = aws_iam_role. write_access_role [* ]. arn
4+ environment = var. environment
5+ stack_name = local. stack_name
6+ workspace = terraform. workspace
7+ eligibility_lambda_role_arn = aws_iam_role. eligibility_lambda_role . arn
98}
You can’t perform that action at this time.
0 commit comments