1

Im using AWS lambda(using python 2.7) to invoke StackResource api to get the Stack Id of the resource created as part of nested stack .Im getting below error

"An error occurred during JSON serialization of response: cloudformation.StackResource(stack_name='Mystack', logical_id='Ec2Stack') is not JSON serializable"

import boto3
import time
import json

cloudformation = boto3.resource('cloudformation')
stack_resource = cloudformation.StackResource('prodUpgradeForchestartorFullStack','ApplicationStack')

def lambda_handler(event, context):
        return stack_resource

i have tried describe_stack_resources api which gives below error

"An error occurred during JSON serialization of response: datetime.datetime(2016, 7, 12, 15, 23, 16, 451000, tzinfo=tzlocal()) is not JSON serializable"

import boto3
import time
import json

client = boto3.client('cloudformation')


response = client.describe_stack_resources(
    StackName='Mystack',
    LogicalResourceId='Ec2Stack'
)

def lambda_handler(event, context):
        return response

Please suggest!

shiv455
  • 7,384
  • 19
  • 54
  • 93
  • Is it possible for you to get a look at the format of the data that comes out of response? It's possible you might have to do some parsing to turn it into something json friendly. – Keef Baker Jul 14 '16 at 11:33
  • That's wat I'm trying to do which I'm unable to do – shiv455 Jul 14 '16 at 12:01
  • This is really a duplicate of http://stackoverflow.com/questions/11875770/how-to-overcome-datetime-datetime-not-json-serializable-in-python – garnaat Jul 14 '16 at 16:59

0 Answers0