Skip to content

Commit a057d1a

Browse files
committed
S3 support
1 parent 03150e1 commit a057d1a

21 files changed

+5168
-988
lines changed

package-lock.json

Lines changed: 4006 additions & 941 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@
4040
},
4141
"homepage": "https://github.com/fastly/compute-js-static-publish#readme",
4242
"dependencies": {
43+
"@aws-sdk/client-s3": "^3.882.0",
44+
"@aws-sdk/credential-providers": "^3.883.0",
4345
"@fastly/cli": "^11.2.0",
4446
"command-line-args": "^5.2.1",
4547
"glob-to-regexp": "^0.4.1",

src/cli/commands/manage/clean.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ KV Store Options:
3939
1. FASTLY_API_TOKEN environment variable
4040
2. Logged-in Fastly CLI profile
4141
42+
S3 Storage Options:
43+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
44+
--aws-secret-access-key=<key> interface with S3.
45+
If not set, the tool will check:
46+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
47+
environment variables
48+
2. The aws credentials file, see below
49+
50+
--aws-profile=<profile> Profile within the aws credentials file.
51+
If not set, the tool will check:
52+
1. AWS_PROFILE environment variable
53+
2. The default profile, if set
54+
4255
Global Options:
4356
-h, --help Show this help message and exit.
4457
`);
@@ -54,6 +67,10 @@ export async function action(actionArgs: string[]) {
5467

5568
{ name: 'local', type: Boolean },
5669
{ name: 'fastly-api-token', type: String, },
70+
71+
{ name: 'aws-profile', type: String, },
72+
{ name: 'aws-access-key-id', type: String, },
73+
{ name: 'aws-secret-access-key', type: String, },
5774
];
5875

5976
const parsed = parseCommandLine(actionArgs, optionDefinitions);
@@ -74,6 +91,9 @@ export async function action(actionArgs: string[]) {
7491
['dry-run']: dryRun,
7592
local: localMode,
7693
['fastly-api-token']: fastlyApiToken,
94+
['aws-profile']: awsProfile,
95+
['aws-access-key-id']: awsAccessKeyId,
96+
['aws-secret-access-key']: awsSecretAccessKey,
7797
} = parsed.commandLineOptions;
7898

7999
// compute-js-static-publisher cli is always run from the Compute application directory
@@ -110,10 +130,13 @@ export async function action(actionArgs: string[]) {
110130
// Storage Provider
111131
let storageProvider;
112132
try {
113-
storageProvider = loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
133+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
114134
computeAppDir,
115135
localMode,
116136
fastlyApiToken,
137+
awsProfile,
138+
awsAccessKeyId,
139+
awsSecretAccessKey,
117140
});
118141
} catch (err: unknown) {
119142
console.error(`❌ Could not instantiate store provider`);

src/cli/commands/manage/collections/delete.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ KV Store Options:
3737
1. FASTLY_API_TOKEN environment variable
3838
2. Logged-in Fastly CLI profile
3939
40+
S3 Storage Options:
41+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
42+
--aws-secret-access-key=<key> interface with S3.
43+
If not set, the tool will check:
44+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
45+
environment variables
46+
2. The aws credentials file, see below
47+
48+
--aws-profile=<profile> Profile within the aws credentials file.
49+
If not set, the tool will check:
50+
1. AWS_PROFILE environment variable
51+
2. The default profile, if set
52+
4053
Global Options:
4154
-h, --help Show this help message and exit.
4255
`);
@@ -51,6 +64,10 @@ export async function action(actionArgs: string[]) {
5164

5265
{ name: 'local', type: Boolean },
5366
{ name: 'fastly-api-token', type: String, },
67+
68+
{ name: 'aws-profile', type: String, },
69+
{ name: 'aws-access-key-id', type: String, },
70+
{ name: 'aws-secret-access-key', type: String, },
5471
];
5572

5673
const parsed = parseCommandLine(actionArgs, optionDefinitions);
@@ -70,6 +87,9 @@ export async function action(actionArgs: string[]) {
7087
['collection-name']: collectionNameValue,
7188
['fastly-api-token']: fastlyApiToken,
7289
local: localMode,
90+
['aws-profile']: awsProfile,
91+
['aws-access-key-id']: awsAccessKeyId,
92+
['aws-secret-access-key']: awsSecretAccessKey,
7393
} = parsed.commandLineOptions;
7494

