Skip to content
This repository was archived by the owner on Feb 15, 2020. It is now read-only.

Commit 3613cad

Browse files
committed
Add storage class option to s3 output
1 parent f542abb commit 3613cad

1 file changed

Lines changed: 17 additions & 6 deletions

File tree

hindsight/output/telemetry_s3.lua

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,12 @@ preserve_data = not flush_on_shutdown -- should always be the inverse of f
4343
s3_path = "s3://foo"
4444
4545
compression = "zst"
46+
47+
-- The type of storage to use for the object.
48+
-- Valid choices are: STANDARD | REDUCED_REDUNDANCY | STANDARD_IA
49+
-- (default "STANDARD")
50+
storage_class = "STANDARD"
51+
4652
```
4753
--]]
4854

@@ -70,6 +76,11 @@ if compression and compression ~= "zst" and compression ~= "gz" then
7076
error("compression must be nil, zst or gz")
7177
end
7278

79+
local storage_class = read_config("storage_class") or "STANDARD"
80+
if storage_class and storage_class ~= "STANDARD" and
81+
storage_class ~= "REDUCED_REDUNDANCY" and storage_class ~= "STANDARD_IA" then
82+
error("storage_class must be STANDARD, REDUCED_REDUNDANCY or STANDARD_IA")
83+
end
7384

7485
local function get_fqfn(path)
7586
return string.format("%s/%s", batch_path, path)
@@ -98,14 +109,14 @@ local function copy_file(path, entry)
98109
local src = get_fqfn(path)
99110
local dim_path = string.gsub(path, "+", "/")
100111
if compression == "zst" then
101-
cmd = string.format("zstd -c %s | aws s3 cp - %s/%s/%d_%d_%s.%s", src,
102-
s3_path, dim_path, time_t, buffer_cnt, hostname, compression)
112+
cmd = string.format("zstd -c %s | aws s3 cp --storage-class %s - %s/%s/%d_%d_%s.%s", src,
113+
storage_class, s3_path, dim_path, time_t, buffer_cnt, hostname, compression)
103114
elseif compression == "gz" then
104-
cmd = string.format("gzip -c %s | aws s3 cp - %s/%s/%d_%d_%s.%s", src,
105-
s3_path, dim_path, time_t, buffer_cnt, hostname, compression)
115+
cmd = string.format("gzip -c %s | aws s3 cp --storage-class %s - %s/%s/%d_%d_%s.%s", src,
116+
storage_class, s3_path, dim_path, time_t, buffer_cnt, hostname, compression)
106117
else
107-
cmd = string.format("aws s3 cp %s %s/%s/%d_%d_%s", src,
108-
s3_path, dim_path, time_t, buffer_cnt, hostname)
118+
cmd = string.format("aws s3 cp %s --storage-class %s %s/%s/%d_%d_%s", src,
119+
storage_class, s3_path, dim_path, time_t, buffer_cnt, hostname)
109120
end
110121

111122
print(cmd)

0 commit comments

Comments
 (0)