This file contains hidden or 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
| async def processToolUse(self, toolName, toolUseContent): | |
| """Return the tool result""" | |
| logger.info(f"Tool Use Content: {toolUseContent}") | |
| toolName = toolName.lower() | |
| content, result = None, None | |
| try: | |
| if toolUseContent.get("content"): | |
| # Parse the JSON string in the content field | |
| content = toolUseContent.get("content") # Pass the JSON string directly to the agent |
This file contains hidden or 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
| """ | |
| DynamoDBのステータスを更新して処理ロックを取得する。 | |
| S3イベント通知をトリガーとしてこのLambda関数が実行されるため、 | |
| ロックを取得することで、同じ写真に対して処理が重複実行されることを防ぐ。 | |
| ロック取得条件: | |
| status が CREATED | |
| または | |
| status が PROCESSING かつ processingExpiresAt が現在時刻より過去 |
This file contains hidden or 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
| import { defineBackend } from '@aws-amplify/backend'; | |
| import * as iam from "aws-cdk-lib/aws-iam"; | |
| import { auth } from './auth/resource.js'; | |
| import { data } from './data/resource.js'; | |
| import { startSfn } from './functions/start-sfn/resource'; | |
| import { sendTaskSuccessSfn } from './functions/send-task-success-sfn/resource'; | |
| import { AuthorizationType } from 'aws-cdk-lib/aws-appsync' | |
| import { CustomResources } from './custom/resource'; | |
| const backend = defineBackend({ |
This file contains hidden or 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
| // S3インターフェースエンドポイントとAPI用Lambda関数のターゲットグループを作成 | |
| const s3InterfaceTg = new elbv2.ApplicationTargetGroup( | |
| this, | |
| "S3ITargetGroup", | |
| { | |
| healthCheck: { | |
| // ヘルスチェックの設定 | |
| // ref: https://aws.amazon.com/jp/blogs/news/hosting-internal-https-static-websites-with-alb-s3-and-privatelink/ | |
| healthyHttpCodes: "200,307,405", | |
| port: "80", |
This file contains hidden or 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
| this.function = new lambda.Function(this, "AnalyzeLetterFunction", { | |
| handler: "lambda_function.lambda_handler", | |
| runtime: lambda.Runtime.PYTHON_3_12, | |
| timeout: Duration.minutes(15), | |
| memorySize: 1024, | |
| reservedConcurrentExecutions: 10, // Note: Auroraへの接続数に影響 | |
| role: this.functionRole, | |
| securityGroups: [this.functionSg], | |
| vpc: spVpc.vpc, | |
| vpcSubnets: { subnets: spVpc.privateSubnets }, |
This file contains hidden or 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
| this.trainingTable = new dynamodb.TableV2(this, "TrainingTable", { | |
| partitionKey: { name: "TrainingId", type: dynamodb.AttributeType.STRING }, | |
| billing: dynamodb.Billing.onDemand(), | |
| removalPolicy: RemovalPolicy.DESTROY, | |
| tableName: config.appName + "Trainings", | |
| }); |
This file contains hidden or 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
| async function uploadTrainingVideo(uploadUrl) { | |
| try { | |
| const url = uploadUrl; | |
| const req = { | |
| method: "PUT", | |
| headers: { | |
| "Content-Type": "video/mp4", | |
| }, | |
| body: trainingVideo, | |
| }; |
This file contains hidden or 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
| def gen_presigned_url(upload_bucket_name: str, upload_s3key: str) -> str: | |
| region_name = os.environ.get("S3_REGION_NAME") | |
| if region_name is None: | |
| logger.error("Environment variable S3_REGION_NAME not found") | |
| raise | |
| s3 = boto3.client( | |
| "s3", region_name=region_name, config=Config(signature_version="s3v4") | |
| ) | |
| try: |
This file contains hidden or 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
| /* | |
| * デフォルトで以下2設定が有効 | |
| * - プライベートDNS名 | |
| * - インバウンドエンドポイントに対してのみのプライベートDNS | |
| */ | |
| this.s3Interface = vtVpc.vpc.addInterfaceEndpoint("S3", { | |
| service: ec2.InterfaceVpcEndpointAwsService.S3, | |
| securityGroups: [this.s3Sg], | |
| subnets: { subnets: vtVpc.privateSubnets }, | |
| }); |
This file contains hidden or 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
| this.uploadBucket = new s3.Bucket(this, "UploadBucket", { | |
| // 署名済みURLからアップロードするバケット | |
| // 名前は何でもいい | |
| bucketName: config.uploadBucketNamePrefix + config.appDomain, | |
| removalPolicy: RemovalPolicy.DESTROY, | |
| }); | |
| this.uploadBucket.addToResourcePolicy( | |
| new iam.PolicyStatement({ | |
| actions: ["s3:*"], | |
| conditions: { |
NewerOlder