Difference between revisions of "Terraform resource: aws wafv2 web acl association"
Jump to navigation
Jump to search
Line 1: | Line 1: | ||
* https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/wafv2_web_acl_association | * https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/wafv2_web_acl_association | ||
+ | |||
+ | <pre> | ||
+ | resource "aws_api_gateway_rest_api" "example" { | ||
+ | body = jsonencode({ | ||
+ | openapi = "3.0.1" | ||
+ | info = { | ||
+ | title = "example" | ||
+ | version = "1.0" | ||
+ | } | ||
+ | paths = { | ||
+ | "/path1" = { | ||
+ | get = { | ||
+ | "x-amazon-apigateway-integration" = { | ||
+ | httpMethod = "GET" | ||
+ | payloadFormatVersion = "1.0" | ||
+ | type = "HTTP_PROXY" | ||
+ | uri = "https://ip-ranges.amazonaws.com/ip-ranges.json" | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | }) | ||
+ | |||
+ | name = "example" | ||
+ | } | ||
+ | |||
+ | resource "aws_api_gateway_deployment" "example" { | ||
+ | rest_api_id = aws_api_gateway_rest_api.example.id | ||
+ | |||
+ | triggers = { | ||
+ | redeployment = sha1(jsonencode(aws_api_gateway_rest_api.example.body)) | ||
+ | } | ||
+ | |||
+ | lifecycle { | ||
+ | create_before_destroy = true | ||
+ | } | ||
+ | } | ||
+ | |||
+ | resource "aws_api_gateway_stage" "example" { | ||
+ | deployment_id = aws_api_gateway_deployment.example.id | ||
+ | rest_api_id = aws_api_gateway_rest_api.example.id | ||
+ | stage_name = "example" | ||
+ | } | ||
+ | |||
+ | resource "aws_wafv2_web_acl" "example" { | ||
+ | name = "web-acl-association-example" | ||
+ | scope = "REGIONAL" | ||
+ | |||
+ | default_action { | ||
+ | allow {} | ||
+ | } | ||
+ | |||
+ | visibility_config { | ||
+ | cloudwatch_metrics_enabled = false | ||
+ | metric_name = "friendly-metric-name" | ||
+ | sampled_requests_enabled = false | ||
+ | } | ||
+ | } | ||
+ | |||
+ | resource "aws_wafv2_web_acl_association" "example" { | ||
+ | resource_arn = aws_api_gateway_stage.example.arn | ||
+ | web_acl_arn = aws_wafv2_web_acl.example.arn | ||
+ | } | ||
+ | </pre> | ||
Revision as of 10:22, 20 August 2024
resource "aws_api_gateway_rest_api" "example" { body = jsonencode({ openapi = "3.0.1" info = { title = "example" version = "1.0" } paths = { "/path1" = { get = { "x-amazon-apigateway-integration" = { httpMethod = "GET" payloadFormatVersion = "1.0" type = "HTTP_PROXY" uri = "https://ip-ranges.amazonaws.com/ip-ranges.json" } } } } }) name = "example" } resource "aws_api_gateway_deployment" "example" { rest_api_id = aws_api_gateway_rest_api.example.id triggers = { redeployment = sha1(jsonencode(aws_api_gateway_rest_api.example.body)) } lifecycle { create_before_destroy = true } } resource "aws_api_gateway_stage" "example" { deployment_id = aws_api_gateway_deployment.example.id rest_api_id = aws_api_gateway_rest_api.example.id stage_name = "example" } resource "aws_wafv2_web_acl" "example" { name = "web-acl-association-example" scope = "REGIONAL" default_action { allow {} } visibility_config { cloudwatch_metrics_enabled = false metric_name = "friendly-metric-name" sampled_requests_enabled = false } } resource "aws_wafv2_web_acl_association" "example" { resource_arn = aws_api_gateway_stage.example.arn web_acl_arn = aws_wafv2_web_acl.example.arn }
See also
Advertising: