Skip to content

Commit

Permalink
Changes to pass along all s3 putOption config options.
Browse files Browse the repository at this point in the history
  • Loading branch information
zleight1 authored and Zachary Charles Leighton committed May 24, 2020
1 parent 3ee666c commit 0846e23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ Here are the properties available in the config file:
- `port` (optional): The port to run the import-map-deployer on. Defaults to 5000.
- `region` (optional): The [AWS region](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html) to be used when retrieving and updating the import map.
This can also be specified via the [AWS_DEFAULT_REGION environment variable](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-envvars.html), which is the preferred method.
- `cannedACL` (optional): The [S3 Canned ACL](https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl) to be used when updating the import map.This value should be a string and it is validated against the list of values in the link above. This defaults to 'public-read'.
- `s3.putObject` (optional): The s3.putObject is an object that is merged with the default putObject parameters. This can contain and override any of of the valid request options, such as ACL, encoding, SSE, etc. The sdk options can be found [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#putObject-property).
- `s3Endpoint` (optional): The url for aws-sdk to call when interacting with S3. Defaults to AWS' default domain, but can be configured for
Digital Ocean Spaces or other S3-compatible APIs.
- `readManifest(env)` (optional): A javascript function that will be called to read the import map. One argument is provided, a string `env` indicating
Expand Down
6 changes: 5 additions & 1 deletion examples/ci-for-import-map-deployer/gitlab-aws-ecs/conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ module.exports = {
username: process.env.HTTP_USERNAME,
password: process.env.HTTP_PASSWORD,
region: process.env.AWS_DEFAULT_REGION || "us-east-2",
cannedACL: process.env.AWS_CANNED_ACL || "public-read",
s3: {
putObject: {
ACL: process.env.AWS_CANNED_ACL || "public-read",
},
},
manifestFormat: "importmap",
locations: {
stage: process.env.STAGING_S3_OBJECT_URL,
Expand Down
18 changes: 7 additions & 11 deletions src/io-methods/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ function parseFilePath(filePath) {
};
}

const validCannedACLs = [
// See: https://docs.aws.amazon.com/AmazonS3/latest/dev/acl-overview.html#canned-acl
"private", "public-read", "public-read-write", "aws-exec-read", "authenticated-read",
"bucket-owner-read", "bucket-owner-full-control", "log-delivery-write"
];

let cannedACL = "public-read";
if (config && config.cannedACL && validCannedACLs.indexOf(config.cannedACL) !== -1) {
cannedACL = config.cannedACL;
let s3PutObjectConfig = {};
if (config && config.s3 && config.s3.putObject) {
s3PutObjectConfig = { ...config.s3.putObject };
}

const s3 = new aws.S3({
Expand Down Expand Up @@ -65,7 +59,8 @@ exports.writeManifest = function (filePath, data) {
Body: data,
ContentType: "application/json",
CacheControl: "public, must-revalidate, max-age=0",
ACL: cannedACL,
ACL: "public-read",
...s3PutObjectConfig
},
function (err) {
if (err) reject(err);
Expand All @@ -88,7 +83,8 @@ exports.writeManifest = function (filePath, data) {
Body: jsHelpers.createJsString(data),
ContentType: "application/javascript",
CacheControl: "public, must-revalidate, max-age=0",
ACL: cannedACL,
ACL: "public-read",
...s3PutObjectConfig
},
function (err) {
if (err) reject(err);
Expand Down

0 comments on commit 0846e23

Please sign in to comment.