former2
former2 copied to clipboard
When generating terraform output, use references instead of absolute values
In a lot of cases, the generated terraform output contains absolute id values for the resources rather than a reference to the same resource. For example,
resource "aws_api_gateway_rest_api" "ApiGatewayRestApi" {
name = "my-api"
api_key_source = "HEADER"
endpoint_configuration {
types = [
"EDGE"
]
}
tags = {}
}
resource "aws_api_gateway_deployment" "ApiGatewayDeployment" {
rest_api_id = "g7cfh7e9y8"
}
Rather than "g7cfh7e9y8"
, use aws_api_gateway_rest_api.ApiGatewayRestApi.id
. This is just one example and not intended to be a complete representation of all the places found in the terraform output. For example, I found the same issue referencing s3_bucket
, resource_id
, and authorizer_id
among others.
Hi @rorourke-iot,
Thanks for raising! I've fixed the referencing for REST API Gateway and API Gateway Authorizer for you. Unfortunately, there is a significant manual overhead to getting to all possible references so some may be missing from time to time. I'll try to get to them when I can.