7595
// compute-js-static-publisher cli is always run from the Compute application directory
@@ -112,10 +132,13 @@ export async function action(actionArgs: string[]) {
112132
// Storage Provider
113133
let storageProvider;
114134
try {
115-
storageProvider = loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
135+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
116136
computeAppDir,
117137
localMode,
118138
fastlyApiToken,
139+
awsProfile,
140+
awsAccessKeyId,
141+
awsSecretAccessKey,
119142
});
120143
} catch (err: unknown) {
121144
console.error(`❌ Could not instantiate store provider`);

src/cli/commands/manage/collections/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,19 @@ KV Store Options:
3535
1. FASTLY_API_TOKEN environment variable
3636
2. Logged-in Fastly CLI profile
3737
38+
S3 Storage Options:
39+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
40+
--aws-secret-access-key=<key> interface with S3.
41+
If not set, the tool will check:
42+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
43+
environment variables
44+
2. The aws credentials file, see below
45+
46+
--aws-profile=<profile> Profile within the aws credentials file.
47+
If not set, the tool will check:
48+
1. AWS_PROFILE environment variable
49+
2. The default profile, if set
50+
3851
Global Options:
3952
-h, --help Show this help message and exit.
4053

src/cli/commands/manage/collections/list.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,19 @@ KV Store Options:
3232
1. FASTLY_API_TOKEN environment variable
3333
2. Logged-in Fastly CLI profile
3434
35+
S3 Storage Options:
36+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
37+
--aws-secret-access-key=<key> interface with S3.
38+
If not set, the tool will check:
39+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
40+
environment variables
41+
2. The aws credentials file, see below
42+
43+
--aws-profile=<profile> Profile within the aws credentials file.
44+
If not set, the tool will check:
45+
1. AWS_PROFILE environment variable
46+
2. The default profile, if set
47+
3548
Global Options:
3649
-h, --help Show this help message and exit.
3750
`);
@@ -44,6 +57,10 @@ export async function action(actionArgs: string[]) {
4457

4558
{ name: 'local', type: Boolean },
4659
{ name: 'fastly-api-token', type: String, },
60+
61+
{ name: 'aws-profile', type: String, },
62+
{ name: 'aws-access-key-id', type: String, },
63+
{ name: 'aws-secret-access-key', type: String, },
4764
];
4865

4966
const parsed = parseCommandLine(actionArgs, optionDefinitions);
@@ -62,6 +79,9 @@ export async function action(actionArgs: string[]) {
6279
verbose,
6380
local: localMode,
6481
['fastly-api-token']: fastlyApiToken,
82+
['aws-profile']: awsProfile,
83+
['aws-access-key-id']: awsAccessKeyId,
84+
['aws-secret-access-key']: awsSecretAccessKey,
6585
} = parsed.commandLineOptions;
6686

6787
// compute-js-static-publisher cli is always run from the Compute application directory
@@ -98,10 +118,13 @@ export async function action(actionArgs: string[]) {
98118
// Storage Provider
99119
let storageProvider;
100120
try {
101-
storageProvider = loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
121+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
102122
computeAppDir,
103123
localMode,
104124
fastlyApiToken,
125+
awsProfile,
126+
awsAccessKeyId,
127+
awsSecretAccessKey,
105128
});
106129
} catch (err: unknown) {
107130
console.error(`❌ Could not instantiate store provider`);

src/cli/commands/manage/collections/promote.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,19 @@ KV Store Options:
5454
1. FASTLY_API_TOKEN environment variable
5555
2. Logged-in Fastly CLI profile
5656
57+
S3 Storage Options:
58+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
59+
--aws-secret-access-key=<key> interface with S3.
60+
If not set, the tool will check:
61+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
62+
environment variables
63+
2. The aws credentials file, see below
64+
65+
--aws-profile=<profile> Profile within the aws credentials file.
66+
If not set, the tool will check:
67+
1. AWS_PROFILE environment variable
68+
2. The default profile, if set
69+
5770
Global Options:
5871
-h, --help Show this help message and exit.
5972
`);
@@ -73,6 +86,10 @@ export async function action(actionArgs: string[]) {
7386

7487
{ name: 'local', type: Boolean },
7588
{ name: 'fastly-api-token', type: String, },
89+
90+
{ name: 'aws-profile', type: String, },
91+
{ name: 'aws-access-key-id', type: String, },
92+
{ name: 'aws-secret-access-key', type: String, },
7693
];
7794

7895
const parsed = parseCommandLine(actionArgs, optionDefinitions);
@@ -96,6 +113,9 @@ export async function action(actionArgs: string[]) {
96113
['expires-never']: expiresNever,
97114
local: localMode,
98115
['fastly-api-token']: fastlyApiToken,
116+
['aws-profile']: awsProfile,
117+
['aws-access-key-id']: awsAccessKeyId,
118+
['aws-secret-access-key']: awsSecretAccessKey,
99119
} = parsed.commandLineOptions;
100120

