From 5872e8e1a7d040aede85cf94ecc5df79b54a224e Mon Sep 17 00:00:00 2001 From: Oliver Gutperl Date: Thu, 28 Mar 2019 17:42:28 +0100 Subject: [PATCH] Bugfixes for automated version creation --- .gitignore | 3 ++- README.md | 8 ++++++++ package.json | 5 +++-- sam.yaml | 9 +-------- 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/.gitignore b/.gitignore index 4e0c8b0..c3fdc85 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ npm-debug.log *.log git-commit.json .vscode -standard-redirects-for-cloudfront-sam.yaml \ No newline at end of file +standard-redirects-for-cloudfront-sam.yaml +standard-redirects-for-cloudfront-sam-test.yaml \ No newline at end of file diff --git a/README.md b/README.md index 0ad06e6..967cb7b 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,14 @@ It allows you to have very nice outward facing URLs like "/cooltopic", that inte Make sure that your CloudFront distribution handles the URL "/" directly by having the property "Default Root Object" set to "index.html". +## Updating + +1. Install the application "standard-redirects-for-cloudfront". +2. Go to the Cloudformation Console +3. Select the Output Value, this is the ARN (including the version) for the Lambda function. +4. In CloudFront edit a **Behaviour** and add a **Lambda Function Association** with the *Event Type* "Origin Request" and enter the Lambda function ARN from the previous step. +5. Wait for the CloudFront distribution to deploy. + ## Installation ### Installation via the Serverless Application Repository diff --git a/package.json b/package.json index 7949ec4..5f8d2e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "standard-redirects-for-cloudfront", - "version": "1.2.0", + "version": "1.3.1", "description": "", "main": "index.js", "scripts": { @@ -8,7 +8,8 @@ "test-coverage": "istanbul cover _mocha", "predeploy": "git log -1 --pretty=format:'{ \"date\":\"%cI\", \"commit\":\"%H\" }' > git-commit.json", "deploy": "zip -r LATE-standard-redirects-for-cloudfront.zip . -i \\*.js -i git-commit.json -i node_modules/\\* -x test/\\* -x node_modules/aws-sdk/\\* -x node_modules/mocha/\\* && echo Uploading... && aws lambda update-function-code --region us-east-1 --function-name LATE-standard-redirects-for-cloudfront --zip-file fileb://LATE-standard-redirects-for-cloudfront.zip --publish", - "package": "aws cloudformation package --template-file sam.yaml --output-template-file standard-redirects-for-cloudfront-sam.yaml --s3-bucket public.digital-sailors.de --s3-prefix serverless-application-repo/standard-redirects-for-cloudfront" + "package": "aws cloudformation package --template-file sam.yaml --output-template-file standard-redirects-for-cloudfront-sam.yaml --s3-bucket public.digital-sailors.de --s3-prefix serverless-application-repo/standard-redirects-for-cloudfront", + "package-test": "aws cloudformation package --template-file sam.yaml --output-template-file standard-redirects-for-cloudfront-sam-test.yaml --s3-bucket demo.digital-sailors.work --s3-prefix serverless-application-repo/standard-redirects-for-cloudfront-test" }, "dependencies": {}, "license": "Apache-2.0", diff --git a/sam.yaml b/sam.yaml index d0cf5a8..d6fc4a1 100644 --- a/sam.yaml +++ b/sam.yaml @@ -3,8 +3,7 @@ Transform: AWS::Serverless-2016-10-31 Outputs: StandardRedirectsForCloudFrontVersionOutput: Description: The ARN of the function, including the version - Value: - Ref: DeployedFunction + Value: !Ref StandardRedirectsForCloudFront.Version Export: Name: StandardRedirectsForCloudFrontARN Resources: @@ -17,9 +16,3 @@ Resources: MemorySize: 128 Timeout: 3 AutoPublishAlias: 'CurrentProd' - DeployedFunction: - Type: AWS::Lambda::Version - Properties: - Description: The deployed version of the function - FunctionName: - Ref: StandardRedirectsForCloudFront \ No newline at end of file