Skip to content

Commit

Permalink
Require individual policies for each MIS database type
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-buchan committed Dec 20, 2024
1 parent 53ea13d commit 6baa021
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ resource "aws_backup_vault" "oracle_backup_vault" {
# The AWSBackupDefaultServiceRole managed by AWS and is documented at:
# https://docs.aws.amazon.com/aws-backup/latest/devguide/iam-service-roles.html
resource "aws_iam_policy" "oracle_ec2_snapshot_backup_role_policy" {
name = "oracle-ec2-snapshot-backup-role-policy"
name = "${var.env_name}-${var.db_suffix}-oracle-ec2-snapshot-backup-role-policy"
description = "Allow iam:PassRole for AWSBackupDefaultServiceRole"

policy = jsonencode({
Expand All @@ -41,7 +41,7 @@ resource "aws_iam_policy" "oracle_ec2_snapshot_backup_role_policy" {

# Allow Access To AWSBackupDefaultServiceRolePolicy From EC2 Instance Roles
resource "aws_iam_policy_attachment" "oracle_ec2_snapshot_backup_role_policy_attachment" {
name = "oracle-ec2-snapshot-backup-role-policy-attachment"
name = "${var.env_name}-${var.db_suffix}-oracle-ec2-snapshot-backup-role-policy-attachment"
roles = var.instance_roles
policy_arn = aws_iam_policy.oracle_ec2_snapshot_backup_role_policy.arn
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ module "oracle_db_shared" {
tags = local.tags
public_keys = local.db_public_key_data.keys[var.account_info.mp_environment]
instance_roles = concat(
each.key == "mis-db" ? [for i in range(1,try(var.mis_db_config.instance_count, 1) + 1): "arn:aws:iam::${var.account_info.id}:role/instance-role-delius-mis-${var.env_name}-mis-db-${i}"] : [],
each.key == "boe-db" ? [for i in range(1,try(var.boe_db_config.instance_count, 1) + 1): "arn:aws:iam::${var.account_info.id}:role/instance-role-delius-mis-${var.env_name}-boe-db-${i}"] : [],
each.key == "dsd-db" ? [for i in range(1,try(var.dsd_db_config.instance_count, 1) + 1): "arn:aws:iam::${var.account_info.id}:role/instance-role-delius-mis-${var.env_name}-mis-db-${i}"] : []
each.key == "mis-db" ? [for i in range(1,try(var.mis_db_config.instance_count, 1) + 1): "arn:aws:iam::${var.account_info.id}:role/instance-role-delius-mis-${var.env_name}-${each.key}-${i}"] : [],
each.key == "boe-db" ? [for i in range(1,try(var.boe_db_config.instance_count, 1) + 1): "arn:aws:iam::${var.account_info.id}:role/instance-role-delius-mis-${var.env_name}-${each.key}-${i}"] : [],
each.key == "dsd-db" ? [for i in range(1,try(var.dsd_db_config.instance_count, 1) + 1): "arn:aws:iam::${var.account_info.id}:role/instance-role-delius-mis-${var.env_name}-${each.key}-${i}"] : []
)

db_suffix = each.key
Expand Down

0 comments on commit 6baa021

Please sign in to comment.