So, importing via the CLI is pretty nice. However, what if you want to import resource state in your code directly? Run the code once, then you're set to go? Well, we can do that with an import call in the code itself. This call is part of the `ResourceOptions` in every SDK that Pulumi provides.
## Finding identifiers
As before, we have to get `id`s from our providers to import resources. We've done this a couple times now, so you should have it handy!
## Coding up the import
We use the `ResourceOptions``import` key to define a key:value pair that contains the ID. Let's try importing the frontend container. Make a new directory and initialize a new Pulumi program in the language of your choice. Then update the {{<langfile>}} to include the following code (with the ID pulled from Docker):
Now that you have the code, actually importing the resource is one command away: `pulumi up`. As before, you'll get an equal sign instead of a plus sign in the preview of the actions taken by Pulumi. This means nothing specifically changed with the resource; the service just set it in the stack based on the results coming from the provider.
If you run `pulumi up` (or `pulumi preview`) and get an error like this, you need to check your `id` value:
```bash
error: Preview failed: importing <id><type> not found
```
If you had any issues with the CLI command, you'll notice the slight difference in the error message. Here's the error you'd get from the CLI:
```bash
error: Preview failed: resource <id> does not exist
```
One big difference to note for this method compared to the others is that this method **does not** protect the resource automatically. From here, any subsequent action by Pulumi as a result of modification of your code will apply to the resource, including destruction if you were to remove the resource from your code.
## Moving forward
From here, you need to remove the `import` option to continue to update the resource. We only run that option once. And you can modify the resources as you see fit in the code with every `pulumi up` or `pulumi destroy` applying to the resource as with every other one you have in your code.
{{% notes type=warning %}}
If you were following along, don't forget to tear down your stack and tear down the Terraform resources you stood up! `pulumi destroy` and `terraform destroy`
{{% /notes %}}
<br/>
<hr/>
Congratulations! You've now finished this pathway on importing resources and migrating to Pulumi! In this pathway, you've learned about importing resources via a CLI command, importing resources in bulk, and importing resources in code.
Go build new things, and watch this space for more learning experiences with Pulumi!