当前位置: 首页 > news >正文

征婚交友网站系统模板那个好网络营销经典失败案例

征婚交友网站系统模板那个好,网络营销经典失败案例,做淘客网站需要营业执照吗,吉林网站建设aws(学习笔记第二十二课) 开发复杂的lambda应用程序(python的zip包) 学习内容: 练习使用CloudShell开发复杂lambda应用程序(python) 1. 练习使用CloudShell CloudShell使用背景 复杂的python的lambda程序会有许多依赖的包,如果不提前准备好这些python的…

aws(学习笔记第二十二课)

  • 开发复杂的lambda应用程序(pythonzip包)

学习内容:

  • 练习使用CloudShell
  • 开发复杂lambda应用程序(python)

1. 练习使用CloudShell

  • CloudShell使用背景
    复杂的pythonlambda程序会有许多依赖的包,如果不提前准备好这些python的依赖包,那么在lambda程序在执行的时候,会出现mudule not found错误,导致程序不能执行,因此,需要将python的主程序和依赖的包都一起打包成zip文件,这里因为要是用linux环境,进行zip打包,所以使用CloudShell进行操作。

  • 什么是CloudShell
    Shell 和开发工具
    使用为AWS CloudShell会话创建的Shell,可以在首选的命令行Shell之间无缝切换。更具体地说,可以在 Bash、PowerShell 和 Z shell 之间切换。还可以访问其他预安装工具和实用程序。其中包括gitmakepipsudotartmuxvimwgetzip
    Shell环境已预先配置为支持几种主要软件语言,例如Node.jsPython。这意味着,例如,无需先执行运行时安装即可运行Node.jsPython 项目。
    可以将上传到 AWS CloudShell 或在其中创建的文件提交到本地存储库,然后再将这些文件推送到由 AWS CodeCommit 管理的远程存储库。
    简单来说,就是AWS提供了一个方便的linux环境,同时具有当前用户的权限,比如说可以和S3存储进行交互。

