Security News
Node.js EOL Versions CVE Dubbed the "Worst CVE of the Year" by Security Experts
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
@serverless/aws-cloudfront
Advanced tools
Deploy an AWS CloudFront distribution for the provided origins using Serverless Components.
$ npm install -g serverless
$ mkdir cdn
$ cd cdn
the directory should look something like this:
|- serverless.yml
|- .env # your AWS api keys
# .env
AWS_ACCESS_KEY_ID=XXX
AWS_SECRET_ACCESS_KEY=XXX
# serverless.yml
distribution:
component: '@serverless/aws-cloudfront'
inputs:
region: us-east-1
enabled: true # optional
comment: 'My distribution' # optional
defaults: # optional
ttl: 15
allowedHttpMethods: ['HEAD', 'GET']
forward: # optional
# array of header names, 'none' or 'all'
headers: ['Accept', 'Accept-Language']
# array of cookie names, 'none' or 'all'
cookies: ['my-cookie]
queryString: true
queryStringCacheKeys: ['queryKey']
viewerProtocolPolicy: 'https-only' # optional
smoothStreaming: true # optional
compress: true # optional
fieldLevelEncryptionId: '123' # optional
lambda@edge: # added to cloudfront default cache behavior
viewer-request: arn:aws:lambda:us-east-1:123:function:myFunc:version
origins:
- https://my-bucket.s3.amazonaws.com
Custom cache behaviors support the same config parameters as the default cache behavior (see the example above).
# serverless.yml
distribution:
component: '@serverless/aws-cloudfront'
inputs:
origins:
- url: https://my-assets.com
pathPatterns:
/static/images: # route any /static/images requests to https://my-assets.com
ttl: 10
allowedHttpMethods: ['GET', 'HEAD'] # optional
forward: # optional
headers: 'all'
cookies: ['auth-token']
queryString: true
compress: false # optional
# ...
# serverless.yml
distribution:
component: '@serverless/aws-cloudfront'
inputs:
origins:
- url: https://sampleorigin.com
pathPatterns:
/sample/path:
ttl: 10
lambda@edge:
viewer-request: arn:aws:lambda:us-east-1:123:function:myFunc:version # lambda ARN including version
To restrict access to content that you serve from S3 you can mark as private
your S3 origins:
# serverless.yml
distribution:
component: '@serverless/aws-cloudfront'
inputs:
origins:
- url: https://my-private-bucket.s3.amazonaws.com
private: true
A bucket policy will be added that grants CloudFront with access to the bucket objects. Note that it doesn't remove any existing permissions on the bucket. If users currently have permission to access the files in your bucket using Amazon S3 URLs you will need to manually remove those.
This is documented in more detail here: https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
$ serverless
Checkout the Serverless Components repo for more information.
FAQs
The npm package @serverless/aws-cloudfront receives a total of 222 weekly downloads. As such, @serverless/aws-cloudfront popularity was classified as not popular.
We found that @serverless/aws-cloudfront demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Critics call the Node.js EOL CVE a misuse of the system, sparking debate over CVE standards and the growing noise in vulnerability databases.
Security News
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.