former2 icon indicating copy to clipboard operation
former2 copied to clipboard

When generating terraform output, use references instead of absolute values

Open rorourke-iot opened this issue 1 year ago • 1 comments

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.

rorourke-iot avatar May 17 '23 14:05 rorourke-iot

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.

iann0036 avatar May 19 '23 23:05 iann0036