안녕하세요 늑대양 입니다
매주 일요일 오전 10시 온오프라인 믹스 방식으로 테라폼 자격증 스터디를 진행하고 있습니다.
관련된 내용은 아래의 유튜브 채널 라이브 스트림 탭에서 확인하실 수 있습니다.
https://www.youtube.com/@TV-eu5yk/streams
늑대양TV
www.youtube.com
구독과 좋아요~😼
지난 주(20240512) 진행된 HashiCorp Terraform Associate(HCTAO-003) 스터디 3주차 내용을 전달드리도록 하겠습니다.
해당 주차에 진행된 학습 목표는 아래와 같습니다.
3주차 학습목표:
- Use Terraform outside of core workflow
- Describe when to use terraform import to import existing infrastructure into your Terraform state
- Use terraform state to view Terraform state
- Describe when to enable verbose logging and what the outcome/value is
- Interact with Terraform modules
- Contrast and use different module source options including the public Terraform Module Registry
- Interact with module inputs and outputs
- Describe variable scope within modules/child modules
- Set module version
- Use the core Terraform workflow
- Describe Terraform workflow (Write → Plan → Create)
- Initialize a Terraform working directory (terraform init)
- Validate a Terraform configuration (terraform validate)
- Generate and review an execution plan for Terraform (terraform plan)
- Execute changes to infrastructure with Terraform (terraform apply)
- Destroy Terraform managed infrastructure (terraform destroy)
- Apply formatting and style adjustments to a configuration (terraform fmt)
아래는 스터디에 사용한 노션을 편집한 내용입니다.
테라폼 자격증을 공부하시는 분들에게 도움이 되었으면 좋을 것 같습니다 🤗
Use Terraform outside of core workflow
Describe when to use terraform import to import existing infrastructure into your Terraform state
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/import
Command: import | Terraform | HashiCorp Developer
The terraform import command brings existing resources into Terraform state.
developer.hashicorp.com
- Import will find the existing resource from ID and import it into your Terraform state at the given ADDRESS.
https://developer.hashicorp.com/terraform/cli/import/usage
Import: Usage | Terraform | HashiCorp Developer
The `terraform import` command is used to import existing infrastructure.
developer.hashicorp.com
- Use the terraform import command to import existing infrastructure to Terraform state.
- The terraform import command can only import one resource at a time.
- It cannot simultaneously import an entire collection of resources, like an AWS VPC.
Use terraform state to view Terraform state
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/state
Command: state | Terraform | HashiCorp Developer
The `terraform state` command is used for advanced state management.
developer.hashicorp.com
- The terraform state command is used for advanced state management. As your Terraform usage becomes more advanced, there are some cases where you may need to modify the Terraform state.
https://developer.hashicorp.com/terraform/tutorials/state/state-cli
Manage resources in Terraform state | Terraform | HashiCorp Developer
Create an EC2 instance and security group, and move a resource to another state file. Remove, replace, and re-import resources to manage state and reconcile drift in your infrastructure.
developer.hashicorp.com
- Terraform stores information about your infrastructure in a state file. This state file keeps track of resources created by your configuration and maps them to real-world resources.
- Terraform compares your configuration with the state file and your existing infrastructure to create plans and make changes to your infrastructure.
- When you run terraform apply or terraform destroy against your initialized configuration, Terraform writes metadata about your configuration to the state file and updates your infrastructure resources accordingly.
Describe when to enable verbose logging and what the outcome/value is
https://developer.hashicorp.com/terraform/internals/v1.1.x/debugging
Debugging | Terraform | HashiCorp Developer
Terraform has detailed logs which can be enabled by setting the TF_LOG environment variable to any value. This will cause detailed logs to appear on stderr
developer.hashicorp.com
- Terraform has detailed logs which can be enabled by setting the TF_LOG environment variable to any value. This will cause detailed logs to appear on stderr.
- You can set TF_LOG to one of the log levels TRACE, DEBUG, INFO, WARN or ERROR to change the verbosity of the logs.
- Setting TF_LOG to JSON outputs logs at the TRACE level or higher, and uses a parseable JSON encoding as the formatting.
Troubleshoot Terraform | Terraform | HashiCorp Developer
Interpret and fix a Terraform configuration with common configuration language errors and deploy an EC2 instance with security groups in AWS. Learn best practices for logging application errors and reporting bugs.
developer.hashicorp.com
- Terraform 0.15 allows you to generate logs from the Terraform provider and the core application separately.
- The Terraform development team needs the core logs for your attempted operation to troubleshoot core-related errors.
- To enable core logging, set the TF_LOG_CORE environment variable to the appropriate log level.
$ export TF_LOG_CORE=TRACE
Interact with Terraform modules
Contrast and use different module source options including the public Terraform Registry
https://developer.hashicorp.com/terraform/registry/modules/use
Finding and Using Modules from the Terraform Registry | Terraform | HashiCorp Developer
The Terraform Registry makes it simple to find and use modules.
developer.hashicorp.com
- Every page on the registry has a search field for finding modules.
- Enter any type of module you are looking for (such as "vault", "vpc", "database") and the registry lists any modules matching your query.
- The search query will look at module name, provider, and description to match your search terms.
- On the results page, filters can be used further refine search results.
- By default, the registry lists all types of modules in search results. You can limit your search to only parameter modules by checking the Partner filter.
- Partner modules are reviewed by HashiCorp to ensure stability and compatibility.
https://developer.hashicorp.com/terraform/tutorials/modules/module
Modules overview | Terraform | HashiCorp Developer
Read about how Terraform modules make configuration easier to organize, understand, reuse, and share. Learn about the directory structure of a module, and how to call them.
developer.hashicorp.com
- As you manage your infrastructure with Terraform, you will create increasingly complex configurations.
- There is no intrinsic limit to the complexity of a single Terraform configuration file or directory, so it is possible to continue writing and updating your configuration files in a single directory.
- However, if you do, you may encounter one or more problems:
- Understanding and navigating the configuration files will become increasingly difficult.
- Updating the configuration will become more risky, as an update to one section may cause unintended consequences to other parts of your configuration.
- There will be an increasing amount of duplication of similar blocks of configuration, for instance when configuring separate dev/staging/production environments, which will cause an increasing burden when updating those parts of your configuration.
- You may wish to share parts of your configuration between projects and teams, and will quickly find that cutting and pasting blocks of configuration between projects is error prone and hard to maintain.
- Engineers will need more Terraform expertise to understand and modify your configuration. This makes self-service workflows for other teams more difficult, slowing down their development.
https://developer.hashicorp.com/terraform/tutorials/modules/module-use
Use registry modules in configuration | Terraform | HashiCorp Developer
Use modules from the public Terraform Registry to define an Amazon VPC containing two EC2 instances. Select module and root input and output variables, install the modules, and apply the configuration.
developer.hashicorp.com
Interact with module inputs and outputs
https://developer.hashicorp.com/terraform/language/values/variables
Input Variables - Configuration Language | Terraform | HashiCorp Developer
Input variables allow you to customize modules without altering their source code. Learn how to declare, define, and reference variables in configurations.
developer.hashicorp.com
- Input variables let you customize aspects of Terraform modules without altering the module's own source code.
- This functionality allows you to share modules across different Terraform configurations, making your module composable and reusable.
Modules - Configuration Language | Terraform | HashiCorp Developer
Modules are containers for multiple resources that are used together in configurations. Learn how to call one module from another and access module output.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/modules/module-use
Use registry modules in configuration | Terraform | HashiCorp Developer
Use modules from the public Terraform Registry to define an Amazon VPC containing two EC2 instances. Select module and root input and output variables, install the modules, and apply the configuration.
developer.hashicorp.com
Describe variable scope within modules/child modules
https://developer.hashicorp.com/terraform/language/v1.1.x/values/variables
Input Variables - Configuration Language | Terraform | HashiCorp Developer
Input variables allow you to customize modules without altering their source code. Learn how to declare, define, and reference variables in configurations.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/language/v1.1.x/modules/syntax
Modules - Configuration Language | Terraform | HashiCorp Developer
Modules are containers for multiple resources that are used together in configurations. Learn how to call one module from another and access module output.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/modules/module-create
Build and use a local module | Terraform | HashiCorp Developer
Write a local module to create an Amazon S3 bucket hosting a static website. Create a module directory, write the module configuration, variables, and outputs, and call the module from a root configuration.
developer.hashicorp.com
Set module version
https://developer.hashicorp.com/terraform/language/v1.1.x/modules/syntax#version
Modules - Configuration Language | Terraform | HashiCorp Developer
Modules are containers for multiple resources that are used together in configurations. Learn how to call one module from another and access module output.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/modules/module-use
Use registry modules in configuration | Terraform | HashiCorp Developer
Use modules from the public Terraform Registry to define an Amazon VPC containing two EC2 instances. Select module and root input and output variables, install the modules, and apply the configuration.
developer.hashicorp.com
Initialize a Terraform working directory (terraform init)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/init
Command: init | Terraform | HashiCorp Developer
The terraform init command initializes a working directory containing configuration files and installs plugins for required providers.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/cli/init
Initialize Terraform configuration | Terraform | HashiCorp Developer
Learn what Terraform does when you run `terraform init` in a working directory. Initialize the backend, install providers, download modules, and explore the lock file and .terraform directory.
developer.hashicorp.com
Validate a Terraform configuration (terraform validate)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/validate
Command: validate | Terraform | HashiCorp Developer
The `terraform validate` command is used to validate the syntax of the terraform files.
developer.hashicorp.com
Troubleshoot Terraform | Terraform | HashiCorp Developer
Interpret and fix a Terraform configuration with common configuration language errors and deploy an EC2 instance with security groups in AWS. Learn best practices for logging application errors and reporting bugs.
developer.hashicorp.com
Generate and review an execution plan for Terraform (terraform plan)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/plan
Command: plan | Terraform | HashiCorp Developer
The terraform plan command creates an execution plan with a preview of the changes that Terraform will make to your infrastructure.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/cli/plan
Create a Terraform plan | Terraform | HashiCorp Developer
Learn how Terraform constructs an execution plan. Export a plan with the -out flag, review the plan contents, and apply a saved plan.
developer.hashicorp.com
Execute changes to infrastructure with Terraform (terraform apply)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/apply
Command: apply | Terraform | HashiCorp Developer
The terraform apply command executes the actions proposed in a Terraform plan to create, update, or destroy infrastructure.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/cli/apply
Apply Terraform configuration | Terraform | HashiCorp Developer
Learn how Terraform applies configuration to change your infrastructure. Provision a Docker container, introduce an apply error, note how Terraform handles errors, and perform basic troubleshooting.
developer.hashicorp.com
Destroy Terraform managed infrastructure (terraform destroy)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/destroy
Command: destroy | Terraform | HashiCorp Developer
The terraform destroy command destroys all objects managed by a Terraform configuration.
developer.hashicorp.com
https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-destroy
Destroy infrastructure | Terraform | HashiCorp Developer
Destroy the AWS EC2 instance you created in the previous tutorials. Evaluate the plan and confirm the destruction.
developer.hashicorp.com
Apply formatting and style adjustments to a configuration (terraform fmt)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/fmt
Command: fmt | Terraform | HashiCorp Developer
The terraform fmt command rewrites configuration files to a canonical format and style.
developer.hashicorp.com
Troubleshoot Terraform | Terraform | HashiCorp Developer
Interpret and fix a Terraform configuration with common configuration language errors and deploy an EC2 instance with security groups in AWS. Learn best practices for logging application errors and reporting bugs.
developer.hashicorp.com
Terraform Associate 자격증을 준비하는 분들에게 도움이 되었으면 좋을 것 같습니다!
긴 글 읽어주셔서 감사합니다 🤗
요즘 날씨가 참 좋네요 (왜 공휴일,, 주말에만 비가 오는지,,)
5월도 화이팅 하시와요!!!
감사합니다
'Terraform > Terraform Associate Study' 카테고리의 다른 글
Terraform Associate Study - 20240505 - 2주차 (0) | 2024.05.06 |
---|---|
Terraform Associate Study - 20240428 - 1주차 (0) | 2024.05.05 |
Terraform Associate Study - 20240421 - OT (0) | 2024.05.01 |