Closed kokoichi206 closed 2 years ago
octet-stream
になってしまっていた型ヒントの為に aws_lambda_powertools をインポートした
import os
import json
import boto3
from typing import Any, Dict
from aws_lambda_powertools.utilities.typing import LambdaContext
dynamodb = boto3.resource('dynamodb')
table = dynamodb.Table(os.getenv('TABLE_NAME'))
def handler(
event: Dict[str, Any],
context: aws_lambda_powertools.utilities.typing.LambdaContext,
) -> Dict[str, Any]:
"""dynamodbからメンバーの一覧を取得する。
すると次のようなエラーが lambda のテストで表示された
Test Event Name
test
Response
{
"errorMessage": "Unable to import module 'lambda': No module named 'aws_lambda_powertools'",
"errorType": "Runtime.ImportModuleError",
"stackTrace": []
}
Function Logs
START RequestId: f73a8213-3201-4ee0-8e19-9f0af77835e2 Version: $LATEST
[ERROR] Runtime.ImportModuleError: Unable to import module 'lambda': No module named 'aws_lambda_powertools'
Traceback (most recent call last):END RequestId: f73a8213-3201-4ee0-8e19-9f0af77835e2
REPORT RequestId: f73a8213-3201-4ee0-8e19-9f0af77835e2 Duration: 1.39 ms Billed Duration: 2 ms Memory Size: 128 MB Max Memory Used: 51 MB Init Duration: 245.79 ms
Request ID
f73a8213-3201-4ee0-8e19-9f0af77835e2
タイプヒントは必須ではないため、今回ここはスルーする。。。
# upload objects
resource "aws_s3_bucket_object" "main" {
for_each = fileset("${path.module}/src/", "*")
bucket = aws_s3_bucket.main.bucket
content_type = "text/html"
key = each.value
source = "${path.module}/src/${each.value}"
}
cli でアップロードできないのでやめた
resource "aws_s3_bucket_public_access_block" "mini_schna_com" {
bucket = aws_s3_bucket.main.bucket
block_public_acls = true
block_public_policy = false
ignore_public_acls = true
restrict_public_buckets = false
}
AWS-SAA でよくみる構成を作ってみるシリーズ
https://github.com/kokoichi206/cloud-prac/tree/main/aws_saa/api_gateway_lambda