-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add signed url resources and fields on existing Backends
- Loading branch information
Showing
8 changed files
with
417 additions
and
60 deletions.
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
27 changes: 27 additions & 0 deletions
27
templates/terraform/decoders/backend_signed_url_key.go.erb
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,27 @@ | ||
keyName := d.Get("name").(string) | ||
|
||
policyRaw, ok := res["cdnPolicy"] | ||
if !ok { | ||
return nil, nil | ||
} | ||
|
||
policy := policyRaw.(map[string]interface{}) | ||
keyNames, ok := policy["signedUrlKeyNames"] | ||
if !ok { | ||
keyNames = make([]interface{}, 0) | ||
} | ||
|
||
// Because the sensitive key value is not returned, all we can do is verify a | ||
// key with this name exists and assume the key value hasn't been changed. | ||
for _, k := range keyNames.([]interface{}) { | ||
if keyName == k.(string) { | ||
// Just return empty map to indicate key was found | ||
return map[string]interface{}{}, nil | ||
} | ||
} | ||
|
||
// If not found, the key doesn't exist anymore | ||
log.Printf("[WARN] Removing SignedUrlKey %q because it's gone", d.Id()) | ||
d.SetId("") | ||
|
||
return nil, nil |
17 changes: 17 additions & 0 deletions
17
templates/terraform/examples/backend_bucket_signed_url_key.tf.erb
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 @@ | ||
resource "google_compute_backend_bucket_signed_url_key" "backend_key" { | ||
name = "<%= ctx[:vars]['key_name'] %>" | ||
key_value = "pPsVemX8GM46QVeezid6Rw==" | ||
backend_bucket = "${google_compute_backend_bucket.test_backend.name}" | ||
} | ||
|
||
resource "google_compute_backend_bucket" "test_backend" { | ||
name = "<%= ctx[:vars]['backend_name'] %>" | ||
description = "Contains beautiful images" | ||
bucket_name = "${google_storage_bucket.bucket.name}" | ||
enable_cdn = true | ||
} | ||
|
||
resource "google_storage_bucket" "bucket" { | ||
name = "<%= ctx[:vars]['bucket_name'] %>" | ||
location = "EU" | ||
} |
Oops, something went wrong.