Home > Software design >  Unable to reference an AWS API Gateway Usage Plan as a data source in Terraform
Unable to reference an AWS API Gateway Usage Plan as a data source in Terraform

Time:03-22

I have two Terraform projects that are deployed at different times. One of them needs to reference an API Gateway Usage plan in the other project, which should be deployed first. The code looks like this:

data "aws_api_gateway_usage_plan" "usage_plan" {
  name = "name-of-usage-plan"
}

However, when I execute terraform plan, I get the following:

data "aws_api_gateway_usage_plan" "usage_plan" {

The provider hashicorp/aws does not support data source "aws_api_gateway_usage_plan".

Did you intend to use the managed resource type "aws_api_gateway_usage_plan"? If so, declare this using a "resource" block instead of a "data" block.

I think that if I use a "resource" block it will just create a new usage plan, which I don't want to do.

I'm using terraform 1.1.0 with the aws provider v4.6.0.

What other options do I have? Can I use the AWS CLI to get a reference to the resource? I only need to get its ARN to add it to an IAM statement.

CodePudding user response:

There is no data source called aws_api_gateway_usage_plan. TF does not support that. Please check docs for list of existing data sources.

You have to implement your own custom data source to query API stage details.

  • Related