Skip to content

Commit

Permalink
kms
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Sep 3, 2022
1 parent e7ab441 commit 1a6f353
Show file tree
Hide file tree
Showing 14 changed files with 118 additions and 14 deletions.
6 changes: 6 additions & 0 deletions src/files_gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,9 @@ var googleProjectIamCustomRole []byte

//go:embed mapping/gcp/resource/iam/google_sevice_account.json
var googleServiceAccount []byte

//go:embed mapping/gcp/resource/cloudkms/google_kms_key_ring.json
var googleKmsKeyRing []byte

//go:embed mapping/gcp/resource/cloudkms/google_kms_crypto_key.json
var googleKmsCryptoKey []byte
6 changes: 6 additions & 0 deletions src/files_gcp_datasource.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,9 @@ var dataGoogleComputeZones []byte

//go:embed mapping/gcp/data/resourcemanager/google_project.json
var dataGoogleProject []byte

//go:embed mapping/gcp/data/cloudkms/google_kms_key_ring.json
var dataGoogleKmsKeyRing []byte

//go:embed mapping/gcp/data/cloudkms/google_kms_crypto_key.json
var dataGoogleKmsCryptoKey []byte
2 changes: 2 additions & 0 deletions src/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ func GetGCPResourcePermissions(result ResourceV2) []string {
"google_compute_firewall": googleComputeFirewall,
"google_project_iam_custom_role": googleProjectIamCustomRole,
"google_service_account": googleServiceAccount,
"google_kms_crypto_key": googleKmsCryptoKey,
"google_kms_key_ring": googleKmsKeyRing,
}

var Permissions []string
Expand Down
2 changes: 2 additions & 0 deletions src/gcp_data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ func GetGCPDataPermissions(result ResourceV2) []string {
"google_project": dataGoogleProject,
"google_iam_policy": placeholder,
"google_iam_role": placeholder,
"google_kms_crypto_key": dataGoogleKmsCryptoKey,
"google_kms_key_ring": dataGoogleKmsKeyRing,
}

var Permissions []string
Expand Down
13 changes: 13 additions & 0 deletions src/mapping/gcp/data/cloudkms/google_kms_crypto_key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"cloudkms.cryptoKeys.get"
]
}
]
13 changes: 13 additions & 0 deletions src/mapping/gcp/data/cloudkms/google_kms_key_ring.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"apply": [],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": [
"cloudkms.keyRings.get"
]
}
]
21 changes: 21 additions & 0 deletions src/mapping/gcp/resource/cloudkms/google_kms_crypto_key.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
[
{
"apply": [
"cloudkms.cryptoKeys.create",
"cloudkms.cryptoKeys.get",
"cloudkms.cryptoKeyVersions.list",
"cloudkms.cryptoKeyVersions.destroy",
"cloudkms.cryptoKeys.update"
],
"attributes": {
"tags": []
},
"destroy": [
"cloudkms.cryptoKeyVersions.destroy"
],
"modify": [
"cloudkms.cryptoKeys.update"
],
"plan": []
}
]
14 changes: 14 additions & 0 deletions src/mapping/gcp/resource/cloudkms/google_kms_key_ring.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[
{
"apply": [
"cloudkms.keyRings.create",
"cloudkms.keyRings.get"
],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": []
}
]
8 changes: 8 additions & 0 deletions terraform/gcp/backup/data.google_kms_crypto_key.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
data "google_kms_crypto_key" "pike" {
name = "pike-key-keep"
key_ring = "projects/pike-361314/locations/europe-west1/keyRings/pike"
}

output "pike-key" {
value = data.google_kms_crypto_key.pike
}
9 changes: 9 additions & 0 deletions terraform/gcp/backup/data.google_kms_key_ring.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

data "google_kms_key_ring" "pike" {
name = "pike"
location = "europe-west1"
}

output "ring" {
value = data.google_kms_key_ring.pike
}
16 changes: 16 additions & 0 deletions terraform/gcp/backup/google_kms_crypto_key.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "google_kms_crypto_key" "pike" {
name = "pike-key-keep"
key_ring = "projects/pike-361314/locations/europe-west1/keyRings/pike"
rotation_period = "100000s"

purpose = "ENCRYPT_DECRYPT"
labels = {
"pike" = "permissions"
update = "possible"
}
# destroy_scheduled_duration = "86400s"

# lifecycle {
# prevent_destroy = true
# }
}
7 changes: 7 additions & 0 deletions terraform/gcp/backup/google_kms_key_ring.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_kms_key_ring" "pike" {
name = "pike"
location = "europe-west1"
}

# key rings cannot be deleted
# terraform import google_kms_key_ring.pike projects/pike-361314/locations/europe-west1/keyRings/pike
5 changes: 1 addition & 4 deletions terraform/gcp/role/google_project_iam_custom_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ resource "google_project_iam_custom_role" "pike" {
title = "pike terraform user"
description = "A user with least privileges"
permissions = [
"iam.serviceAccounts.create",
"iam.serviceAccounts.get",
"iam.serviceAccounts.delete",
"iam.serviceAccounts.update"
"cloudkms.cryptoKeys.get"
]
}
10 changes: 0 additions & 10 deletions todo_gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,23 +13,13 @@
google_compute_subnetwork not implemented
google_container_cluster not implemented
google_container_node_pool not implemented
google_kms_crypto_key not implemented
google_kms_key_ring not implemented
google_project_iam_binding not implemented
google_project_iam_binding not implemented
google_project_iam_binding not implemented
google_project_iam_binding not implemented
google_project_iam_binding not implemented
google_project_iam_binding not implemented
google_project_iam_member not implemented
google_project_service not implemented
google_project_service not implemented
google_project_service not implemented
google_project_service not implemented
google_project_service not implemented
google_project_service not implemented
google_project_service not implemented
google_project_service not implemented
google_service_account_iam_policy not implemented
google_service_account_key not implemented
google_service_networking_connection not implemented
Expand Down

0 comments on commit 1a6f353

Please sign in to comment.