-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Attach KMS Key in Safer IAP GKE cluster #1614
Merged
bharathkkb
merged 12 commits into
terraform-google-modules:master
from
avinashkumar1289:avinashjha/gke-kms
May 23, 2023
Merged
Changes from 3 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
99aeee8
Adding support for KMS for safer GKE Cluster
avinashkumar1289 5d1a037
changes for default Keys
avinashkumar1289 fef3d64
Merge branch 'master' into avinashjha/gke-kms
bharathkkb 432e176
KMS related changes
avinashkumar1289 34a610c
KMS related changes
avinashkumar1289 4acea17
Merge branch 'avinashjha/gke-kms' of github.com:avinashkumar1289/terr…
avinashkumar1289 3ef4afc
Merge branch 'terraform-google-modules:master' into avinashjha/gke-kms
avinashkumar1289 8f49681
ReadMe changes
avinashkumar1289 8623939
Merge branch 'avinashjha/gke-kms' of github.com:avinashkumar1289/terr…
avinashkumar1289 f766e7b
Merge branch 'master' into avinashjha/gke-kms
bharathkkb 473b1d6
Terraform Format
avinashkumar1289 7537ab9
Merge branch 'master' into avinashjha/gke-kms
avinashkumar1289 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
data "google_project" "project" {} | ||
|
||
locals { | ||
gke_sa = "serviceAccount:service-${data.google_project.project.number}@container-engine-robot.iam.gserviceaccount.com" | ||
} | ||
|
||
module "kms" { | ||
source = "terraform-google-modules/kms/google" | ||
version = "~> 2.2.1" | ||
project_id = var.project_id | ||
location = var.region | ||
keyring = var.keyring | ||
keys = var.keys | ||
prevent_destroy = false | ||
set_decrypters_for = var.keys | ||
set_encrypters_for = var.keys | ||
encrypters = [ | ||
local.gke_sa, | ||
] | ||
decrypters = [ | ||
local.gke_sa, | ||
] | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,3 +69,15 @@ variable "bastion_members" { | |
description = "List of users, groups, SAs who need access to the bastion host" | ||
default = [] | ||
} | ||
|
||
variable "keyring" { | ||
description = "Keyring name." | ||
type = string | ||
default = "gke-keyring" | ||
} | ||
|
||
variable "keys" { | ||
description = "Key names." | ||
type = list(string) | ||
default = ["gke-key"] | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We are transitioning to inline these variables so you can directly provide them in kms.tf There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bharathkkb updated the comment |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can generate this using service identities from the project services module in apis.tf and use the
enabled_api_identities
output to retrieve the sa email.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @bharathkkb Thanks for the response. activate_api_identities requires the api and the role. I can pass the api but what should be the role I need to pass ? Because this service account needs the KMS encrypter/Decrypter role which is taken care at the KMS Module
Something like. this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updating the role at api_identities and removed thee role from KMS module