# How to modify a resource I just created -\> aws\_api\_gateway\_rest\_api and underneat method

**URL:** <https://discuss.hashicorp.com/t/how-to-modify-a-resource-i-just-created-aws-api-gateway-rest-api-and-underneat-method/35086>\
**Category:** AWS\
**Created:** [February 1, 2022, 7:36pm UTC](https://discuss.hashicorp.com/t/how-to-modify-a-resource-i-just-created-aws-api-gateway-rest-api-and-underneat-method/35086 "2022-02-01T19:36:33Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![YGamelin](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/ygamelin/32/24161_2.png) [@YGamelin](https://discuss.hashicorp.com/u/YGamelin)\
**Post date:** [February 1, 2022, 7:36pm UTC](https://discuss.hashicorp.com/t/how-to-modify-a-resource-i-just-created-aws-api-gateway-rest-api-and-underneat-method/35086/1 "2022-02-01T19:36:33Z")

</div>

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
