Updating Your Configuration with more resources
Time to update architecture to include resiliency, by adding resources
- Improve our architecture by adding more ec2 instances
- start off by updating the architectural design, determine what resources we need
- then consult docs to see what arguments are needed for each resource
- update the config with new resources and data sources
- review state data
Globomantics scenario
- add a second AZ
- add a second ec2 instance
- make both instances accessible with a load balancer
- maintain readability of code, split resources into their own files like variables, locals and outputs
- easier to read
- files may be reusable for other configurations
- When setting up files, you can add placeholders or comments (using double ##) to indicate what resources we know that we need to create
Using the Documentation

- The documentation for providers and their resources are available at:Terraform Registry
https://registry.terraform.io
Viewing State Data
- state data is stored in a JSON format
- DO NOT TOUCH
- use can use Terraform commands to work with it instead
- stores important information about deployment, including:
- mappings of resources from the identifiers in config to a unique identifier in target env
- metadata about the version of terraform used, version of state data format, and serial number of current state data
- when executing operations which alter state data, data is locked so no other instance of terraform can make changes
- State data can be stored on local host, or remotely on AWS, azure, terraform cloud, etc.
- can also support workspaces, which allows one configuration to be used for multiple instances of a deployment, each with unique state data
EXAMPLE

- serial number is incremented each time state data is updated
- lineage is unique id associated with each instance of state data or deployment
State Data commands

Address is resource_type.<name_label>
To move, you need to provide source address and then destination address, like mv on unix
First rule of Terraform?
Make all changes with Terraform
Summary
- We have improved our deployment
- more resilient and production ready
- Used Terraform documentation
- explored state data and commands