forked from DataTalksClub/data-engineering-zoomcamp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
sejalv
committed
Jan 15, 2022
1 parent
f470a47
commit e2f312d
Showing
48 changed files
with
163 additions
and
135 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
56 changes: 44 additions & 12 deletions
56
week_1_basics_n_setup/1_terraform_gcp/1_terraform_overview.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,50 @@ | ||
(In Draft mode) | ||
|
||
## Terraform Overview | ||
|
||
### Concepts | ||
|
||
1. Introduction | ||
2. TF state & backend | ||
3. Google Provider as source | ||
* modules/resources: google_storage_bucket, google_bigquery_dataset, google_bigquery_table | ||
4. Code: main, resources, variables, locals, outputs | ||
5. Demo | ||
* GCP CLI client (gcloud) - setup & auth | ||
* tf init, plan & apply | ||
#### Introduction | ||
1. What if Terraform? | ||
* open-source tool by HashiCorp, used for provisioning infrastructure resources | ||
* supports DevOps best practices for change management | ||
* Managing configuration files in source control to maintain an ideal provisioning state | ||
for testing and production environments | ||
|
||
2. What is IaC? | ||
* Infrastructure-as-Code | ||
* build, change, and manage your infrastructure in a safe, consistent, and repeatable way | ||
by defining resource configurations that you can version, reuse, and share. | ||
|
||
3. Some advantages | ||
* Infrastructure lifecycle management | ||
* Version control commits | ||
* Very useful for stack-based deployments, and with cloud providers such as AWS, GCP, Azure, K8S… | ||
* State-based approach to track resource changes throughout deployments | ||
|
||
|
||
#### Files | ||
* `main.tf` | ||
* `variables.tf` | ||
* Optional: `resources.tf`, `output.tf` | ||
* `.tfstate` | ||
|
||
#### Declarations | ||
* `terraform` | ||
* `backend`: state | ||
* `provider`: | ||
* adds a set of resource types and/or data sources that Terraform can manage | ||
* The Terraform Registry is the main directory of publicly available providers from most major infrastructure platforms. | ||
* `resource` | ||
* blocks to define components of your infrastructure | ||
* Project modules/resources: google_storage_bucket, google_bigquery_dataset, google_bigquery_table | ||
* `variable` & `locals` | ||
|
||
|
||
#### Execution steps | ||
1. `terraform init`: Initialize & install | ||
2. `terraform plan`: Match changes against the previous state | ||
3. `terraform apply`: Apply changes to cloud | ||
4. `terraform destroy`: Remove your stack from cloud | ||
|
||
|
||
### Workshop | ||
Continue [here](../../project/terraform): `data-engineering-zoomcamp/project/terraform` | ||
### Terraform Workshop for GCP Infra | ||
Continue [here](../terraform): `week_1_basics_n_setup/1_terraform_gcp/terraform` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,42 @@ | ||
(In Draft mode) | ||
|
||
## GCP Overview | ||
|
||
## Tools & Tech | ||
- Cloud Storage | ||
- BigQuery | ||
### Project infrastructure modules in GCP: | ||
* Google Cloud Storage (GCS): Data Lake | ||
* BigQuery: Data Warehouse | ||
|
||
(Concepts explained in Week 2 - Data Ingestion) | ||
|
||
### Initial Setup | ||
|
||
For this course, we'll use a free version (upto EUR 300 credits). | ||
|
||
1. Create an account with your Google email ID | ||
2. Setup your first [project](https://console.cloud.google.com/) | ||
* eg. "DTC DE Course", and note down the "Project ID" | ||
3. Setup [service account & authentication](https://cloud.google.com/docs/authentication/getting-started) for this project | ||
* Grant `Viewer` role to begin with. | ||
* Download service-account-keys (.json) for auth. | ||
4. Download [SDK](https://cloud.google.com/sdk/docs/quickstart) for local setup | ||
5. Set environment variable to point to your downloaded GCP keys: | ||
```shell | ||
export GOOGLE_APPLICATION_CREDENTIALS="<path/to/your/service-account-authkeys>.json" | ||
|
||
# Refresh token, and verify authentication | ||
gcloud auth application-default login | ||
``` | ||
|
||
### Setup for Access | ||
|
||
1. [IAM Roles](https://cloud.google.com/storage/docs/access-control/iam-roles) for Service account: | ||
|
||
Viewer + Storage Admin + Storage Object Admin + BigQuery Admin | ||
|
||
2. Enable these APIs for your project: | ||
* https://console.cloud.google.com/apis/library/iam.googleapis.com | ||
* https://console.cloud.google.com/apis/library/iamcredentials.googleapis.com | ||
|
||
3. Please ensure `GOOGLE_APPLICATION_CREDENTIALS` env-var is set. | ||
```shell | ||
export GOOGLE_APPLICATION_CREDENTIALS="<path/to/your/service-account-authkeys>.json" | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,17 @@ | ||
(In Draft mode) | ||
|
||
## Local Setup for Terraform and GCP | ||
|
||
### Terraform | ||
|
||
Installation: https://www.terraform.io/downloads | ||
### Pre-Requisites | ||
1. Terraform client installation: https://www.terraform.io/downloads | ||
2. Cloud Provider account: https://console.cloud.google.com/ | ||
|
||
### GCP | ||
### Terraform Concepts | ||
[Terraform Overview](1_terraform_overview.md) | ||
|
||
For this course, we'll use a free version (upto EUR 300 credits). | ||
### GCP setup | ||
|
||
1. Create an account with your Google email ID | ||
2. Setup your first [project](https://console.cloud.google.com/), eg. "DTC DE Course", and note down the "Project ID" | ||
3. Setup [service account & authentication](https://cloud.google.com/docs/authentication/getting-started) for this project, and download auth-keys (.json). | ||
4. Download [SDK](https://cloud.google.com/sdk/docs/quickstart) for local setup | ||
5. Set environment variable to point to your downloaded GCP auth-keys: | ||
```shell | ||
export GOOGLE_APPLICATION_CREDENTIALS="<path/to/your/service-account-authkeys>.json" | ||
|
||
# Refresh token, and verify authentication | ||
gcloud auth application-default login | ||
``` | ||
1. [Setup for First-time](2_gcp_overview.md#Initial Setup) | ||
2. [IAM / Access specific to this course](2_gcp_overview.md#Setup for Access) | ||
|
||
### Workshop | ||
Continue [here](../../project/terraform): `data-engineering-zoomcamp/project/terraform` | ||
### Terraform Workshop for GCP Infra | ||
Continue [here](terraform). | ||
`week_1_basics_n_setup/1_terraform_gcp/terraform` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
### Execution | ||
|
||
```shell | ||
# Refresh service-account's auth-token for this session | ||
gcloud auth application-default login | ||
|
||
# Initialize state file (.tfstate) | ||
terraform init | ||
|
||
# Check changes to new infra plan | ||
terraform plan -var="project=<your-project-id>" | ||
``` | ||
|
||
```shell | ||
# Create new infra | ||
terraform apply -var="project=<your-project-id>" | ||
``` | ||
|
||
```shell | ||
# Delete infra after your work, to avoid costs on any running services | ||
terraform destroy | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
(In Draft mode) | ||
|
||
## Setup Postgres Env with Docker |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Empty file.
Empty file.
Empty file.