首页 > 解决方案 > Lambda 函数不调用 cloudtrail 日志

问题描述

我正在开发一个 python 脚本,它将使用 lambda 函数在 dynamodb 表中存储 JSON 属性,例如 ("region","ebs_volume_size","instance_type")。这是我的 lambda 函数,它从我的 python 函数中获取策略的输入:

import boto3
import time
import json
import meta_templates
from jinja2 import Template
from template_utils import create_aws_iam_policy_template 

dynamodb = boto3.resource('dynamodb')
lambd = boto3.client('lambda')

def lambda_handler(event, context):
  template_json = create_aws_iam_policy_template(**event)

  table = dynamodb.Table('GoodTable')
  response = table.put_item(
      Item= {
          'Content': 'Volume Size', 
          'Details': template_json.get('ebs_volume_size'),
      }
  )
  response = table.put_item(
      Item= {
          'Content': 'Instance Type', 
          'Details': template_json.get('instance_type'),
      }
  )
  response = table.put_item(
      Item= {
          'Content': 'Region', 
          'Details': template_json.get('region'),
      }
  )

我已授予我的 IAM 角色 DynamoDB 完全访问权限并创建了名为“GoodTable”的 DynamoDB 表,在我运行此函数后,我无法向 DyanmoDB 表添加任何内容,并且该函数运行也没有任何错误。我不确定可能出了什么问题。

标签: pythonamazon-web-servicesaws-lambdaamazon-iam

解决方案


推荐阅读