-
-
-
Create the below IAM policy "allow-sts-to-aws-iam-user-reaper-role" and attach it to the lambda role "aws-reaper-lambda"
{ "Version": "2012-10-17", "Statement": { "Effect": "Allow", "Action": "sts:AssumeRole", "Resource": [ "arn:aws:iam::12345:role/aws-iam-user-reaper-role", "arn:aws:iam::67890:role/aws-iam-user-reaper-role" ] } }
-
(py36) ➜ / aws lambda get-function-configuration --function-name aws-iam-user-reaper { "FunctionName": "aws-iam-user-reaper", "FunctionArn": "arn:aws:lambda:us-east-1:<account_id>:function:aws-iam-user-reaper", "Runtime": "python3.6", "Role": "arn:aws:iam::<account_id>:role/aws-reaper-lambda", "Handler": "aws_ad_accounts_sync.main", "CodeSize": 1900791, "Description": "", "Timeout": 120, "MemorySize": 512, "LastModified": "2018-11-16T02:34:47.612+0000", "CodeSha256": "123", "Version": "$LATEST", "VpcConfig": { "SubnetIds": [ "subnet-123", "subnet-123", "subnet-123", "subnet-123" ], "SecurityGroupIds": [ "sg-123" ], "VpcId": "vpc-123" }, "TracingConfig": { "Mode": "PassThrough" }, "RevisionId": "899563" }
-
-
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Stmt1484183937316", "Action": [ "iam:DeleteUser", "iam:DeleteUserPolicy", "iam:DetachUserPolicy", "iam:GetUser", "iam:GetUserPolicy", "iam:List*", "iam:DeleteAccessKey", "iam:DeleteSigningCertificate", "iam:UpdateAccessKey", "iam:UpdateSigningCertificate", "iam:DeleteLoginProfile", "iam:RemoveUserFromGroup", "iam:DeleteSSHPublicKey", "iam:Get*", "iam:DeactivateMFADevice" ], "Effect": "Allow", "Resource": "*" } ] }
-
Create this IAM Lambda role: "aws-iam-user-reaper-role". Attach the below trust policy. Note you need to replace the account number with your account number where your lambda function lives.
{ "Version": "2012-10-17", "Statement": [ { "Sid": "", "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::123456:role/aws-reaper-lambda" }, "Action": "sts:AssumeRole" } ] }
-
-
Apache 2.0