DataBiosphere / azul

Metadata indexer and query service used for AnVIL, HCA, LungMAP, and CGP
Apache License 2.0
6 stars 2 forks source link

Redundant API Gateway method setting resource (TF) for service #6408

Open hannes-ucsc opened 1 month ago

hannes-ucsc commented 1 month ago

The aws_api_gateway_method_settings resource is being defined using a list comprehension that doesn't use the list comprehension variables inside the aws_api_gateway_method_settings resource, making the list comprehension unnecessary and resulting in redundant aws_api_gateway_method_settings resources.

Source code:

                'aws_api_gateway_method_settings': {
                    f'{app.name}_{i}': {
                        …
                        ## neither `i` nor `domain` used in here ##
                        …
                    } for i, domain in enumerate(app.domains)
                }, 

Generated JSON:

            "aws_api_gateway_method_settings": [
                {
                    "service_0": {
                        "rest_api_id": "${aws_api_gateway_rest_api.service.id}",
                        "stage_name": "${aws_api_gateway_stage.service.stage_name}",
                        "method_path": "*/*",
                        "settings": {
                            "metrics_enabled": true,
                            "data_trace_enabled": false,
                            "logging_level": "INFO"
                        },
                        "lifecycle": {
                            "replace_triggered_by": [
                                "aws_api_gateway_stage.service.id"
                            ]
                        }
                    }
                },
                {
                    "service_1": {
                        "rest_api_id": "${aws_api_gateway_rest_api.service.id}",
                        "stage_name": "${aws_api_gateway_stage.service.stage_name}",
                        "method_path": "*/*",
                        "settings": {
                            "metrics_enabled": true,
                            "data_trace_enabled": false,
                            "logging_level": "INFO"
                        },
                        "lifecycle": {
                            "replace_triggered_by": [
                                "aws_api_gateway_stage.service.id"
                            ]
                        }
                    }
                }
            ]
        },
achave11-ucsc commented 1 month ago

Assignee to provide reproduction.

achave11-ucsc commented 1 month ago

Assignee to amend reproduction with evidence that the two resources are identical.

dsotirho-ucsc commented 2 weeks ago

Spike to check if we can use x-amazon-… extensions to the OpenAPI spec in order to configure the settings made by this resource type, which would enable us to completely eliminate this resource.

dsotirho-ucsc commented 2 weeks ago

Spike to check if we can use x-amazon-… extensions to the OpenAPI spec in order to configure the settings made by this resource type, which would enable us to completely eliminate this resource.

There are no API Gateway extensions related to the stage method settings covered by the TF resource aws_api_gateway_method_settings. I searched the documentation of each extension and there was no mention of "setting", "metric", "trace", or "logging".

dsotirho-ucsc commented 2 weeks ago

@hannes-ucsc: "So it looks like we cannot eliminate the resource completely. Assignee to file PR that removes the redundant copy and renames the remaining resource to just service / indexer."