안녕하세요 늑대양 입니다
매주 일요일 오전 10시 온오프라인 믹스 방식으로 테라폼 자격증 스터디를 진행하고 있습니다.
관련된 내용은 아래의 유튜브 채널 라이브 스트림 탭에서 확인하실 수 있습니다.
https://www.youtube.com/@TV-eu5yk/streams
구독과 좋아요~😼
지난 주(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
- 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
- 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
- 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
- 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
- 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.
- 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
- 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
- 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
Interact with module inputs and outputs
https://developer.hashicorp.com/terraform/language/values/variables
- 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.
https://developer.hashicorp.com/terraform/tutorials/modules/module-use
Describe variable scope within modules/child modules
https://developer.hashicorp.com/terraform/language/v1.1.x/values/variables
https://developer.hashicorp.com/terraform/language/v1.1.x/modules/syntax
https://developer.hashicorp.com/terraform/tutorials/modules/module-create
Set module version
https://developer.hashicorp.com/terraform/language/v1.1.x/modules/syntax#version
https://developer.hashicorp.com/terraform/tutorials/modules/module-use
Initialize a Terraform working directory (terraform init)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/init
https://developer.hashicorp.com/terraform/tutorials/cli/init
Validate a Terraform configuration (terraform validate)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/validate
Generate and review an execution plan for Terraform (terraform plan)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/plan
https://developer.hashicorp.com/terraform/tutorials/cli/plan
Execute changes to infrastructure with Terraform (terraform apply)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/apply
https://developer.hashicorp.com/terraform/tutorials/cli/apply
Destroy Terraform managed infrastructure (terraform destroy)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/destroy
https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-destroy
Apply formatting and style adjustments to a configuration (terraform fmt)
https://developer.hashicorp.com/terraform/cli/v1.1.x/commands/fmt
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 |