Hello TF!
Ok I have a script that created an aws_api_gateway_rest_api based on an openApi document. Creation of that rest_api will provide an Id
from there I can easily retrieve one of the resource using the rest_api.id and a path
data “aws_api_gateway_resource” “_”
that’s pretty usefull to managed aws_api_gateway_integration and
aws_api_gateway_integration_response of the aws_api_gateway_resource
But now I m stuck with the aws_api_gateway_method. I want to add a custom authorizer. I say add because the method is already created by the specification of the openAPi document used earlier by the rest-api. TF doesn’t support data source for method. So it can’t be retrieved and using Resource will tell the resource already exist.
How should I address this ?
I can tell you what I thought.
I could first run terraform output and use its outcome to set one or more variable(s)
then on the aws_api_gateway_method, I could use the count meta-argument to modify the endpoint or not.
BUT prior to that, to have my access to my method, it must be part of the TF state, so I need to do an terraform import right?
terraform import -var-file=xxx/input.tfvars aws_api_gateway_method.MyDemoMethod awg3v8uha6/pg4ace/POST
then I can do TF apply a for second time. I won’t get the resource already exist, and my method will get the custom authorizer attached to it
it is tedious, but I havent found a simpler way, please tell me what you think and say if you have a better way of doing it