forked from bregman-arie/devops-exercises
-
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
1 parent
d2f681f
commit 7cceb86
Showing
17 changed files
with
672 additions
and
318 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,5 @@ | ||
# DataDog | ||
|
||
## Questions | ||
|
||
TODO |
Large diffs are not rendered by default.
Oops, something went wrong.
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,13 @@ | ||
# Assign Roles | ||
|
||
## Objectives | ||
|
||
1. Assign the following roles to a member in your organization | ||
1. Compute Storage Admin | ||
2. Compute Network Admin | ||
3. Compute Security Admin | ||
2. Verify roles were assigned | ||
|
||
## Solution | ||
|
||
Click [here](solution.md) to view the solution |
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,19 @@ | ||
locals { | ||
roles = [ | ||
"roles/compute.storageAdmin", | ||
"roles/compute.networkAdmin", | ||
"roles/compute.securityAdmin" | ||
] | ||
} | ||
|
||
resource "google_service_account" "some_member" { | ||
account_id = "${substr(var.env_id, 0, min(length(var.env_id), 10))}-some-member" | ||
display_name = "${var.env_id} some-member" | ||
} | ||
|
||
resource "google_project_iam_member" "storageAdminMaster" { | ||
for_each = toset(concat(local.roles)) | ||
project = "${var.project_id}" | ||
role = each.key | ||
member = "serviceAccount:${google_service_account.some_member.email}" | ||
} |
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 @@ | ||
# Assign Roles | ||
|
||
## Objectives | ||
|
||
1. Assign the following roles to a member in your organization | ||
1. Compute Storage Admin | ||
2. Compute Network Admin | ||
3. Compute Security Admin | ||
2. Verify roles were assigned | ||
|
||
## Solution | ||
|
||
### Console | ||
|
||
1. Go to IAM & Admin | ||
2. Click on IAM and then on the "Add" button | ||
1. Choose the member account to whom the roles will be added | ||
2. Under select role, search for the specified roles under "Objectives" and click on "Save" | ||
2. The member should now be able to go to the compute engine API and see the resources there. | ||
|
||
### Terraform | ||
|
||
Click [here](main.tf) to view the Terraform main.tf file |
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,7 @@ | ||
variable "project_id" { | ||
type = string | ||
} | ||
|
||
variable "env_id" { | ||
type = string | ||
} |
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,10 @@ | ||
terraform { | ||
required_version = ">=1.3.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 4.10.0, < 5.0" | ||
} | ||
} | ||
} |
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,9 @@ | ||
# Create a Project | ||
|
||
## Objectives | ||
|
||
1. Create a project with a unique name | ||
|
||
## Solution | ||
|
||
Click [here](solution.md) to view the solution |
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,10 @@ | ||
resource "google_project" "gcp_project" { | ||
name = "Some Project" | ||
project_id = "some-unique-project-id" | ||
folder_id = google_folder.some_folder.name | ||
} | ||
|
||
resource "google_folder" "some_folder" { | ||
display_name = "Department 1" | ||
parent = "organizations/some-organization" | ||
} |
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,19 @@ | ||
# Create a Project | ||
|
||
## Objectives | ||
|
||
1. Create a project with a unique name | ||
|
||
## Solution | ||
|
||
### Console | ||
|
||
1. Click in the top bar on "New Project" (if you already have a project then, click on the project name and then "New Project") or in the search bar insert "Create Project". | ||
2. Insert a globally unique project name | ||
3. Optionally choose an organization | ||
4. Optionally put it under a specific folder | ||
5. Click on "Create" :) | ||
|
||
### Terraform | ||
|
||
Click [here](main.tf) to view the solution |
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,10 @@ | ||
terraform { | ||
required_version = ">=1.3.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 4.10.0, < 5.0" | ||
} | ||
} | ||
} |
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,17 @@ | ||
# Create an Instance | ||
|
||
## Objectives | ||
|
||
1. Create a VM instance with the following properties | ||
1. name: instance-1 | ||
2. type: e2-micro | ||
3. labels: | ||
1. app: web | ||
2. env: dev | ||
2. Using the CLI (gcloud) perform the following operations: | ||
1. Update "app" label to "db" | ||
2. Remove "env" label | ||
|
||
## Solution | ||
|
||
Click [here](solution.md) to view the solution |
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,21 @@ | ||
resource "google_compute_network" "vpc_network" { | ||
name = "my-custom-mode-network" | ||
auto_create_subnetworks = false | ||
mtu = 1460 | ||
} | ||
|
||
resource "google_compute_subnetwork" "default" { | ||
name = "my-custom-subnet" | ||
ip_cidr_range = "10.0.1.0/24" | ||
region = "us-west1" | ||
network = google_compute_network.vpc_network.id | ||
} | ||
|
||
resource "google_compute_instance" "default" { | ||
name = "instance-1" | ||
machine_type = "e2-micro" | ||
zone = "us-west1-a" | ||
labels = { | ||
app = "db" | ||
} | ||
} |
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,45 @@ | ||
# Create an Instance | ||
|
||
## Objectives | ||
|
||
1. Create a VM instance with the following properties | ||
1. name: instance-1 | ||
2. type: e2-micro | ||
3. labels: | ||
1. app: web | ||
2. env: dev | ||
2. Using the CLI (gcloud) perform the following operations: | ||
1. Update "app" label to "db" | ||
2. Remove "env" label | ||
|
||
## Solution | ||
|
||
### Console | ||
|
||
1. Go to Compute Engine -> VM instances | ||
2. Click on "Create Instance" | ||
1. Insert the name "instance-1" | ||
2. Click on "Add label" and add the following labels: | ||
1. app: web | ||
2. env: dev | ||
3. Choose machine type: e2-micro | ||
3. Click on "Create" | ||
4. Selected the created instance and click on "show info panel" | ||
1. Click on "labels" tab and change the value of "app" label to "db" | ||
2. Remove the "env" label | ||
|
||
### Shell | ||
|
||
``` | ||
gcloud config set project <PROJECT_ID> | ||
gcloud config set compute/region <REGION NAME> | ||
gcloud config set compute/zone <ZONE NAME> | ||
gcloud compute instances create instance-1 --labels app=web,env=dev --machine-type=e2-micro | ||
gcloud compute instances update instance-1 --update-labels app=db | ||
gcloud compute instances update instance-1 --remove-labels env | ||
``` | ||
|
||
### Terraform | ||
|
||
Click [here](main.tf) to view the main.tf file |
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,10 @@ | ||
terraform { | ||
required_version = ">=1.3.0" | ||
|
||
required_providers { | ||
google = { | ||
source = "hashicorp/google" | ||
version = ">= 4.10.0, < 5.0" | ||
} | ||
} | ||
} |