View .bashrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Function to automatically call cfn-lint when deploying AWS CloudFormation templates | |
function aws() { | |
export COMMAND=$@ | |
if [[ $COMMAND == cloudformation\ create-stack* ]] || [[ $COMMAND == cloudformation\ update-stack* ]]; | |
then | |
while [[ $# -gt 0 ]] | |
do | |
key="$1" |
View lambda-edge-step-dir-2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
├── .aws-sam | |
│ └── build | |
│ ├── RedirectLambda | |
│ │ ├── RedirectLambda.js | |
│ │ └── package.json | |
│ └── template.yaml | |
├── lambda-edge-prerequisites.yaml | |
├── lambda-edge.yaml | |
├── lambdas | |
│ ├── RedirectLambda.js |
View lambda-edge-step-dir-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
├── lambda-edge-prerequisites.yaml | |
├── lambda-edge.yaml | |
├── lambdas | |
│ ├── RedirectLambda.js | |
│ └── package.json | |
└── packaged | |
└── lambda-edge.yaml |
View lambda-edge-step-full
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: Full stack to demo Lambda@Edge for CloudFront redirects | |
Parameters: | |
RedirectLambdaName: | |
Type: String | |
Default: redirect-lambda | |
Resources: |
View lambda-edge-step-9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CloudFront: | |
Type: AWS::CloudFront::Distribution | |
Properties: | |
DistributionConfig: | |
DefaultCacheBehavior: | |
Compress: true | |
ForwardedValues: | |
QueryString: true | |
TargetOriginId: google-origin | |
ViewerProtocolPolicy: redirect-to-https |
View lambda-edge-step-8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "lambda-redirect", | |
"version": "1.0.1", | |
"description": "Redirect lambda using Lambda@Edge and CloudFront", | |
"author": "Chris McKinnel", | |
"license": "MIT" | |
} |
View lambda-edge-step-7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
exports.handler = async (event) => { | |
console.log('Event: ', JSON.stringify(event, null, 2)); | |
let request = event.Records[0].cf.request; | |
const redirects = { | |
'/path-1': 'https://consegna.cloud/', | |
'/path-2': 'https://www.amazon.com/', | |
}; |
View lambda-edge-step-5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RedirectLambdaFunction: | |
Type: AWS::Serverless::Function | |
Properties: | |
CodeUri: lambdas/ | |
FunctionName: !Ref RedirectLambdaName | |
Handler: RedirectLambda.handler | |
Role: !GetAtt RedirectLambdaFunctionRole.Arn | |
Runtime: nodejs10.x | |
AutoPublishAlias: live |
View lambda-edge-step-4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Transform: AWS::Serverless-2016-10-31 | |
Description: Full stack to demo Lambda@Edge for CloudFront redirects | |
Parameters: | |
RedirectLambdaName: | |
Type: String | |
Default: redirect-lambda | |
Resources: |
View lambda-edge-step-1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AWSTemplateFormatVersion: '2010-09-09' | |
Resources: | |
RedirectLambdaBucket: | |
Type: AWS::S3::Bucket | |
Outputs: | |
RedirectLambdaBucketName: | |
Description: Redirect lambda package S3 bucket name | |
Value: !Ref RedirectLambdaBucket |
NewerOlder