Skip to content
This repository has been archived by the owner on Nov 14, 2024. It is now read-only.

Add backend bucket signed URL key (for CDN) support #127

Merged
merged 1 commit into from
Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docs/resources/google_compute_backend_bucket.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ Properties that can be accessed from the `google_compute_backend_bucket` resourc

* `bucket_name`: Cloud Storage bucket name.

* `cdn_policy`: Cloud CDN configuration for this Backend Bucket.

* `signed_url_cache_max_age_sec`: Maximum number of seconds the response to a signed URL request will be considered fresh. Defaults to 1hr (3600s). After this time period, the response will be revalidated before being served. When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered.

* `creation_timestamp`: Creation timestamp in RFC3339 text format.

* `description`: An optional textual description of the resource; provided by the client when the resource is created.
Expand Down
1 change: 1 addition & 0 deletions docs/resources/google_compute_backend_buckets.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ Properties that can be accessed from the `google_compute_backend_buckets` resour

See [google_compute_backend_bucket.md](google_compute_backend_bucket.md) for more detailed information
* `bucket_names`: an array of `google_compute_backend_bucket` bucket_name
* `cdn_policies`: an array of `google_compute_backend_bucket` cdn_policy
* `creation_timestamps`: an array of `google_compute_backend_bucket` creation_timestamp
* `descriptions`: an array of `google_compute_backend_bucket` description
* `enable_cdns`: an array of `google_compute_backend_bucket` enable_cdn
Expand Down
2 changes: 2 additions & 0 deletions docs/resources/google_compute_backend_service.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ Properties that can be accessed from the `google_compute_backend_service` resour

* `cache_key_policy`: The CacheKeyPolicy for this CdnPolicy.

* `signed_url_cache_max_age_sec`: Maximum number of seconds the response to a signed URL request will be considered fresh, defaults to 1hr (3600s). After this time period, the response will be revalidated before being served. When serving responses to signed URL requests, Cloud CDN will internally behave as though all responses from this backend had a "Cache-Control: public, max-age=[TTL]" header, regardless of any existing Cache-Control header. The actual headers served in responses will not be altered.

* `connection_draining`: Settings for connection draining

* `draining_timeout_sec`: Time for which instance will be drained (not accept new connections, but still work to finish started).
Expand Down
34 changes: 34 additions & 0 deletions libraries/google/compute/property/backendbucket_cdn_policy.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# frozen_string_literal: false

# ----------------------------------------------------------------------------
#
# *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
#
# ----------------------------------------------------------------------------
#
# This file is automatically generated by Magic Modules and manual
# changes will be clobbered when the file is regenerated.
#
# Please read more about how to change this file in README.md and
# CONTRIBUTING.md located at the root of this package.
#
# ----------------------------------------------------------------------------
module GoogleInSpec
module Compute
module Property
class BackendBucketCdnPolicy
attr_reader :signed_url_cache_max_age_sec

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@signed_url_cache_max_age_sec = args['signedUrlCacheMaxAgeSec']
end

def to_s
"#{@parent_identifier} BackendBucketCdnPolicy"
end
end
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ module Property
class BackendServiceCdnPolicy
attr_reader :cache_key_policy

attr_reader :signed_url_cache_max_age_sec

def initialize(args = nil, parent_identifier = nil)
return if args.nil?
@parent_identifier = parent_identifier
@cache_key_policy = GoogleInSpec::Compute::Property::BackendServiceCdnPolicyCacheKeyPolicy.new(args['cacheKeyPolicy'], to_s)
@signed_url_cache_max_age_sec = args['signedUrlCacheMaxAgeSec']
end

def to_s
Expand Down
3 changes: 3 additions & 0 deletions libraries/google_compute_backend_bucket.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#
# ----------------------------------------------------------------------------
require 'gcp_backend'
require 'google/compute/property/backendbucket_cdn_policy'

# A provider to manage Compute Engine resources.
class BackendBucket < GcpResourceBase
Expand All @@ -23,6 +24,7 @@ class BackendBucket < GcpResourceBase

attr_reader :params
attr_reader :bucket_name
attr_reader :cdn_policy
attr_reader :creation_timestamp
attr_reader :description
attr_reader :enable_cdn
Expand All @@ -38,6 +40,7 @@ def initialize(params)

def parse
@bucket_name = @fetched['bucketName']
@cdn_policy = GoogleInSpec::Compute::Property::BackendBucketCdnPolicy.new(@fetched['cdnPolicy'], to_s)
@creation_timestamp = parse_time_string(@fetched['creationTimestamp'])
@description = @fetched['description']
@enable_cdn = @fetched['enableCdn']
Expand Down
2 changes: 2 additions & 0 deletions libraries/google_compute_backend_buckets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class BackendBuckets < GcpResourceBase
filter_table_config = FilterTable.create

filter_table_config.add(:bucket_names, field: :bucket_name)
filter_table_config.add(:cdn_policies, field: :cdn_policy)
filter_table_config.add(:creation_timestamps, field: :creation_timestamp)
filter_table_config.add(:descriptions, field: :description)
filter_table_config.add(:enable_cdns, field: :enable_cdn)
Expand Down Expand Up @@ -69,6 +70,7 @@ def transform(key, value)
def transformers
{
'bucketName' => ->(obj) { return :bucket_name, obj['bucketName'] },
'cdnPolicy' => ->(obj) { return :cdn_policy, GoogleInSpec::Compute::Property::BackendBucketCdnPolicy.new(obj['cdnPolicy'], to_s) },
'creationTimestamp' => ->(obj) { return :creation_timestamp, parse_time_string(obj['creationTimestamp']) },
'description' => ->(obj) { return :description, obj['description'] },
'enableCdn' => ->(obj) { return :enable_cdn, obj['enableCdn'] },
Expand Down