This rule ensures that API Gateway stage logging is enabled to maintain high security standards.
Rule | API Gateway stage logging should be enabled |
Framework | NIST 800-53 Revision 5 |
Severity | ✔ High |
Rule Description:
This rule requires enabling logging for the API Gateway stage in order to comply with the NIST 800-53 Revision 5 security framework. Logging can help in monitoring and identifying any unauthorized access attempts or potential security breaches.
Troubleshooting Steps:
Necessary Codes:
This rule does not have direct code implementations. However, the following AWS CLI commands can be used to enable logging for the API Gateway stage:
aws apigateway update-stage \ --rest-api-id <API-ID> \ --stage-name <STAGE-NAME> \ --patch-operations '[{"op":"replace","path":"/accessLogSettings/destinationArn","value":"arn:aws:logs:<REGION>:<ACCOUNT-ID>:log-group:<LOG-GROUP-NAME>"}]'
Replace
<API-ID>
with the actual ID of the API Gateway, <STAGE-NAME>
with the name of the stage (e.g., prod, dev), <REGION>
with the AWS region, <ACCOUNT-ID>
with your AWS account ID, and <LOG-GROUP-NAME>
with the desired log group name.aws apigateway update-stage \ --rest-api-id <API-ID> \ --stage-name <STAGE-NAME> \ --patch-operations '[{"op":"replace","path":"/accessLogSettings/format","value":"json"},{"op":"add","path":"/accessLogSettings/roleArn","value":"arn:aws:iam::<ACCOUNT-ID>:role/<ROLE-NAME>"}]'
Replace
<API-ID>
with the actual ID of the API Gateway, <STAGE-NAME>
with the name of the stage, <ACCOUNT-ID>
with your AWS account ID, and <ROLE-NAME>
with the name of the IAM role.Step-by-Step Guide for Remediation:
Note: It may take a few minutes for the changes to take effect and for logs to appear in the designated CloudWatch Logs group.
By following these steps, you will successfully enable logging for the API Gateway stage, aligning with the NIST 800-53 Revision 5 security requirements.