#author("2023-10-02T13:47:06+09:00","","") #author("2023-10-04T14:20:40+09:00","","") [[kiji-template]] Resources: ECRRepository: Type: AWS::ECR::Repository Properties: RepositoryName: YourRepositoryName ECRRepositoryRole: Type: AWS::IAM::Role Properties: RoleName: test001 AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: ecr.amazonaws.com Action: sts:AssumeRole LambdaExecutionRole: Type: AWS::IAM::Role Properties: RoleName: LambdaExecutionRole AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: lambda.amazonaws.com Action: sts:AssumeRole Policies: - PolicyName: LambdaECRIntegrationPolicy PolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Action: - ecr:GetAuthorizationToken - ecr:GetDownloadUrlForLayer - ecr:BatchCheckLayerAvailability - ecr:GetRepositoryPolicy - ecr:DescribeRepositories - ecr:ListImages - ecr:GetLifecyclePolicy - ecr:GetLifecyclePolicyPreview - ecr:GetRepositoryPolicy - ecr:DescribeImages - ecr:GetImageScanFindings - ecr:InitiateLayerUpload - ecr:UploadLayerPart - ecr:CompleteLayerUpload - ecr:PutImage Resource: !GetAtt ECRRepository.Arn AnotherRole: Type: AWS::IAM::Role Properties: RoleName: AnotherRole AssumeRolePolicyDocument: Version: '2012-10-17' Statement: - Effect: Allow Principal: Service: lambda.amazonaws.com # または必要なサービス Action: sts:AssumeRole ECRRepositoryPolicy: Type: AWS::ECR::RepositoryPolicy Properties: RepositoryName: !Ref ECRRepository PolicyText: Version: '2012-10-17' Statement: - Effect: Allow Principal: AWS: !GetAtt AnotherRole.Arn # 別のIAMロールのARNを指定 Action: - ecr:GetDownloadUrlForLayer - ecr:BatchCheckLayerAvailability - ecr:GetRepositoryPolicy - ecr:DescribeRepositories - ecr:ListImages - ecr:GetLifecyclePolicy - ecr:GetLifecyclePolicyPreview - ecr:GetRepositoryPolicy - ecr:DescribeImages - ecr:GetImageScanFindings - ecr:InitiateLayerUpload - ecr:UploadLayerPart - ecr:CompleteLayerUpload - ecr:PutImage import nltk import json import boto3 from pptx import Presentation #import plotly.express as px import plotly.graph_objects as go import io nltk.data.path.append("/var/task") def handler(event, context): tokens = nltk.word_tokenize(event["sentence"]) #Figureオブジェクト作成 fig = go.Figure() #traceを作成 trace1 = go.Bar(x=[1, 2, 3, 4], y=[1, 4, 9, 16]) #traceをFigureに追加 fig.add_trace(trace1) #レイアウトの設定 #fig.update_layout(title='グラフのタイトル', # width=1000, # height=500) #軸の設定 #fig.update_xaxes(title='横軸') #fig.update_yaxes(title='縦軸') # グラフを作成 # fig = px.scatter(x=[1, 2, 3], y=[4, 5, 6]) plotly_image_bytes = fig.to_image(format="png") # PPTXファイルを作成 prs = Presentation() slide = prs.slides.add_slide(prs.slide_layouts[5]) left = top = width = height = 1 slide.shapes.add_picture(io.BytesIO(plotly_image_bytes), left, top, width, height) # 一時保存 file_path = "/tmp/output.pptx" prs.save(file_path) # PPTXファイルをS3にアップロード s3 = boto3.client('s3') bucket_name = 'my-sample-s3-hori-bucket' object_key = 'test/output.pptx' s3.upload_file(file_path, bucket_name, object_key) return { "statusCode": 200, "body": json.dumps({"tokens": tokens}) } * Name [#bc65a518] * Contents [#sc3dccee] #contents * What's XX [#wabc21ac] XX is ~ * Discribe [#r711b9b8] XX discribe is ~ example. XXX = XX + X * 1. [#fdd45eca] ** 1.1. [#v5a6705a] *** 1.1.1 [#fa72975a] + ① ++ ② +++ ③ - ・1 -- ・2 --- ・3 | | |h | | | | | | ---- [[kiji-template]] * Name * Contents #contents * What's XX XX is ~ * Discribe XX discribe is ~ example. XXX = XX + X * 1. ** 1.1. *** 1.1.1 + ① ++ ② +++ ③ - ・1 -- ・2 --- ・3 | | |h | | | | | | ----