HI Team,
I am trying to associate the HTTP-API to WAFV2 by using below sample code but getting below error:
Error: WAFInvalidParameterException: Error reason: The ARN isn't valid. A valid ARN begins with arn: and includes other information separated by colons or slashes., field: RESOURCE_ARN,
Below is the sample test code using for test:
resource “aws_wafv2_web_acl” “waf_acl” {
name = “Test-Api-Gateway”
scope = “REGIONAL”default_action {
allow {}
}rule {
name = “Test-Rule”
priority = 10action { block {} } statement { not_statement { statement { geo_match_statement { country_codes = ["UK","IN"] } } } } visibility_config { cloudwatch_metrics_enabled = false metric_name = "TestRule" sampled_requests_enabled = false }}
tags = module.tags.default_tags
visibility_config {
cloudwatch_metrics_enabled = false
metric_name = “TestApiGateway”
sampled_requests_enabled = false
}
}
resource “aws_apigatewayv2_api” “example_api” {
name = “example_api”
protocol_type = “HTTP”
}
resource “aws_apigatewayv2_stage” “example_stage” {
api_id = aws_apigatewayv2_api.example_api.id
name = “example_stage”
}
resource “aws_wafv2_web_acl_association” “association” {
resource_arn = aws_apigatewayv2_stage.example_stage.arn
web_acl_arn = aws_wafv2_web_acl.waf_acl.arn
}
//tried the resource_arn other way like (resource_arn = “${aws_apigatewayv2_stage.example_stage.arn}” ) but no use, Still getting the same error.
So, please suggest how to fix this error.
Thanks in Advance.