Creating an IAM Role for the Lambda function
You need to create and configure a CloudWatch Events rule to get AWS Security Hub events and forward the events to the CloudWatch Logs. To do that you need to create an IAM role for the Lambada function.
- Go to your IAM console (https://console.aws.amazon.com/iam/).
- Select Roles from the navigation pane.
- If you have an existing role or roles, select the role
name that you want to associate with the Lambda function and complete
the following steps:
Expand the Policy name and then click Edit policy
Click the JSON tab and then verify that the JSON entry matches the following JSON entry:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "logs:DescribeLogGroups","logs:DescribeLogStreams", "logs:PutLogEvents" ], "Resource": "arn:aws:logs:*:*:*" }]}
- If you don't have an existing role, click Create role.
- From the list of service or services that use the role, select Lambda.
- Click Next: Permissions, and then select an appropriate policy.
- Click Next: Review, and then type a role name in the Role name field. If you want, you can type a description in the Role description field.
- Click Create role, and then select the new rule that you created.
- If you want to add an existing policy, complete the following
steps:
Click Attach policies.
Expand the Policy name and then click Edit policy
Click the JSON tab and then verify that the JSON entry matches the following JSON entry:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:PutLogEvents" ], "Resource": "arn:aws:logs:*:*:*" }]}
- Click Attach policy.
- If you want to add a new policy, complete the following
steps:
Click Add inline policy.
Click the JSON tab, and then copy and paste the following JSON entry:
{ "Version": "2012-10-17", "Statement": [ { "Sid": "VisualEditor0", "Effect": "Allow", "Action": [ "logs:DescribeLogGroups", "logs:DescribeLogStreams", "logs:PutLogEvents" ], "Resource": "arn:aws:logs:*:*:*" }]}
- Click Review Policy, and then type a name for the policy.
- Click Create policy.
- Verify that the role has the trust relationship. Click the Trust relationships tab.
- Click Edit trust relationship and verify the
following trust relationship:
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "lambda.amazonaws.com" }, "Action": "sts:AssumeRole" }