как динамически передать ключ и значение во вложенный dict aws запрос python - PullRequest
0 голосов
/ 23 марта 2020

Я пытаюсь передать значение ключа вложенному dict в метод batch_get_resource_config https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/config.html#ConfigService .Client.batch_get_resource_config . и я получаю синтаксическую ошибку.

Синтаксическая ошибка в модуле 'index': неверный синтаксис (index.py, строка 15)

import boto3
import os
client = boto3.client('config')                
def lambda_handler(event, context):
    msg = ''
    next_token = ''    
    while next_token is not None:
        response = client.get_compliance_details_by_config_rule(ConfigRuleName='required-tags',ComplianceTypes=['NON_COMPLIANT'],NextToken=next_token)
        next_token = response.get('NextToken', None)
        for a in response['EvaluationResults']:
            resourceType = a['EvaluationResultIdentifier']['EvaluationResultQualifier']['ResourceType']
            resourceID = a['EvaluationResultIdentifier']['EvaluationResultQualifier']['ResourceId']
            dict = [{'resourceType':resourceType,'resourceId':resourceID}]
            response2 = client.batch_get_resource_config(resourceKeys=dict)
            for b in response2['baseConfigurationItems']
                response3 = client.list_tags_for_resource(ResourceArn=b['arn'])
                tags = response3['Tags']
            msg = msg + '%s\t%s\t%s\n' %(resourceType, resourceID, tags)
...