Skip to content

Can't Associate WebACL to API Gateway WebSocket by any way

0

Hello, The main issue is that in the WAF console, I do not see any ressources to be associated with my ACL rule. Screenshot

Before that, I wanted to do it with cloud formation but it complains about the arn of the websocket. I also tried with CLI and same issue, it complains about the websocket arn. I tried different arn format and I think this one should be the correct one:

Properties: ResourceArn: !Sub "arn:aws:apigateway:${AWS::Region}::/apis/${WebSocketApiId}/stages/${Environment}" WebACLArn: !GetAtt MyWebACL.Arn

Do you know how I am supposed to do?

1 Answer
0
Accepted Answer

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

EXPERT

reviewed 2 years ago

EXPERT

reviewed 2 years ago

  • Thank you very much, very detailed and clear.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.