adn*_*ili 6 amazon-web-services gitlab aws-lambda
我们有一个 lambda@edge 函数,它监听 Cloudfront 分发源request和response事件。我们正在尝试自动化部署。到目前为止,我们成功地更新了代码并发布了新版本。
- npm install
- zip -r lambda.zip *
- aws lambda update-function-code --function-name LambdaFunction1 --zip-file fileb://lambda.zip
- aws lambda publish-version --function-name LambdaFunction1
Run Code Online (Sandbox Code Playgroud)
但是我们如何更新 CloudFront 触发器以指向最新发布的版本?
小智 4
执行以下步骤 -
aws lambda list-versions-by-function --function-name LAMBDA_NAME
aws cloudfront get-distribution-config --id DISTRIBUTION_ID > cf_config.json
创建一个通过从 cf_config.json 中updated_cf_config.json获取DistributionConfig键命名的文件。
现在将最新版本的 lambda 的 FunctionARN 放入“LambdaFunctionAssociations”->“LambdaFunctionARN”中
通过运行命令更新 cloudfront 发行版。要更新 cloudfront 发行版,我们需要来自以下位置的 ETAG cf_config.json:
aws cloudfront update-distribution --distribution-config file://cf_config.json --id DISTRIBUTION_ID --if-match ETAG
| 归档时间: |
|
| 查看次数: |
1034 次 |
| 最近记录: |