Skip to content

Commit aa5bd47

Browse files
committed
JavaScript (v3): S3 - Replace hard coded bucket names with env vars or allowable name.
1 parent 4f4aeff commit aa5bd47

31 files changed

+38
-49
lines changed

javascriptv3/example_code/s3/actions/copy-object.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,28 +54,28 @@ export const main = async ({
5454
// snippet-end:[s3.JavaScript.buckets.copyObjectV3]
5555

5656
// Call function if run directly
57-
import { fileURLToPath } from "url";
5857
import { parseArgs } from "util";
58+
import { isMain } from "@aws-doc-sdk-examples/lib/utils/util-node.js";
5959

60-
if (process.argv[1] === fileURLToPath(import.meta.url)) {
60+
const loadArgs = () => {
6161
const options = {
62-
sourceBucket: {
62+
sourceBucketName: {
6363
type: "string",
64-
default: "source-bucket",
6564
},
6665
sourceKey: {
6766
type: "string",
68-
default: "todo.txt",
6967
},
7068
destinationBucket: {
7169
type: "string",
72-
default: "destination-bucket",
7370
},
7471
destinationKey: {
7572
type: "string",
76-
default: "todo.txt",
7773
},
7874
};
79-
const { values } = parseArgs({ options });
75+
return parseArgs({ options });
76+
};
77+
78+
if (isMain(import.meta.url)) {
79+
const { values } = loadArgs();
8080
main(values);
8181
}

javascriptv3/example_code/s3/actions/create-bucket.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
5656
const options = {
5757
bucketName: {
5858
type: "string",
59-
default: "bucket-name",
6059
},
6160
};
6261
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/delete-bucket-policy.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
4949
const options = {
5050
bucketName: {
5151
type: "string",
52-
default: "amzn-s3-demo-bucket",
5352
},
5453
};
5554
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/delete-bucket-website.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
5353
const options = {
5454
bucketName: {
5555
type: "string",
56-
default: "amzn-s3-demo-bucket",
5756
},
5857
};
5958
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/delete-object.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
5959
const options = {
6060
bucketName: {
6161
type: "string",
62-
default: "amzn-s3-demo-bucket",
6362
},
6463
key: {
6564
type: "string",
66-
default: "todo.txt",
6765
},
6866
};
6967
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/delete-objects.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
6767
const options = {
6868
bucketName: {
6969
type: "string",
70-
default: "amzn-s3-demo-bucket",
7170
},
7271
};
7372
const { values, positionals } = parseArgs({

javascriptv3/example_code/s3/actions/get-bucket-acl.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
5050
const options = {
5151
bucketName: {
5252
type: "string",
53-
default: "amzn-s3-demo-bucket",
5453
},
5554
};
5655
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/get-bucket-cors.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
6060
const options = {
6161
bucketName: {
6262
type: "string",
63-
default: "amzn-s3-demo-bucket",
6463
},
6564
};
6665
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/get-bucket-policy.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
4949
const options = {
5050
bucketName: {
5151
type: "string",
52-
default: "amzn-s3-demo-bucket",
5352
},
5453
};
5554
const { values } = parseArgs({ options });

javascriptv3/example_code/s3/actions/get-bucket-website.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ if (process.argv[1] === fileURLToPath(import.meta.url)) {
5151
const options = {
5252
bucketName: {
5353
type: "string",
54-
default: "amzn-s3-demo-bucket",
5554
},
5655
};
5756
const { values } = parseArgs({ options });

0 commit comments

Comments
 (0)