I have this lambda function:
def lambda_handler(event, context):
response = client.describe_maintenance_windows(Filters=[
{
'Key': 'Name',
'Values': ['test']
},
])
MWId = response["WindowIdentities"]
return(MWId)
I got below response Response structure:
[
{
"WindowId": "mw-0154acefa2151234",
"Name": "test",
"Enabled": true,
"Duration": 4,
"Cutoff": 0,
"Schedule": "cron(0 0 11 ? * SUN#4 *)",
"NextExecutionTime": "2024-08-25T11:00Z"
}
]
How do I get the value of WindowId so I can pass it to a variable? I tried below but I am getting "errorMessage": "'list' object is not callable"
mwidvalue = MWId("WindowId")
It's a list that contains a dictionary, so you would need to use:
mwidvalue = MWId[0]["WindowId"]
That will return the first element of the list (in your example, there is only one) and then the WindowId
element of that dictionary.