Provides an API Gateway REST API Policy.
resource "aws_api_gateway_rest_api" "test" {
name = "example-rest-api"
}
data "aws_iam_policy_document" "test" {
statement {
effect = "Allow"
principals {
type = "AWS"
identifiers = ["*"]
}
actions = ["execute-api:Invoke"]
resources = [aws_api_gateway_rest_api.test.execution_arn]
condition {
test = "IpAddress"
variable = "aws:SourceIp"
values = ["123.123.123.123/32"]
}
}
}
resource "aws_api_gateway_rest_api_policy" "test" {
rest_api_id = aws_api_gateway_rest_api.test.id
policy = data.aws_iam_policy_document.test.json
}
This resource supports the following arguments:
rest_api_id
- (Required) ID of the REST API.policy
- (Required) JSON formatted policy document that controls access to the API Gateway. For more information about building AWS IAM policy documents with Terraform, see the AWS IAM Policy Document GuideThis resource exports the following attributes in addition to the arguments above:
id
- ID of the REST APIIn Terraform v1.5.0 and later, use an import
block to import aws_api_gateway_rest_api_policy
using the REST API ID. For example:
import {
to = aws_api_gateway_rest_api_policy.example
id = "12345abcde"
}
Using terraform import
, import aws_api_gateway_rest_api_policy
using the REST API ID. For example:
% terraform import aws_api_gateway_rest_api_policy.example 12345abcde