101121
// compute-js-static-publisher cli is always run from the Compute application directory
@@ -154,10 +174,13 @@ export async function action(actionArgs: string[]) {
154174
// Storage Provider
155175
let storageProvider;
156176
try {
157-
storageProvider = loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
177+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
158178
computeAppDir,
159179
localMode,
160180
fastlyApiToken,
181+
awsProfile,
182+
awsAccessKeyId,
183+
awsSecretAccessKey,
161184
});
162185
} catch (err: unknown) {
163186
console.error(`❌ Could not instantiate store provider`);

src/cli/commands/manage/collections/update-expiration.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,19 @@ KV Store Options:
5050
1. FASTLY_API_TOKEN environment variable
5151
2. Logged-in Fastly CLI profile
5252
53+
S3 Storage Options:
54+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
55+
--aws-secret-access-key=<key> interface with S3.
56+
If not set, the tool will check:
57+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
58+
environment variables
59+
2. The aws credentials file, see below
60+
61+
--aws-profile=<profile> Profile within the aws credentials file.
62+
If not set, the tool will check:
63+
1. AWS_PROFILE environment variable
64+
2. The default profile, if set
65+
5366
Global Options:
5467
-h, --help Show this help message and exit.
5568
`);
@@ -68,6 +81,10 @@ export async function action(actionArgs: string[]) {
6881

6982
{ name: 'local', type: Boolean },
7083
{ name: 'fastly-api-token', type: String, },
84+
85+
{ name: 'aws-profile', type: String, },
86+
{ name: 'aws-access-key-id', type: String, },
87+
{ name: 'aws-secret-access-key', type: String, },
7188
];
7289

7390
const parsed = parseCommandLine(actionArgs, optionDefinitions);
@@ -90,6 +107,9 @@ export async function action(actionArgs: string[]) {
90107
['expires-never']: expiresNever,
91108
local: localMode,
92109
['fastly-api-token']: fastlyApiToken,
110+
['aws-profile']: awsProfile,
111+
['aws-access-key-id']: awsAccessKeyId,
112+
['aws-secret-access-key']: awsSecretAccessKey,
93113
} = parsed.commandLineOptions;
94114

95115
// compute-js-static-publisher cli is always run from the Compute application directory
@@ -147,10 +167,13 @@ export async function action(actionArgs: string[]) {
147167
// Storage Provider
148168
let storageProvider;
149169
try {
150-
storageProvider = loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
170+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
151171
computeAppDir,
152172
localMode,
153173
fastlyApiToken,
174+
awsProfile,
175+
awsAccessKeyId,
176+
awsSecretAccessKey,
154177
});
155178
} catch (err: unknown) {
156179
console.error(`❌ Could not instantiate store provider`);

src/cli/commands/manage/index.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@ KV Store Options:
3737
1. FASTLY_API_TOKEN environment variable
3838
2. Logged-in Fastly CLI profile
3939
40+
S3 Storage Options:
41+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
42+
--aws-secret-access-key=<key> interface with S3.
43+
If not set, the tool will check:
44+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
45+
environment variables
46+
2. The aws credentials file, see below
47+
48+
--aws-profile=<profile> Profile within the aws credentials file.
49+
If not set, the tool will check:
50+
1. AWS_PROFILE environment variable
51+
2. The default profile, if set
52+
4053
Global Options:
4154
-h, --help Show this help message and exit.
4255

src/cli/commands/manage/publish-content.ts

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,19 @@ KV Store Options:
8181
8282
--kv-overwrite Alias for --overwrite-existing.
8383
84+
S3 Storage Options:
85+
--aws-access-key-id=<key> AWS Access Key ID and Secret Access Key used to
86+
--aws-secret-access-key=<key> interface with S3.
87+
If not set, the tool will check:
88+
1. AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
89+
environment variables
90+
2. The aws credentials file, see below
91+
92+
--aws-profile=<profile> Profile within the aws credentials file.
93+
If not set, the tool will check:
94+
1. AWS_PROFILE environment variable
95+
2. The default profile, if set
96+
8497
Global Options:
8598
-h, --help Show this help message and exit.
8699
@@ -109,6 +122,10 @@ export async function action(actionArgs: string[]) {
109122
{ name: 'local', type: Boolean },
110123
{ name: 'fastly-api-token', type: String, },
111124
{ name: 'kv-overwrite', type: Boolean },
125+
126+
{ name: 'aws-profile', type: String, },
127+
{ name: 'aws-access-key-id', type: String, },
128+
{ name: 'aws-secret-access-key', type: String, },
112129
];
113130

114131
const parsed = parseCommandLine(actionArgs, optionDefinitions);
@@ -135,6 +152,9 @@ export async function action(actionArgs: string[]) {
135152
local: localMode,
136153
['fastly-api-token']: fastlyApiToken,
137154
['kv-overwrite']: _kvOverwrite,
155+
['aws-profile']: awsProfile,
156+
['aws-access-key-id']: awsAccessKeyId,
157+
['aws-secret-access-key']: awsSecretAccessKey,
138158
} = parsed.commandLineOptions;
139159

140160
const overwriteExisting = _overwriteExisting ?? _kvOverwrite;
@@ -210,10 +230,13 @@ export async function action(actionArgs: string[]) {
210230
// Storage Provider
211231
let storageProvider: any;
212232
try {
213-
storageProvider = loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
233+
storageProvider = await loadStorageProviderFromStaticPublishRc(staticPublisherRc, {
214234
computeAppDir,
215235
localMode,
216236
fastlyApiToken,
237+
awsProfile,
238+
awsAccessKeyId,
239+
awsSecretAccessKey,
217240
});
218241
} catch (err: unknown) {
219242
console.error(`❌ Could not instantiate store provider`);

0 commit comments

Comments
 (0)