npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

medusa-plugin-aws-storage

v1.0.0

Published

Medusa plugin for AWS storage

Downloads

14

Readme

medusa-plugin-aws-storage

Upload files to an AWS S3 bucket. Optionally serve files through CloudFront.

Options

| Option | Description | Required | Example | |-----------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------|--------------------| | region | AWS region | Yes | us-east-1 | | access_key_id | AWS Access Key ID | Yes | | | secret_access_key | AWS Secret Access Key | Yes | | | s3_bucket | S3 bucket name. This can be omitted if cloud_front_distribution_id is provided and CloudFront distribution has an S3 origin. | Conditionally | | | s3_origin_path | S3 origin. If cloud_front_distribution_id is provided then origin path has to be part of the distribution's S3 origins. If cloud_front_distribution_id is provided and s3_origin_path is not provided, then the distribution's default cache behavior's origin path will be used. Defaults to ''. | | /assets | | s3_upload_options | S3 upload options | | {} | | s3_upload_options.ACL | S3 ACL | | public-read | | s3_upload_options.CacheControl | S3 Cache Control | | max-age=31536000 | | s3_upload_options.ServerSideEncryption | S3 Server Side Encryption | | AES256 | | s3_upload_options.StorageClass | S3 Storage Class | | STANDARD | | cloud_front_distribution_id | CloudFront Distribution ID. Required if s3_bucket is not provided. CloudFront distribution must have an S3 origin. | Conditionally | | | cloud_front_cache_behavior_path_pattern | CloudFront Cache Behavior Path Pattern. Used when other than default cache behavior needs to be used. If not provided, then the default cache behavior will be used. Ignored when cloud_front_distribution_id is not provided. | | images/* | | cloud_front_key_pair_id | CloudFront Key Pair ID. Required if cloud_front_distribution_id is provided and signed URLs will be used. | Conditionally | | | cloud_front_key_private_key | CloudFront Key Private Key. Required if cloud_front_distribution_id is provided and signed URLs will be used. | Conditionally | | | domain_name | Domain name. If cloud_front_distribution_id is provided then domain name has to be part of the distribution's aliases. If cloud_front_distribution_id is provided and domain_name is not provided, then the 1st distribution alias will be used. Defaults to S3 Bucket URL. | | my-domain.com | | download_url_duration | The number of seconds before the signed URL expires | | 3600 | | use_https | Whether to use http or https | | true |

Usage

const plugins = [
  // ...
  {
    resolve: `medusa-plugin-aws-storage`,
    options: {
      region: process.env.S3_REGION,
      access_key_id: process.env.S3_ACCESS_KEY_ID,
      secret_access_key: process.env.S3_SECRET_ACCESS_KEY,
      s3_bucket: process.env.S3_BUCKET,
    },
  },
]

S3 Bucket Policy

{
  "Version": "2012-10-17",
  "Id": "Policy1397632521960",
  "Statement": [
    {
      "Sid": "Stmt1397633323327",
      "Effect": "Allow",
      "Principal": {
        "AWS": "*"
      },
      "Action": "s3:GetObject",
      "Resource": "arn:aws:s3:::<YOUR_BUCKET_NAME>/*"
    }
  ]
}

User Permissions

Your user must have the AmazonS3FullAccess policy attached to it. You can refer to this guide to learn how to add a policy if necessary.

If using CloudFront, your user must have the CloudFrontFullAccess policy attached to it.

CloudFront Signed URLs

Please note the process for creating a signed URL with Cloudfront is very different from the process for S3. For more information, please visit the documentation for restricting CloudFront content with signed URLs and signed cookies.