Resource: aws_api_gateway_rest_api_policy

Provides an API Gateway REST API Policy.

Example Usage

Basic

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
}

Argument Reference

This resource supports the following arguments:

Attribute Reference

This resource exports the following attributes in addition to the arguments above:

Import

In 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