Attach (import?) a resource to a cloudformation stack using templates

Viewed 607

I have a api gateway that was created using the aws console a long time ago, and now I would like to attach that gateway to a cloudformation stack using the template. I know the resource's logical ID, but I'm having a hard time passing the logical Id to the stack during my update operation. Is this possible without using the console? I'm aware of the console functionality to import resources to a stack, I'm trying to achieve this using a template.

1 Answers

I think there is some misconception on how does Importing Existing Resources Into a Stack work.

Change set

You can't perform stack import operation from inside a template. You have to use CLI or console for that, because you need to generate a change set for the import. This is an external operation to your templates available through CLI or Console.

Available resources

Not all resources can be imported to CFN. Luckily, AWS::ApiGateway::Resource is one of those that can.

Importing templates

To perform the importing action, you have to prepare your own template defining a resource AWS::ApiGateway::Resource which fully describes existing API resource. All attributes in the template file you define must match those of the existing API resources.

In other words, importing operation does not generate any templates (or yaml/json) files for you. Its largely manual operation involving writing a template and performing a change set.

Link

A good resource on how importing can be done using CLI, is the following tutorial:

Hope this helps.

I don't know what kind of "hard times" you have (its not described in the question), thus I'm unable to provide more precised info to help you.

Related