From cb0a642e567153f0d604779c0dec57249e187136 Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 16:49:35 -0500 Subject: [PATCH 1/7] adding the three stage CloudFormation stack and a brief readme in MarkDown --- cloudformation/README.md | 10 ++ cloudformation/README.md~ | 5 + cloudformation/aws-lambda-image-1.template | 134 +++++++++++++++ cloudformation/aws-lambda-image-2.template | 183 +++++++++++++++++++++ cloudformation/aws-lambda-image-3.template | 183 +++++++++++++++++++++ 5 files changed, 515 insertions(+) create mode 100644 cloudformation/README.md create mode 100644 cloudformation/README.md~ create mode 100644 cloudformation/aws-lambda-image-1.template create mode 100644 cloudformation/aws-lambda-image-2.template create mode 100644 cloudformation/aws-lambda-image-3.template diff --git a/cloudformation/README.md b/cloudformation/README.md new file mode 100644 index 0000000..b46823c --- /dev/null +++ b/cloudformation/README.md @@ -0,0 +1,10 @@ +h1. CloudFormation Template(s) for `AWS-Lambda-Image` + +This contains cloudformation template(s) to spin up a working bucket/lambda stack. Although it only spins up one set of resources, due to limitations in CloudFormation there are 3 templates, to be run sequentally. + +There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order to create a uniquely named bucket. In order to spin the stack up: + +# Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket. +# Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path +# Update with stack 2. This will create the lambda and the lambda permission objects +# Update with stack 3. This will setup the trigger between the s3 bucket and the lambda diff --git a/cloudformation/README.md~ b/cloudformation/README.md~ new file mode 100644 index 0000000..1db93c3 --- /dev/null +++ b/cloudformation/README.md~ @@ -0,0 +1,5 @@ +h1. CloudFormation Template(s) for `AWS-Lambda-Image` + +This contains cloudformation template(s) to spin up a working bucket/lambda stack. Although it only spins up one set of resources, due to limitations in CloudFormation there are 3 templates, to be run sequentally. + +There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order \ No newline at end of file diff --git a/cloudformation/aws-lambda-image-1.template b/cloudformation/aws-lambda-image-1.template new file mode 100644 index 0000000..0567fcc --- /dev/null +++ b/cloudformation/aws-lambda-image-1.template @@ -0,0 +1,134 @@ + { + "AWSTemplateFormatVersion" : "2010-09-09", + "Description" : "CF Template CoKL Image buckets and processing lambda", + "Parameters" : { + "DomainName" : { + "Description" : "domain to append to the buckets", + "Type" : "String", + "Default" : "nemo.com", + "AllowedPattern" : "[a-z.-]+", + "ConstraintDescription" : "can only contain lowercase letters, - and ." + } + }, + "Resources" : { + "ImageBucket" : { + "Type" : "AWS::S3::Bucket", + "DependsOn" : "AdminBucket", + "Properties" : { + "BucketName" : { "Fn::Sub" : "images.${DomainName}"}, + "Tags" : [ + { "Key" : "Name", "Value" : "AWS Resize Images Bucket" } + ], + "LoggingConfiguration" : { + "DestinationBucketName" : {"Ref" : "AdminBucket"}, + "LogFilePrefix" : { "Fn::Sub" : "logs/s3/images.${DomainName}"} + } + } + }, + "ImageBucketPolicy": { + "Type": "AWS::S3::BucketPolicy", + "DependsOn": "ImageBucket", + "Properties": { + "Bucket": {"Ref" : "ImageBucket"}, + "PolicyDocument": { + "Statement": [ + { + "Effect": "Allow", + "Principal": "*", + "Action": [ "s3:GetObject" ], + "Resource": [ + { "Fn::Join": [ "/", [ { "Fn::GetAtt" : ["ImageBucket", "Arn"] }, "images/small/*" ] ] }, + { "Fn::Join": [ "/", [ { "Fn::GetAtt" : ["ImageBucket", "Arn"] }, "images/medium/*" ] ] } + ] + } + ] + } + } + }, + "AdminBucket" : { + "Type" : "AWS::S3::Bucket", + "Properties" : { + "BucketName" : { "Fn::Sub" : "admin.${DomainName}"}, + "AccessControl": "LogDeliveryWrite", + "Tags" : [ + { "Key" : "Name", "Value" : "Admin code/logging Bucket" } + ] + } + }, + "ResizeAccessPolicy" : { + "Type": "AWS::IAM::ManagedPolicy", + "Properties": { + "PolicyDocument" : { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "s3:ListAllMyBuckets", + "s3:GetBucketLocation" + ], + "Resource": [ + "arn:aws:s3:::*" + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:ListBucket" + ], + "Resource": [ + {"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"} + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:GetObject" + ], + "Resource": [ + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/raw/*"]]} + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:PutObject", + "S3:PutObjectACL", + "s3:GetObject" + ], + "Resource": [ + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/small/*"]]}, + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/medium/*"]]} + ] + } + ] + } + } + }, + "ResizeLambdaRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName" : {"Fn::Sub" : "lambda-imageresizer-${DomainName}"}, + "ManagedPolicyArns" : [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole", + { "Ref": "ResizeAccessPolicy" } + ], + "AssumeRolePolicyDocument": { + "Version" : "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ "lambda.amazonaws.com" ] + }, + "Action": [ "sts:AssumeRole" ] + }] + }, + "Path": "/" + } + } + }, + "Outputs" : { + + } +} \ No newline at end of file diff --git a/cloudformation/aws-lambda-image-2.template b/cloudformation/aws-lambda-image-2.template new file mode 100644 index 0000000..3726571 --- /dev/null +++ b/cloudformation/aws-lambda-image-2.template @@ -0,0 +1,183 @@ + { + "AWSTemplateFormatVersion" : "2010-09-09", + "Description" : "CF Template CoKL Image buckets and processing lambda", + "Parameters" : { + "DomainName" : { + "Description" : "domain to append to the buckets", + "Type" : "String", + "Default" : "nemo.com", + "AllowedPattern" : "[a-z.-]+", + "ConstraintDescription" : "can only contain lowercase letters, - and ." + } + }, + "Resources" : { + "ImageBucket" : { + "Type" : "AWS::S3::Bucket", + "DependsOn" : "AdminBucket", + "Properties" : { + "BucketName" : { "Fn::Sub" : "images.${DomainName}"}, + "Tags" : [ + { "Key" : "Name", "Value" : "AWS Resize Images Bucket" } + ], + "LoggingConfiguration" : { + "DestinationBucketName" : {"Ref" : "AdminBucket"}, + "LogFilePrefix" : { "Fn::Sub" : "logs/s3/images.${DomainName}"} + }, + "NotificationConfiguration": { + "LambdaConfigurations": [ + { + "Event" : "s3:ObjectCreated:*", + "Function" : { "Fn::GetAtt" : ["ImageResizeLambda", "Arn"] }, + "Filter" : { + "S3Key" : { + "Rules" : [ + { + "Name" : "prefix", + "Value" : "images/raw" + } + ] + } + } + } + ] + } + } + }, + "ImageBucketPolicy": { + "Type": "AWS::S3::BucketPolicy", + "DependsOn": "ImageBucket", + "Properties": { + "Bucket": {"Ref" : "ImageBucket"}, + "PolicyDocument": { + "Statement": [ + { + "Effect": "Allow", + "Principal": "*", + "Action": [ "s3:GetObject" ], + "Resource": [ + { "Fn::Join": [ "/", [ { "Fn::GetAtt" : ["ImageBucket", "Arn"] }, "images/small/*" ] ] }, + { "Fn::Join": [ "/", [ { "Fn::GetAtt" : ["ImageBucket", "Arn"] }, "images/medium/*" ] ] } + ] + } + ] + } + } + }, + "AdminBucket" : { + "Type" : "AWS::S3::Bucket", + "Properties" : { + "BucketName" : { "Fn::Sub" : "admin.${DomainName}"}, + "AccessControl": "LogDeliveryWrite", + "Tags" : [ + { "Key" : "Name", "Value" : "Admin code/logging Bucket" } + ] + } + }, + "ResizeAccessPolicy" : { + "Type": "AWS::IAM::ManagedPolicy", + "Properties": { + "PolicyDocument" : { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "s3:ListAllMyBuckets", + "s3:GetBucketLocation" + ], + "Resource": [ + "arn:aws:s3:::*" + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:ListBucket" + ], + "Resource": [ + {"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"} + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:GetObject" + ], + "Resource": [ + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/raw/*"]]} + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:PutObject", + "S3:PutObjectACL", + "s3:GetObject" + ], + "Resource": [ + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/small/*"]]}, + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/medium/*"]]} + ] + } + ] + } + } + }, + "ResizeLambdaRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName" : {"Fn::Sub" : "lambda-imageresizer-${DomainName}"}, + "ManagedPolicyArns" : [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole", + { "Ref": "ResizeAccessPolicy" } + ], + "AssumeRolePolicyDocument": { + "Version" : "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ "lambda.amazonaws.com" ] + }, + "Action": [ "sts:AssumeRole" ] + }] + }, + "Path": "/" + } + }, + "ImageResizeLambda": { + "Type": "AWS::Lambda::Function", + "DependsOn" : "ResizeLambdaRole", + "Properties": { + "Description" : "Image Resizer", + "FunctionName" : "image_resizer", + "Handler": "index.handler", + "Role": { "Fn::GetAtt" : ["ResizeLambdaRole", "Arn"] }, + "MemorySize" : "384", + "Code": { + "S3Bucket": {"Ref" : "AdminBucket"}, + "S3Key": "lambda/aws-lambda-image.zip" + }, + "Runtime": "nodejs6.10", + "Timeout": "300" + } + }, + "ImageResizeLambdaPerm": { + "Type": "AWS::Lambda::Permission", + "Properties" : { + "Action": "lambda:InvokeFunction", + "FunctionName": {"Ref": "ImageResizeLambda"}, + "Principal": "s3.amazonaws.com", + "SourceAccount": {"Ref": "AWS::AccountId"}, + "SourceArn": { "Fn::Join": [":", [ + "arn", "aws", "s3", "" , "", {"Ref" : "ImageBucket"}]] + } + } + } + + + }, + "Outputs" : { + + } +} \ No newline at end of file diff --git a/cloudformation/aws-lambda-image-3.template b/cloudformation/aws-lambda-image-3.template new file mode 100644 index 0000000..3726571 --- /dev/null +++ b/cloudformation/aws-lambda-image-3.template @@ -0,0 +1,183 @@ + { + "AWSTemplateFormatVersion" : "2010-09-09", + "Description" : "CF Template CoKL Image buckets and processing lambda", + "Parameters" : { + "DomainName" : { + "Description" : "domain to append to the buckets", + "Type" : "String", + "Default" : "nemo.com", + "AllowedPattern" : "[a-z.-]+", + "ConstraintDescription" : "can only contain lowercase letters, - and ." + } + }, + "Resources" : { + "ImageBucket" : { + "Type" : "AWS::S3::Bucket", + "DependsOn" : "AdminBucket", + "Properties" : { + "BucketName" : { "Fn::Sub" : "images.${DomainName}"}, + "Tags" : [ + { "Key" : "Name", "Value" : "AWS Resize Images Bucket" } + ], + "LoggingConfiguration" : { + "DestinationBucketName" : {"Ref" : "AdminBucket"}, + "LogFilePrefix" : { "Fn::Sub" : "logs/s3/images.${DomainName}"} + }, + "NotificationConfiguration": { + "LambdaConfigurations": [ + { + "Event" : "s3:ObjectCreated:*", + "Function" : { "Fn::GetAtt" : ["ImageResizeLambda", "Arn"] }, + "Filter" : { + "S3Key" : { + "Rules" : [ + { + "Name" : "prefix", + "Value" : "images/raw" + } + ] + } + } + } + ] + } + } + }, + "ImageBucketPolicy": { + "Type": "AWS::S3::BucketPolicy", + "DependsOn": "ImageBucket", + "Properties": { + "Bucket": {"Ref" : "ImageBucket"}, + "PolicyDocument": { + "Statement": [ + { + "Effect": "Allow", + "Principal": "*", + "Action": [ "s3:GetObject" ], + "Resource": [ + { "Fn::Join": [ "/", [ { "Fn::GetAtt" : ["ImageBucket", "Arn"] }, "images/small/*" ] ] }, + { "Fn::Join": [ "/", [ { "Fn::GetAtt" : ["ImageBucket", "Arn"] }, "images/medium/*" ] ] } + ] + } + ] + } + } + }, + "AdminBucket" : { + "Type" : "AWS::S3::Bucket", + "Properties" : { + "BucketName" : { "Fn::Sub" : "admin.${DomainName}"}, + "AccessControl": "LogDeliveryWrite", + "Tags" : [ + { "Key" : "Name", "Value" : "Admin code/logging Bucket" } + ] + } + }, + "ResizeAccessPolicy" : { + "Type": "AWS::IAM::ManagedPolicy", + "Properties": { + "PolicyDocument" : { + "Version": "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Action": [ + "s3:ListAllMyBuckets", + "s3:GetBucketLocation" + ], + "Resource": [ + "arn:aws:s3:::*" + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:ListBucket" + ], + "Resource": [ + {"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"} + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:GetObject" + ], + "Resource": [ + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/raw/*"]]} + ] + }, + { + "Effect": "Allow", + "Action": [ + "s3:PutObject", + "S3:PutObjectACL", + "s3:GetObject" + ], + "Resource": [ + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/small/*"]]}, + {"Fn::Join" : ["", [{"Fn::Sub" : "arn:aws:s3:::images.${DomainName}"}, "/images/medium/*"]]} + ] + } + ] + } + } + }, + "ResizeLambdaRole": { + "Type": "AWS::IAM::Role", + "Properties": { + "RoleName" : {"Fn::Sub" : "lambda-imageresizer-${DomainName}"}, + "ManagedPolicyArns" : [ + "arn:aws:iam::aws:policy/service-role/AWSLambdaVPCAccessExecutionRole", + { "Ref": "ResizeAccessPolicy" } + ], + "AssumeRolePolicyDocument": { + "Version" : "2012-10-17", + "Statement": [ + { + "Effect": "Allow", + "Principal": { + "Service": [ "lambda.amazonaws.com" ] + }, + "Action": [ "sts:AssumeRole" ] + }] + }, + "Path": "/" + } + }, + "ImageResizeLambda": { + "Type": "AWS::Lambda::Function", + "DependsOn" : "ResizeLambdaRole", + "Properties": { + "Description" : "Image Resizer", + "FunctionName" : "image_resizer", + "Handler": "index.handler", + "Role": { "Fn::GetAtt" : ["ResizeLambdaRole", "Arn"] }, + "MemorySize" : "384", + "Code": { + "S3Bucket": {"Ref" : "AdminBucket"}, + "S3Key": "lambda/aws-lambda-image.zip" + }, + "Runtime": "nodejs6.10", + "Timeout": "300" + } + }, + "ImageResizeLambdaPerm": { + "Type": "AWS::Lambda::Permission", + "Properties" : { + "Action": "lambda:InvokeFunction", + "FunctionName": {"Ref": "ImageResizeLambda"}, + "Principal": "s3.amazonaws.com", + "SourceAccount": {"Ref": "AWS::AccountId"}, + "SourceArn": { "Fn::Join": [":", [ + "arn", "aws", "s3", "" , "", {"Ref" : "ImageBucket"}]] + } + } + } + + + }, + "Outputs" : { + + } +} \ No newline at end of file From 63dd6258191f8584820c4bdd7fd6c9a1e0d30877 Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 16:50:27 -0500 Subject: [PATCH 2/7] removing the editor file --- cloudformation/README.md~ | 5 ----- 1 file changed, 5 deletions(-) delete mode 100644 cloudformation/README.md~ diff --git a/cloudformation/README.md~ b/cloudformation/README.md~ deleted file mode 100644 index 1db93c3..0000000 --- a/cloudformation/README.md~ +++ /dev/null @@ -1,5 +0,0 @@ -h1. CloudFormation Template(s) for `AWS-Lambda-Image` - -This contains cloudformation template(s) to spin up a working bucket/lambda stack. Although it only spins up one set of resources, due to limitations in CloudFormation there are 3 templates, to be run sequentally. - -There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order \ No newline at end of file From 2b0761188f02f80b0047394a78327e7c0634a5bc Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 17:05:41 -0500 Subject: [PATCH 3/7] more detail and better formatting of the README --- cloudformation/README.md | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/cloudformation/README.md b/cloudformation/README.md index b46823c..33f1d7f 100644 --- a/cloudformation/README.md +++ b/cloudformation/README.md @@ -1,10 +1,14 @@ -h1. CloudFormation Template(s) for `AWS-Lambda-Image` +# CloudFormation Template(s) for `AWS-Lambda-Image` This contains cloudformation template(s) to spin up a working bucket/lambda stack. Although it only spins up one set of resources, due to limitations in CloudFormation there are 3 templates, to be run sequentally. -There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order to create a uniquely named bucket. In order to spin the stack up: +There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order to create a uniquely named bucket. As it is currently configured, there is a `images/raw` path that accepts incoming images, and an `images/small` and `images/medium` that get the resized images. These directories are set to allow public access as a website. -# Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket. -# Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path -# Update with stack 2. This will create the lambda and the lambda permission objects -# Update with stack 3. This will setup the trigger between the s3 bucket and the lambda +Steps in order to spin the stack up: + +
    +
  1. Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket.
  2. +
  3. Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path
  4. +
  5. Update with stack 2. This will create the lambda and the lambda permission objects
  6. +
  7. Update with stack 3. This will setup the trigger between the s3 bucket and the lambda
  8. +
