You've already forked devops-exercises
Update
This commit is contained in:
13
topics/gcp/exercises/assign_roles/exercise.md
Normal file
13
topics/gcp/exercises/assign_roles/exercise.md
Normal file
@@ -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
|
||||
19
topics/gcp/exercises/assign_roles/main.tf
Normal file
19
topics/gcp/exercises/assign_roles/main.tf
Normal file
@@ -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}"
|
||||
}
|
||||
23
topics/gcp/exercises/assign_roles/solution.md
Normal file
23
topics/gcp/exercises/assign_roles/solution.md
Normal file
@@ -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
|
||||
7
topics/gcp/exercises/assign_roles/vars.tf
Normal file
7
topics/gcp/exercises/assign_roles/vars.tf
Normal file
@@ -0,0 +1,7 @@
|
||||
variable "project_id" {
|
||||
type = string
|
||||
}
|
||||
|
||||
variable "env_id" {
|
||||
type = string
|
||||
}
|
||||
10
topics/gcp/exercises/assign_roles/versions.tf
Normal file
10
topics/gcp/exercises/assign_roles/versions.tf
Normal file
@@ -0,0 +1,10 @@
|
||||
terraform {
|
||||
required_version = ">=1.3.0"
|
||||
|
||||
required_providers {
|
||||
google = {
|
||||
source = "hashicorp/google"
|
||||
version = ">= 4.10.0, < 5.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user