GCP の LB でのリダイレクトの設定方法のメモ。
https://aaa.abc.com/ 配下のページを https://www.abc.com/aaa/ にリダイレクトする設定例。
aaa.abc.com の LB の設定の pathRules: に以下を追記
- paths: - /* urlRedirect: hostRedirect: www.abc.com prefixRedirect: /aaa/
GCP の LB でのリダイレクトの設定方法のメモ。
https://aaa.abc.com/ 配下のページを https://www.abc.com/aaa/ にリダイレクトする設定例。
aaa.abc.com の LB の設定の pathRules: に以下を追記
- paths: - /* urlRedirect: hostRedirect: www.abc.com prefixRedirect: /aaa/
Cloud Armor で Basic 認証を行う方法のメモ。
Cloud Armor のルールで、リクエストヘッダーの Authentication に指定された文字列が所定のID、パスワードからなる文字列になっていることを確認し、確認できなかった場合には拒否する。
Authorization は以下の形式の文字列となっている。
Authorization: Basic {base64encode(“{ユーザ}:{パスワード}”)}
ユーザ=user、パスワード=password の場合、以下のコマンドで base64 の文字列を生成することができる。
$ echo -n "user:password" | base64 dXNlcjpwYXNzd29yZA==
/auth ディレクトリに上記のユーザ、パスワードで Basic 認証をかける場合には、以下の拒否ルールを設定する。
request.path.matches('^/auth/') && (! has(request.headers['Authorization']) || request.headers['Authorization'] != 'Basic dXNlcjpwYXNzd29yZA==')
gcloud auth login
Go to the following link in your browser: https://accounts.google.com/o/oauth2/auth?...
gcloud auth application-default login
create table `items` ( item_id string, store_id string, stock integer );
create table `item_store_infos` ( item_id string, store_infos array< struct< store_id string, stock integer > > );
insert into `item_store_infos` (item_id, store_infos) select item_id , store_infos from ( select item_id , array_agg(store_info) as store_infos from ( select item_id, struct(store_id, stock) as store_info from `itmes` ) s group by item_id );
gcloud sql import csv \ {cloud_sql_instance_id} \ gs://{bucket}/{file.tsv} \ --database={database_name} \ --table={table_name} \ --fields-terminated-by="09" \ --lines-terminated-by="0A"
select array(select cast(e as float64) from unnest(split("1, 2, 3", ",")) e) as vector ;
insert into tbl values ('item_01', 'store_01', 100); insert into tbl values ('item_01', 'store_02', 110); insert into tbl values ('item_01', 'store_03', 120); insert into tbl values ('item_02', 'store_01', 200); insert into tbl values ('item_02', 'store_02', 210); insert into tbl values ('item_02', 'store_03', 220); insert into tbl values ('item_03', 'store_04', 300);
select item_id , array_agg(store_info) from ( select item_id , struct(store_cd, price) as store_info from tbl ) group by item_id ;
{"item_id": "item_01", "store_infos": [{ "store_cd": "store_03", "price": "120"}, {"store_cd": "store_01", "price": "100"}, {"store_cd": "store_02", "price": "110"}]} {"item_id": "item_02", "store_infos": [{"store_cd": "store_02", "price": "210"}, {"store_cd": "store_03", "price": "220"}, { "store_cd": "store_01", "price": "200"}]} {"item_id": "item_03", "store_infos": [{"store_cd": "store_04", "price": "300"}]}
insert into `test1.tbl1` (json) values (''' {"type": "search", "uid": "004", "kw": "フライパン", "items": [ {"rank": 1, "id": "001", "title": "商品1"}, {"rank": 2, "id": "002", "title": "商品2"}, {"rank": 3, "id": "003", "title": "商品3"} ]} '''); insert into `test1.tbl1` (json) values (''' {"type": "search", "uid": "004", "kw": "鍋", "items": [ {"rank": 1, "id": "002", "title": "商品2"}, {"rank": 2, "id": "003", "title": "商品3"}, {"rank": 3, "id": "004", "title": "商品4"} ]} ''');
select json_extract_scalar(t1.json, "$.kw") as kw , json_value(item, "$.id") as id from `test1.tbl1` as t1 left join unnest(json_query_array(json_extract(t1.json, "$.items"))) as item where json_extract_scalar(t1.json, "$.type") = "search" ;
行 kw id 1 フライパン 001 2 フライパン 002 3 フライパン 003 4 鍋 002 5 鍋 003 6 鍋 004