@@ -70,3 +70,46 @@ resource "aws_iam_role_policy_attachment" "s3_policy_attachment" {
7070 role = split (" /" , module. batch_eventbridge . batch_job_role_arn )[1 ]
7171 policy_arn = aws_iam_policy. s3_access . arn
7272}
73+
74+ # IAM User Group
75+ resource "aws_iam_group" "group" {
76+ name = " ${ var . domain } -${ var . service_subdomain } -user-group"
77+ path = " /"
78+ }
79+
80+ # Attach S3 policy to group
81+ resource "aws_iam_group_policy_attachment" "group_s3_access_attachment" {
82+ group = aws_iam_group. group . name
83+ policy_arn = aws_iam_policy. s3_access . arn
84+ }
85+
86+ # Attach Secrets Manager policy to group
87+ resource "aws_iam_group_policy_attachment" "group_secrets_attachment" {
88+ group = aws_iam_group. group . name
89+ policy_arn = aws_iam_policy. secrets_access . arn
90+ }
91+
92+ # IAM User
93+ resource "aws_iam_user" "user" {
94+ name = " ${ var . domain } -${ var . service_subdomain } "
95+ path = " /"
96+ }
97+
98+ # Assign IAM User to group
99+ resource "aws_iam_user_group_membership" "user_group_attach" {
100+ user = aws_iam_user. user . name
101+
102+ groups = [
103+ aws_iam_group . group . name
104+ ]
105+ }
106+
107+ # IAM Key Rotation Module
108+ module "iam_key_rotation" {
109+ source = " git::https://github.com/ONS-Innovation/keh-aws-iam-key-rotation.git?ref=v0.1.0"
110+
111+ iam_username = aws_iam_user. user . name
112+ access_key_secret_arn = aws_secretsmanager_secret. access_key . arn
113+ secret_key_secret_arn = aws_secretsmanager_secret. secret_key . arn
114+ rotation_in_days = 90
115+ }
0 commit comments