{"id":22139856,"url":"https://github.com/yvele/aws-cfn-custom-resource-lambda-edge","last_synced_at":"2025-10-09T07:38:48.221Z","repository":{"id":46705849,"uuid":"272558323","full_name":"yvele/aws-cfn-custom-resource-lambda-edge","owner":"yvele","description":"🏗 AWS CloudFormation custom resource that allows deploying Lambda@Edge from any region","archived":false,"fork":false,"pushed_at":"2021-09-29T12:40:17.000Z","size":48,"stargazers_count":19,"open_issues_count":2,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-07-26T03:48:04.931Z","etag":null,"topics":["amazon-web-services","aws","aws-cloudformation","aws-cloudfront","aws-lambda-edge","cloudformation","infrastructure-as-code"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/yvele.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-06-15T22:40:09.000Z","updated_at":"2023-08-14T13:18:39.000Z","dependencies_parsed_at":"2022-08-27T06:12:40.300Z","dependency_job_id":null,"html_url":"https://github.com/yvele/aws-cfn-custom-resource-lambda-edge","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/yvele/aws-cfn-custom-resource-lambda-edge","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvele%2Faws-cfn-custom-resource-lambda-edge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvele%2Faws-cfn-custom-resource-lambda-edge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvele%2Faws-cfn-custom-resource-lambda-edge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvele%2Faws-cfn-custom-resource-lambda-edge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yvele","download_url":"https://codeload.github.com/yvele/aws-cfn-custom-resource-lambda-edge/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yvele%2Faws-cfn-custom-resource-lambda-edge/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279000970,"owners_count":26082973,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amazon-web-services","aws","aws-cloudformation","aws-cloudfront","aws-lambda-edge","cloudformation","infrastructure-as-code"],"created_at":"2024-12-01T20:19:41.647Z","updated_at":"2025-10-09T07:38:48.193Z","avatar_url":"https://github.com/yvele.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# aws-cfn-custom-resource-lambda-edge\n\n\u003ca href=\"https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html\"\u003e\n  \u003cimg align=\"right\" alt=\"CloudFormation\" src=\"docs/media/cfn-logo.png\" title=\"CloudFormation custom resource\" height=\"150\"/\u003e\n\u003c/a\u003e\n\n\u003e This project provides a `Custom::Resource` for AWS CloudFormation that copies a provided Lambda to the `us-east-1` standard region. This is specially useful to deploy [Lambda@Edge](https://aws.amazon.com/lambda/edge/) from other regions than the standard one.\n\n\n[![Node](https://img.shields.io/badge/node-v12.x-blue.svg)](https://nodejs.org)\n\n\n## Motivation\n\n- https://github.com/awslabs/serverless-application-model/issues/635\n- https://twitter.com/prestomation/status/971256051516485632\n\n\n## Installation\n\nClone the repository.\n\n[Setup your AWS CLI credentials](https://docs.aws.amazon.com/cli/latest/userguide/cli-chap-configure.html) then run the install script that deploys the CloudFormation [custom resource](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html) and it's dependencies.\n\nUse the `--region` parameter to specify where you want your custom resource to be deployed:\n\n```sh\n./install.sh --region eu-west-1\n```\n\nThe script deploys 3 CloudFormation stacks.\n\nNote that [the first stack](https://github.com/yvele/aws-cfn-custom-resource-lambda-edge/tree/master/stacks/package-bucket) is a prerequisite that deploys an S3 bucket required by CloudFormation to [upload local artifacts](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/using-cfn-cli-package.html). If you already have such bucket, you can skip installing it by providing the optional `--package-bucket` parameter:\n\n```sh\n./install.sh --region eu-west-1 --package-bucket my-package-bucket\n```\n\n\n## Usage\n\n### With the default execution role\n\n```yaml\nAWSTemplateFormatVersion: 2010-09-09\nTransform: AWS::Serverless-2016-10-31\nResources:\n\n  # CloudFront distribution\n  Distribution:\n    Type: AWS::CloudFront::Distribution\n    Properties:\n      DistributionConfig:\n        DefaultCacheBehavior:\n          LambdaFunctionAssociations:\n            - EventType: origin-request\n              LambdaFunctionARN: !GetAtt EdgeOriginRequest.FunctionVersion\n\n  # Unused Lambda function only to get `CodeUri` working\n  EdgeOriginRequestSource:\n    Type: AWS::Serverless::Function\n    Properties:\n      CodeUri: ./src\n      AutoPublishAlias: live # Required to get `Version` parameter and force publication\n\n  # Custom resource to \"copy\" the Lambda in the standard region (us-east-1)\n  EdgeOriginRequest:\n    Type: Custom::LambdaEdge\n    Properties:\n      ServiceToken: !ImportValue CustomResourceLambdaEdgeServiceToken\n      Parameters:\n        LambdaSourceArn: !Ref EdgeOriginRequestSource.Version\n```\n\n\n### With a custom execution role\n\n```yaml\nAWSTemplateFormatVersion: 2010-09-09\nTransform: AWS::Serverless-2016-10-31\nResources:\n\n  # CloudFront distribution\n  Distribution:\n    Type: AWS::CloudFront::Distribution\n    Properties:\n      DistributionConfig:\n        DefaultCacheBehavior:\n          LambdaFunctionAssociations:\n            - EventType: origin-request\n              LambdaFunctionARN: !GetAtt EdgeOriginRequest.FunctionVersion\n\n  # Unused Lambda function only to get `CodeUri` working\n  EdgeOriginRequestSource:\n    Type: AWS::Serverless::Function\n    Properties:\n      CodeUri: ./src\n      AutoPublishAlias: live # Required to get `Version` parameter and force publication\n\n  # Custom resource to \"copy\" the Lambda in the standard region (us-east-1)\n  EdgeOriginRequest:\n    Type: Custom::LambdaEdge\n    Properties:\n      ServiceToken: !ImportValue CustomResourceLambdaEdgeServiceToken\n      Parameters:\n        LambdaSourceArn: !Ref EdgeOriginRequestSource.Version\n        LambdaRoleArn: !GetAtt EdgeOriginRequestRole.Arn\n\n  # Custom execution role\n  EdgeOriginRequestRole:\n    Type: AWS::IAM::Role\n    Properties:\n      AssumeRolePolicyDocument:\n        Version: 2012-10-17\n        Statement:\n          - Effect: Allow\n            Action: sts:AssumeRole\n            Principal:\n              Service:\n                - lambda.amazonaws.com\n                - edgelambda.amazonaws.com\n      ManagedPolicyArns:\n        - arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole\n        - arn:aws:iam::aws:policy/AWSXRayDaemonWriteAccess\n      Policies:\n        - PolicyName: CustomPolicy\n          PolicyDocument:\n            Version: 2012-10-17\n            Statement:\n              - Effect: Allow\n                Resource: \"*\"\n                Action: lambda:InvokeFunction\n```\n\n\n## License\n\n[Apache 2.0](LICENSE) © Yves Merlicco\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyvele%2Faws-cfn-custom-resource-lambda-edge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyvele%2Faws-cfn-custom-resource-lambda-edge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyvele%2Faws-cfn-custom-resource-lambda-edge/lists"}