Add padded url safe base64 encoding b64_url_pad for random_id outputs #352
+19
−1
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.
proposal
I added
b64_url_pad
for random_id outputs.Why
When creating a signed URL for CloudCDN, I used
random_id b64_url
.google_compute_backend_bucket_signed_url_key | Resources | hashicorp/google | Terraform Registry
I have confirmed that this works.
However, when I created them from the Google Cloud console or
gcloud
commanda, the keys created were URL safe, base64 encoded, and padded with=
.Furthermore, the official Google Cloud sample code assumes padded keys, so I could not use the keys created with
b64_url
without modification. In addition, when I tried to create a signed URL using thegcloud compute sign-url
command, an error occurred because it used a key without padding.failed gcloud command
fixed google cloud sample code for golang
Use signed URLs | Cloud CDN | Google Cloud
Change
before
after
Name
At first, I thought of changing the output of b64_url to have padding and creating a new b64_raw_url with no padding.
The reason is that Go code also uses
base64.URLEncoding
to encode those with padding andbase64.RawURLEncoding
for those without padding.The reason for using
b64_url_pad
instead ofb64_raw_url
is to avoid modifying the already usedb64_url
.In the long run, I think it is better to add
b64_raw_url
, but if you accept this PR, I would appreciate your consideration.