\ No newline at end of file From 8c278c572dca703511347aeee1e033a05a7aa20d Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 17:09:39 -0500 Subject: [PATCH 4/7] rename the stack descriptions, remove the lambda notification from the bucket in step 2 --- cloudformation/aws-lambda-image-1.template | 2 +- cloudformation/aws-lambda-image-2.template | 22 +--------------------- cloudformation/aws-lambda-image-3.template | 2 +- 3 files changed, 3 insertions(+), 23 deletions(-) diff --git a/cloudformation/aws-lambda-image-1.template b/cloudformation/aws-lambda-image-1.template index 0567fcc..19ef376 100644 --- a/cloudformation/aws-lambda-image-1.template +++ b/cloudformation/aws-lambda-image-1.template @@ -1,6 +1,6 @@ { "AWSTemplateFormatVersion" : "2010-09-09", - "Description" : "CF Template CoKL Image buckets and processing lambda", + "Description" : "CF Template Image buckets and resize lambda", "Parameters" : { "DomainName" : { "Description" : "domain to append to the buckets", diff --git a/cloudformation/aws-lambda-image-2.template b/cloudformation/aws-lambda-image-2.template index 3726571..d2d00c7 100644 --- a/cloudformation/aws-lambda-image-2.template +++ b/cloudformation/aws-lambda-image-2.template @@ -1,6 +1,6 @@ { "AWSTemplateFormatVersion" : "2010-09-09", - "Description" : "CF Template CoKL Image buckets and processing lambda", + "Description" : "CF Template Image buckets and resize lambda", "Parameters" : { "DomainName" : { "Description" : "domain to append to the buckets", @@ -22,24 +22,6 @@ "LoggingConfiguration" : { "DestinationBucketName" : {"Ref" : "AdminBucket"}, "LogFilePrefix" : { "Fn::Sub" : "logs/s3/images.${DomainName}"} - }, - "NotificationConfiguration": { - "LambdaConfigurations": [ - { - "Event" : "s3:ObjectCreated:*", - "Function" : { "Fn::GetAtt" : ["ImageResizeLambda", "Arn"] }, - "Filter" : { - "S3Key" : { - "Rules" : [ - { - "Name" : "prefix", - "Value" : "images/raw" - } - ] - } - } - } - ] } } }, @@ -174,8 +156,6 @@ } } } - - }, "Outputs" : { diff --git a/cloudformation/aws-lambda-image-3.template b/cloudformation/aws-lambda-image-3.template index 3726571..453bff6 100644 --- a/cloudformation/aws-lambda-image-3.template +++ b/cloudformation/aws-lambda-image-3.template @@ -1,6 +1,6 @@ { "AWSTemplateFormatVersion" : "2010-09-09", - "Description" : "CF Template CoKL Image buckets and processing lambda", + "Description" : "CF Template Image buckets and resize lambda", "Parameters" : { "DomainName" : { "Description" : "domain to append to the buckets", From 59c7bdd80763f0d2e3d0f9e3195fd6f2b8347341 Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 17:48:49 -0500 Subject: [PATCH 5/7] updating the docs to be more explicit, adding in a sample config.json --- cloudformation/README.md | 6 +++--- cloudformation/config.json.sample | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 cloudformation/config.json.sample diff --git a/cloudformation/README.md b/cloudformation/README.md index 33f1d7f..d345852 100644 --- a/cloudformation/README.md +++ b/cloudformation/README.md @@ -2,13 +2,13 @@ This contains cloudformation template(s) to spin up a working bucket/lambda stack. Although it only spins up one set of resources, due to limitations in CloudFormation there are 3 templates, to be run sequentally. -There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order to create a uniquely named bucket. As it is currently configured, there is a `images/raw` path that accepts incoming images, and an `images/small` and `images/medium` that get the resized images. These directories are set to allow public access as a website. +There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order to create a uniquely named bucket. As it is currently configured, there is a `images/raw` path that accepts incoming images, and an `images/small` and `images/medium` that get the resized images. These directories are set to allow public access as a website. The included copy of `config.json` matches the paths specified in cloudformation as an example. Please change to fit your needs. Steps in order to spin the stack up:
  1. Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket.
  2. -
  3. Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path
  4. +
  5. Build the lambda archive as usual with `make`. Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path
  6. Update with stack 2. This will create the lambda and the lambda permission objects
  7. -
  8. Update with stack 3. This will setup the trigger between the s3 bucket and the lambda
  9. +
  10. Update with stack 3. This will setup the trigger between the s3 bucket and the lambda and grant public access to the processed paths in the bucket
\ No newline at end of file diff --git a/cloudformation/config.json.sample b/cloudformation/config.json.sample new file mode 100644 index 0000000..0c230b6 --- /dev/null +++ b/cloudformation/config.json.sample @@ -0,0 +1,15 @@ +{ + "bucket": "images.nemo.com", + "resizes": [ + { + "size": 300, + "directory": "images/small", + "prefix": "resized-" + }, + { + "size": 450, + "directory": "images/medium", + "suffix": "_medium" + } + ] +} From 09afb0e7da4790fc94dfc920749f3ae60c5936c8 Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 17:50:59 -0500 Subject: [PATCH 6/7] updating the list formatting of the README --- cloudformation/README.md | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/cloudformation/README.md b/cloudformation/README.md index d345852..ea8ca48 100644 --- a/cloudformation/README.md +++ b/cloudformation/README.md @@ -6,9 +6,8 @@ There is one parameter in the template, a domain name. This will be appended on Steps in order to spin the stack up: -
    -
  1. Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket.
  2. -
  3. Build the lambda archive as usual with `make`. Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path
  4. -
  5. Update with stack 2. This will create the lambda and the lambda permission objects
  6. -
  7. Update with stack 3. This will setup the trigger between the s3 bucket and the lambda and grant public access to the processed paths in the bucket
  8. -
\ No newline at end of file + +1. Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket. +2. Build the lambda archive as usual with `make`. Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path +3. Update with stack 2. This will create the lambda and the lambda permission objects +4. Update with stack 3. This will setup the trigger between the s3 bucket and the lambda and grant public access to the processed paths in the bucket From 41aefa058302384f34424854cdf0b31411eda619 Mon Sep 17 00:00:00 2001 From: Aaron Macks Date: Thu, 14 Dec 2017 17:52:14 -0500 Subject: [PATCH 7/7] fixing some minor readme typos --- cloudformation/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cloudformation/README.md b/cloudformation/README.md index ea8ca48..6ef8b96 100644 --- a/cloudformation/README.md +++ b/cloudformation/README.md @@ -2,12 +2,12 @@ This contains cloudformation template(s) to spin up a working bucket/lambda stack. Although it only spins up one set of resources, due to limitations in CloudFormation there are 3 templates, to be run sequentally. -There is one parameter in the template, a domain name. This will be appended onto the name of the s3 bucket in order to create a uniquely named bucket. As it is currently configured, there is a `images/raw` path that accepts incoming images, and an `images/small` and `images/medium` that get the resized images. These directories are set to allow public access as a website. The included copy of `config.json` matches the paths specified in cloudformation as an example. Please change to fit your needs. +There is one parameter in the template, a domain name. This will be appended onto the name of the s3 buckets in order to create uniquely named buckets, one for code and logs (`admin.`) and one for the images (`images.`). As it is currently configured, there is a `images/raw` path that accepts incoming images, and an `images/small` and `images/medium` that get the resized images. These directories are set to allow public access as a website. The included copy of `config.json` matches the paths specified in cloudformation as an example. Please change to fit your needs. Steps in order to spin the stack up: -1. Spin up stack 1. This will create 2 buckets in s3, an `image` bucket and an `admin` bucket. +1. Spin up stack 1. This will create 2 buckets in s3, an `images` bucket and an `admin` bucket. 2. Build the lambda archive as usual with `make`. Upload the .zip file of code to the `admin` bucket. If you do not upload it at `lambda/aws-lambda-image.zip`, you will need to change stack 2 and 3 to reflect the path 3. Update with stack 2. This will create the lambda and the lambda permission objects 4. Update with stack 3. This will setup the trigger between the s3 bucket and the lambda and grant public access to the processed paths in the bucket