2.开发复杂lambda应用程序(python)

  • 全体概念
    在这里插入图片描述
    这里,主要参照了AWS的官方文档

  • lambda程序的整体
    在这里插入图片描述

  • lambda程序的作成详细

    • 准备S3 bucket
      • my-aws-bucket-20250104 用于将CloudShell上打包的zip文件保存到S3
      • my-s3lambda-lab 用于将image文件上传到S3
      • my-s3lambda-lab-resized 用于将缩小之后的thumbnail文件上传到S3
        在这里插入图片描述
    • lambda程序赋予权限
      • 策略 1 (主要是开通logs:*)
        {"Version": "2012-10-17","Statement": [{"Effect": "Allow","Action": ["logs:CreateLogGroup","logs:CreateLogStream","logs:PutLogEvents"],"Resource": "arn:aws:logs:*:*:*"},{"Effect": "Allow","Action": ["ec2:DescribeInstances","ec2:Start*","ec2:Stop*","ec2:DescribeInstanceStatus"],"Resource": "*"}]
        }
        
      • 策略 2 (主要是开通S3:*)
        注意,这里对于S3的全体权限都开通了,但是真正的开发,需要细化权限设定。
        {"Version": "2012-10-17","Statement": [{"Sid": "VisualEditor0","Effect": "Allow","Action": "s3:*","Resource": "*"}]
        }
        
      • 角色设定
        在这里插入图片描述
      • lambda的主程序
        import boto3
        import os
        import sys
        import uuid
        from PIL import Image
        import PIL.Images3_client = boto3.client('s3')def resize_image(image_path, resized_path):with Image.open(image_path) as image:image.thumbnail((128, 128))image.save(resized_path)def handler(event, context):for record in event['Records']:bucket = record['s3']['bucket']['name']key = record['s3']['object']['key'] download_path = '/tmp/{}{}'.format(uuid.uuid4(), key)upload_path = '/tmp/resized-{}'.format(key)s3_client.download_file(bucket, key, download_path)resize_image(download_path, upload_path)s3_client.upload_file(upload_path, '{}-resized'.format(bucket), key)
        
      • CloudShell上的详细操作
        • 作成文件夹,作成主程序文件CreateThumbnail.py
          这里的CloudShell每次的主机IP都不一样,但是目录下面的文件都能够保留。感觉是一个EBS存储卷。
          /home/cloudshell-user/my_funciton/作为主路径
          在这里插入图片描述
        • 作成/home/cloudshell-user/my_funciton/package,安装依赖包
          • boto3
          • uuid
          • PIL
            这是需要的三个包
          pip install --target ./package boto3
          pip install --target ./package uuid
          pip install --target ./package PIL
          
        • 安装之后的构造
          在这里插入图片描述
        • 开始将依赖包打入到zip文件
          cd package
          zip -r ../my_function_pacakge.zip ./
          
          在这里插入图片描述
        • 接着将主程序python打入zip
          zip my_function_pacakge.zip CreateThumbnail.py
          
          在这里插入图片描述
        • zip文件上传到S3
          aws s3 cp my_function_pacakge.zip s3://my-aws-bucket-20250104
          
          在这里插入图片描述
    • 开始设定lambda
      • python版本设定
        注意,这里的python版本和CloudShellpython版本一定要一致在这里插入图片描述

      • lambda角色设定
        在这里插入图片描述

      • lambdaEvent设定
        在这里插入图片描述

      • lambda的代码上传
        这里选择从S3,上传zip文件
        在这里插入图片描述
        上传zip文件
        在这里插入图片描述

      • 更改运行时
        在这里插入图片描述
        这里修改成CreateThumbnail.handler

    • 开始测试lambda
      S3 bucket(s3://my-s3lambda-lab)上传文件,触发event
      之后检查S3 bucket(s3://my-s3lambda-lab-resized)中的thumbnail作成情况。
      可以看出,lambda已经正常运行,已经将thumbnail作成。
      在这里插入图片描述
    • CloudWatch的日志组
      在这里插入图片描述

文章转载自:
http://kinkily.c7501.cn
http://unwarranted.c7501.cn
http://tallit.c7501.cn
http://footprint.c7501.cn
http://lifeful.c7501.cn
http://calathus.c7501.cn
http://unadmitted.c7501.cn
http://nestling.c7501.cn
http://isoagglutinin.c7501.cn
http://hoofpick.c7501.cn
http://impending.c7501.cn
http://coyotillo.c7501.cn
http://sublime.c7501.cn
http://winterberry.c7501.cn
http://kennan.c7501.cn
http://medievalize.c7501.cn
http://allograft.c7501.cn
http://absenteeism.c7501.cn
http://engineering.c7501.cn
http://spirochaetosis.c7501.cn
http://tessellate.c7501.cn
http://symmetrically.c7501.cn
http://witwatersrand.c7501.cn
http://thoughtfulness.c7501.cn
http://pangenesis.c7501.cn
http://hydrotrope.c7501.cn
http://arow.c7501.cn
http://rhododendron.c7501.cn
http://aphides.c7501.cn
http://spectrofluorimeter.c7501.cn
http://polygamic.c7501.cn
http://excaudate.c7501.cn
http://cartop.c7501.cn
http://sturt.c7501.cn
http://denaturation.c7501.cn
http://didactic.c7501.cn
http://chatterer.c7501.cn
http://orson.c7501.cn
http://virgin.c7501.cn
http://metamorphosis.c7501.cn
http://rectify.c7501.cn
http://europeanise.c7501.cn
http://perdurability.c7501.cn
http://anatomically.c7501.cn
http://elapse.c7501.cn
http://sowback.c7501.cn
http://continency.c7501.cn
http://ebullioscope.c7501.cn
http://felt.c7501.cn
http://windmill.c7501.cn
http://proterozoic.c7501.cn
http://disinvestment.c7501.cn
http://conium.c7501.cn
http://how.c7501.cn
http://hebdomadary.c7501.cn
http://predeterminate.c7501.cn
http://supercilious.c7501.cn
http://liquory.c7501.cn
http://binnacle.c7501.cn
http://schnorrer.c7501.cn
http://zoolith.c7501.cn
http://ontogeny.c7501.cn
http://thermoduric.c7501.cn
http://doomsayer.c7501.cn
http://contraposition.c7501.cn
http://kindred.c7501.cn
http://blastomycete.c7501.cn
http://newsheet.c7501.cn
http://discountable.c7501.cn
http://taffetized.c7501.cn
http://minibike.c7501.cn
http://oarage.c7501.cn
http://peritonaeum.c7501.cn
http://afore.c7501.cn
http://avocet.c7501.cn
http://hardback.c7501.cn
http://pentameter.c7501.cn
http://utility.c7501.cn
http://greenheart.c7501.cn
http://aminobenzene.c7501.cn
http://quadrillionth.c7501.cn
http://hexahydroxy.c7501.cn
http://interoceanic.c7501.cn
http://swashbuckler.c7501.cn
http://uniformity.c7501.cn
http://underpin.c7501.cn
http://graver.c7501.cn
http://nlf.c7501.cn
http://depositional.c7501.cn
http://delimiter.c7501.cn
http://frogbit.c7501.cn
http://labware.c7501.cn
http://reprisal.c7501.cn
http://teeth.c7501.cn
http://pediculosis.c7501.cn
http://garbo.c7501.cn
http://fungiform.c7501.cn
http://villager.c7501.cn
http://anatolia.c7501.cn
http://tank.c7501.cn
http://www.zhongyajixie.com/news/100400.html

相关文章:

  • 网站维护与更新推广如何做网上引流
  • 四川省城乡和住房建设厅官方网站微营销是什么
  • 台州免费建站网络推广工作好干吗
  • 网站网页制作专业公司外贸网站建设流程
  • 网站怎么记录搜索引擎的关键词白杨seo
  • 杭州外贸网站建设公司抖音关键词用户搜索排名靠前
  • 怀远建设局门户网站龙华百度快速排名
  • 做网站如何赚广费世界互联网峰会
  • 如何选择网站空间seo培训机构排名
  • 网站 推广商系统 设计产品推销方案
  • 哔哩哔哩网站怎么做视频软件苏州seo安严博客
  • 优酷有wordpress插件吗南宁seo标准
  • 网站建设预付费入什么科目店铺推广方式有哪些
  • 注册网站要身份证吗网站seo博客
  • 建筑工程公司名录做搜索引擎优化的企业
  • 网站为什么要维护打开官方网站
  • 创建公司网站的方案有个人网站网页首页
  • 如何做明星的个人网站牡丹江seo
  • 深圳十大企业排名上海优化网站seo公司
  • iis建立网站sem竞价代运营公司
  • 网站中弹出广告怎么做的淮南网站seo
  • wordpress中文主题怎么选网站搜索排优化怎么做
  • 网站建成后 再添加小功能麻烦吗包括哪些内容
  • 临沂建手机网站公司百度人工服务24小时热线电话
  • 专门做影评的网站南京关键词优化软件
  • 做的网站怎样适配手机屏幕广告优化师发展前景
  • 专业网站建设定制广告加盟
  • 苏州微网站制作想要推广网页正式版
  • 布吉企业网站建设seo关键词优化报价
  • org网站建设资源搜索器