Skip to content

Commit

Permalink
storage resources
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesWoolfenden committed Sep 3, 2022
1 parent 1a6f353 commit 8475b1a
Show file tree
Hide file tree
Showing 8 changed files with 67 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 @@ -33,3 +33,9 @@ var googleKmsKeyRing []byte

//go:embed mapping/gcp/resource/cloudkms/google_kms_crypto_key.json
var googleKmsCryptoKey []byte

//go:embed mapping/gcp/resource/storage/google_storage_bucket_acl.json
var googleStorageBucketAcl []byte

//go:embed mapping/gcp/resource/storage/google_storage_bucket_iam_binding.json
var googleStorageBucketIamBinding []byte
22 changes: 12 additions & 10 deletions src/gcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,18 @@ func GetGCPPermissions(result ResourceV2) []string {
// GetGCPResourcePermissions looks up permissions required for resources
func GetGCPResourcePermissions(result ResourceV2) []string {
TFLookup := map[string]interface{}{
"google_compute_instance": googleComputeInstance,
"google_storage_bucket": googleStorageBucket,
"google_storage_bucket_object": googleStorageBucketObject,
"google_compute_network": googleComputeNetwork,
"google_compute_address": googleComputeAddress,
"google_compute_firewall": googleComputeFirewall,
"google_project_iam_custom_role": googleProjectIamCustomRole,
"google_service_account": googleServiceAccount,
"google_kms_crypto_key": googleKmsCryptoKey,
"google_kms_key_ring": googleKmsKeyRing,
"google_compute_instance": googleComputeInstance,
"google_storage_bucket": googleStorageBucket,
"google_storage_bucket_object": googleStorageBucketObject,
"google_compute_network": googleComputeNetwork,
"google_compute_address": googleComputeAddress,
"google_compute_firewall": googleComputeFirewall,
"google_project_iam_custom_role": googleProjectIamCustomRole,
"google_service_account": googleServiceAccount,
"google_kms_crypto_key": googleKmsCryptoKey,
"google_kms_key_ring": googleKmsKeyRing,
"google_storage_bucket_acl": googleStorageBucketAcl,
"google_storage_bucket_iam_binding": googleStorageBucketIamBinding,
}

var Permissions []string
Expand Down
15 changes: 15 additions & 0 deletions src/mapping/gcp/resource/storage/google_storage_bucket_acl.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[
{
"apply": [
"storage.buckets.get",
"storage.buckets.update",
"storage.buckets.setIamPolicy"
],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": []
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"apply": [
"storage.buckets.get",
"storage.buckets.update",
"storage.buckets.getIamPolicy",
"storage.buckets.setIamPolicy"
],
"attributes": {
"tags": []
},
"destroy": [],
"modify": [],
"plan": []
}
]
5 changes: 5 additions & 0 deletions terraform/gcp/backup/google_storage_bucket_acl.bucket-acl.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
resource "google_storage_bucket_acl" "bucketacl" {
bucket = "test-bucket-jgw-today"

predefined_acl = "projectprivate"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "google_storage_bucket_iam_binding" "binding" {
bucket = "test-bucket-jgw-today"
role = "roles/storage.admin"
members = [
"user:james.woolfenden@gmail.com",
"serviceAccount:pike-service@pike-361314.iam.gserviceaccount.com"
]

}
5 changes: 4 additions & 1 deletion terraform/gcp/role/google_project_iam_custom_role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ resource "google_project_iam_custom_role" "pike" {
title = "pike terraform user"
description = "A user with least privileges"
permissions = [
"cloudkms.cryptoKeys.get"
"storage.buckets.get",
"storage.buckets.update",
"storage.buckets.getIamPolicy",
"storage.buckets.setIamPolicy"
]
}
3 changes: 0 additions & 3 deletions todo_gcp.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,3 @@
google_sql_database not implemented
google_sql_database_instance not implemented
google_sql_user not implemented
google_storage_bucket_acl not implemented
google_storage_bucket_acl not implemented
google_storage_bucket_iam_binding not implemented

0 comments on commit 8475b1a

Please sign in to comment.