https://github.com/DataTalksClub/data-engineering-zoomcamp
GitHub - DataTalksClub/data-engineering-zoomcamp: Data Engineering Zoomcamp is a free nine-week course that covers the fundament
Data Engineering Zoomcamp is a free nine-week course that covers the fundamentals of data engineering. - DataTalksClub/data-engineering-zoomcamp
github.com
목차
Introduction Terraform: Concepts and Overview, a primer
챕터1_2. GCP Terraform
🌏 Terraform
Introduction Terraform: Concepts and Overview, a primer
- https://www.youtube.com/watch?v=s2bOYDCKl_M&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=12
- Terraforming: 생명체가 살 수 있는 조건을 만드는 과정
- HashiCorp Terraform: 클라우드와 온프레미스 리소스를 정의할 수 있는 인프라 코드 도구
- Terraform을 사용하는 이유
- 간편하게 파일로 정의하여 인프라를 추적
- 쉬운 협업
- 재현성
- 리소스 제거 보증
- Terraform이 해주지 않는 것
- 인프라 업데이트 코드를 관리 X
- 불변 리소스를 변경할 수 있는 기능 제공 X
- 정의되지 않은 리소스를 관리하는데 사용 X
- Terraform=Infrastructure as code
- Providers: 리소스를 관리하고 통신할 수 있도록 허용하는 코드
- Command: init, plan, apply, destroy
- 설치
Terraform Basics: Simple one file Terraform Deployment
- https://www.youtube.com/watch?v=Y2ux7gq3Z0o&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=12
- 서비스 계정
- 소프트웨어에서 작업을 실행하거나 프로그램 실행하는데 사용되는 계정 관련 정보
- 실습
- GCP IAM&Admin에서 서비스 계정 설정,
- 권한 설정 (Storage Admin, Compute Admin, Big Query Admin)
- json 키 생성 및 저장
- 실습
- key 설정
$env:GOOGLE_CREDENTIALS = "C:\Users\82105\zoomcamp\1_terraform\keys\my-creds.json"
- 실습
- terraform init: 초기화 작업
# main.tf
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.27.0"
}
}
}
provider "google" {
project = "bold-mantis-452207-g9"
region = "us-central1"
}
terraform init
- 실습
- terraform plan: 수정된 부분만 반영
# main.tf
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.27.0"
}
}
}
provider "google" {
project = "bold-mantis-452207-g9"
region = "us-central1"
}
resource "google_storage_bucket" "demo-bucket" {
name = "bold-mantis-452207-g9-terra-bucket"
location = "US"
force_destroy = true
lifecycle_rule {
condition {
age = 1
}
action {
type = "AbortIncompleteMultipartUpload"
}
}
}
terraform plan
- 실습
- terraform apply: 배포
terraform apply
- 실습
- terraform destroy
terraform destroy
Deployment with a Variables File
- https://www.youtube.com/watch?v=PBi0hHjLftk&list=PL3MmuxUbc_hJed7dXYoJw8DoCuVHhGEQb&index=13
- 실습
- bigquery dataset 생성
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.27.0"
}
}
}
provider "google" {
project = "bold-mantis-452207-g9"
region = "us-central1"
}
resource "google_storage_bucket" "demo-bucket" {
name = "bold-mantis-452207-g9-terra-bucket"
location = "US"
force_destroy = true
lifecycle_rule {
condition {
age = 1
}
action {
type = "AbortIncompleteMultipartUpload"
}
}
}
resource "google_bigquery_dataset" "demo_dataset" {
dataset_id = "demo_dataset"
}
terraform apply
- 실습
- 변수 설정
# main.tf
terraform {
required_providers {
google = {
source = "hashicorp/google"
version = "6.27.0"
}
}
}
provider "google" {
credentials = file(var.credentials)
project = var.project
region = var.region
}
resource "google_storage_bucket" "demo-bucket" {
name = var.gcs_bucket_name
location = var.location
force_destroy = true
lifecycle_rule {
condition {
age = 1
}
action {
type = "AbortIncompleteMultipartUpload"
}
}
}
resource "google_bigquery_dataset" "demo_dataset" {
dataset_id = var.bq_dataset_name
location=var.location
}
# variables.tf
variable "credentials" {
description = "My Credentials"
default = "./keys/my-creds.json"
}
variable "project" {
description = "Project"
default = "bold-mantis-452207-g9"
}
variable "region" {
description = "Region"
default = "us-central1"
}
variable "location" {
description = "Project Location"
default = "US"
}
variable "bq_dataset_name" {
description = "My BigQuery Dataset Name"
default = "demo_dataset"
}
variable "gcs_bucket_name" {
description = "My Storage Bucket Name"
default = "bold-mantis-452207-g9-terra-bucket"
}
variable "gcs_storage_class" {
description = "Bucket Storage Class"
default = "STANDARD"
}
'Boaz > Data Pipeline' 카테고리의 다른 글
[Data Engineering Zoomcamp #1] Docker, SQL (0) | 2025.03.28 |
---|