Code Monkey home page Code Monkey logo

cloud-rendition-service's Introduction

Cloud Rendition Service

This is an implementation of the blog post found here: https://aws.amazon.com/blogs/networking-and-content-delivery/resizing-images-with-amazon-cloudfront-lambdaedge-aws-cdn-blog/

How To Build The Lambdas?

This command will build the Docker image used to compile nodes and the install and package the Lambda functions in the dist directory

# make docker
# make

How To Deploy?

We first have to create an S3 bucket that will holds the deployment file that were built in the previous step.

# aws s3 mb s3://my-deployment-bucket

Then we use the deploy target:

# DEPLOYMENT_BUCKET=my-deployment-bucket make deploy

Other parameters for the deploy target are:

  • STACK_NAME: Name of the CloudFormation stack that will be deployed
  • IMAGE_BUCKET: Prefix of the S3 bucket where image will uploaded

The deploy target issues a describe stack command at the end:

{
    "Stacks": [
        {
            "StackId": "arn:aws:cloudformation:us-east-1:XXXXXXXXXXXXX:stack/image-resize/aaaaaaaaaaaaaa",
            "DriftInformation": {
                "StackDriftStatus": "NOT_CHECKED"
            },
            "LastUpdatedTime": "2019-10-10T21:41:44.411Z",
            "Tags": [],
            "Outputs": [
                {
                    "ExportName": "image-resize-ImageBucket",
                    "OutputKey": "ImageBucket",
                    "OutputValue": "image-resize-XXXXXXXXXXXXX-us-east-1"
                },
                {
                    "ExportName": "image-resize-",
                    "OutputKey": "CloudFrontDomain",
                    "OutputValue": "xxxxxxxx.cloudfront.net"
                },
                {
                    "ExportName": "image-resize-MyDistribution",
                    "OutputKey": "Distribution",
                    "OutputValue": "XXXXXXXXXXXXX"
                }
            ],
            "EnableTerminationProtection": false,
            "CreationTime": "2019-10-10T20:45:44.728Z",
            "Capabilities": [
                "CAPABILITY_IAM"
            ],
            "StackName": "image-resize",
            "NotificationARNs": [],
            "StackStatus": "UPDATE_COMPLETE",
            "DisableRollback": false,
            "ChangeSetId": "arn:aws:cloudformation:us-east-1:XXXXXXXXXXXXX:changeSet/awscli-cloudformation-package-deploy-xxxxxx",
            "RollbackConfiguration": {}
        }
    ]
}

The important data are in the outputs part.

How To Use?

We first have to upload some pictures in the S3 image bucket (see ImageBucket output of our stack) using whatever tool (S3 sync, S3 copy...).

# aws s3 cp mypicture.png s3://image-resize-XXXXXXXXXXXXX-us-east-1/images/mypicture.png

Then we can access that picture with the CloudFront domain that has been create (see CloudFrontDomain of our stack).

# wget https://xxxxxx.cloudfront.net/images/mypicture.png

If we want a resized versions:

# wget https://xxxxxx.cloudfront.net/images/mypicture.png?d=100x100

cloud-rendition-service's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.