@@ -39,39 +39,39 @@ resource "aws_iam_role" "cwl_subscription_role" {
3939 )
4040}
4141
42- # IAM policy to allow PutSubscriptionFilter on the existing API Gateway log group and CSOC destination
43- data "aws_iam_policy_document" "put_subscription_filter" {
42+ # IAM policy to allow CloudWatch Logs to write to the CSOC destination
43+ # This is the permission policy for the role that CloudWatch Logs assumes
44+ data "aws_iam_policy_document" "cwl_to_csoc_destination" {
4445 statement {
45- sid = " AllowPutAPIGSubFilter "
46+ sid = " AllowPutLogEventsToDestination "
4647 effect = " Allow"
4748 actions = [
48- " logs:PutSubscriptionFilter "
49+ " logs:PutLogEvents "
4950 ]
5051 resources = [
51- " ${ module . eligibility_signposting_api_gateway . cloudwatch_destination_arn } :*" ,
5252 " arn:aws:logs:${ var . default_aws_region } :693466633220:destination:api_gateway_log_destination"
5353 ]
5454 }
5555}
5656
57- resource "aws_iam_policy" "put_subscription_filter " {
58- name = " ${ var . environment } -${ local . workspace } -PutSubscriptionFilterPolicy "
59- description = " Policy to allow creating subscription filters for CSOC log forwarding "
60- policy = data. aws_iam_policy_document . put_subscription_filter . json
57+ resource "aws_iam_policy" "cwl_to_csoc_destination " {
58+ name = " ${ var . environment } -${ local . workspace } -CWLogsToCSOCDestinationPolicy "
59+ description = " Policy to allow CloudWatch Logs to write to CSOC destination "
60+ policy = data. aws_iam_policy_document . cwl_to_csoc_destination . json
6161
6262 tags = merge (
6363 local. tags ,
6464 {
65- Name = " ${ var . environment } -${ local . workspace } -PutSubscriptionFilterPolicy "
65+ Name = " ${ var . environment } -${ local . workspace } -CWLogsToCSOCDestinationPolicy "
6666 Purpose = " CSOC log forwarding"
6767 }
6868 )
6969}
7070
7171# Attach the policy to the subscription role
72- resource "aws_iam_role_policy_attachment" "put_subscription_filter " {
72+ resource "aws_iam_role_policy_attachment" "cwl_to_csoc_destination " {
7373 role = aws_iam_role. cwl_subscription_role . name
74- policy_arn = aws_iam_policy. put_subscription_filter . arn
74+ policy_arn = aws_iam_policy. cwl_to_csoc_destination . arn
7575}
7676
7777# Create the subscription filter to forward logs to CSOC
@@ -87,6 +87,6 @@ resource "aws_cloudwatch_log_subscription_filter" "csoc_forwarding" {
8787 depends_on = [
8888 module . eligibility_signposting_api_gateway ,
8989 aws_iam_role . cwl_subscription_role ,
90- aws_iam_role_policy_attachment . put_subscription_filter
90+ aws_iam_role_policy_attachment . cwl_to_csoc_destination
9191 ]
9292}
0 commit comments