- Newest
- Most votes
- Most comments
I apologize, but it appears that you are correct in your observation. Currently, AWS WAF does not support direct association with API Gateway WebSocket APIs.
WAF can be associated with REST APIs in API Gateway, but this functionality is not available for WebSocket APIs. The options you see in the WAF console for associating resources are limited to supported resource types, which is why you're not seeing your WebSocket API as an option.
The ARN format you've tried in CloudFormation is correct for a WebSocket API, but since WAF doesn't support WebSocket APIs, any attempts to associate them (whether through the console, CloudFormation, or CLI) will fail.
As an alternative, you might consider implementing security measures at the application level within your WebSocket API's backend logic. This could include validating incoming messages, implementing authentication and authorization mechanisms, and applying rate limiting.
If WAF protection is crucial for your use case, you may need to reconsider your architecture. For example, you could potentially use a REST API as a front-end to your WebSocket API, applying WAF rules to the REST API. However, this would add complexity to your system and may not be suitable for all use cases.
I recommend keeping an eye on AWS announcements for any future support of WAF with WebSocket APIs. In the meantime, focus on implementing robust security practices within your application code and consider alternative architectural approaches if WAF protection is a must-have for your specific requirements.
Sources
Associate WAF ACL with a specific resource paths from API Gateway | AWS re:Post
Use AWS WAF to protect your REST APIs in API Gateway - Amazon API Gateway
Associating a web ACL with an AWS resource - AWS WAF, AWS Firewall Manager, and AWS Shield Advanced
answered 2 years ago
Relevant content
asked 7 years ago
asked 3 years ago
asked 7 years ago

Thank you very much, very detailed and clear.