# 2. Modify Resources

* Terraform works in a declearative manner
* If we re apply a terraform file, it is not going to re apply the config like some code
* Like in previous example, if we applied that file multiple times, it was not going to deploy multiple ec2 machines each time we apply it
* We can modify the config file and terraform will update the resource
* Take the previous example and add a tag and apply the config, terraform will update the ec2 instance with the tag specified

```hcl
#####################
# Modifying EC2 Instance Tag
#####################
resource "aws_instance" "my-first-server" {
    ami = "ami-052efd3df9dad4825"
    instance_type = "t2.micro"

    tags = {
        Name = "ubuntu"
    }
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://notes.nomanaziz.me/devops/infrastructure-as-a-code-iac/terraform/2.-modify-resources.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
