我无法获得参数的值。
我正在使用 Python 中的lambda。
ssm =boto3.client('ssm')
def eslam(event, context):
parameters = ssm.get_parameters(
Names=[
'/dev/es/ad-es-to-s3',
],
WithDecryption=False
)
x = parameters.values()
print(x)
'''
This print: dict_values([[{'Name': '/dev/es/ad-es-to-s3', 'Type': 'String', **'Value': "'k1':'valor1', 'k2':'valor2', 'k3':'valor3'"**, 'Version': 1, 'LastModifiedDate': datetime.datetime(2019, 10, 16, 16, 50, 38, 155000, tzinfo=tzlocal()), 'ARN': 'arn:aws:ssm:us-east-1:xxxxxxxxxx:parameter/dev/es/ad-es-to-s3'}], [], {'RequestId': 'xxxxxxxx1', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'xxxxxxxxxx', 'content-type': 'application/x-amz-json-1.1', 'content-length': '260', 'date': 'Wed, 16 Oct 2019 17:01:38 GMT'}, 'RetryAttempts': 0}])
'''
print(parameters)
'''
this print: {'Parameters': [{'Name': '/dev/es/ad-es-to-s3', 'Type': 'String', **'Value': "'k1':'valor1', 'k2':'valor2', 'k3':'valor3'"**, 'Version': 1, 'LastModifiedDate': datetime.datetime(2019, 10, 16, 16, 50, 38, 155000, tzinfo=tzlocal()), 'ARN': 'arn:aws:ssm:us-east-1:xxxxxxxxxxx:parameter/dev/es/ad-es-to-s3'}], 'InvalidParameters': [], 'ResponseMetadata': {'RequestId': 'xxxxxxxxxx', 'HTTPStatusCode': 200, 'HTTPHeaders': {'x-amzn-requestid': 'xxxxxxxxx', 'content-type': 'application/x-amz-json-1.1', 'content-length': '260', 'date': 'Wed, 16 Oct 2019 17:01:38 GMT'}, 'RetryAttempts': 0}}
'''
print(parameters['Parameter']['Value'])
# this raise the error: "errorType": "KeyError"
return parameters.get('Parameter', {}).get('Name')
# this return a null value, **I want to get 'Value': "'k1':'valor1', 'k2':'valor2', 'k3':'valor3'"**