awslabs / dynamodb-continuous-backup

Continuous backup automation for Amazon DynamoDB
Apache License 2.0
185 stars 32 forks source link

Unable to match the tag value , while it does exist in a Dynamo DB #45

Open Manoran29 opened 4 years ago

Manoran29 commented 4 years ago

HI team

First of this is my first post, so excuse me if I have post it on a wrong forum or things like that :-)

I have dynamo DB created and I have tagged it In my python script, I can see that I can retrive that value But when i am taking it through a loop its failing to match in my lambda fucntion

When i tried that piece of code in mylaptop its working perfectly

code :

def table_regex_optin(dynamo_table_name): client = boto3.client('dynamodb') response = client.list_tables() try : response = client.list_tags_of_resource( ResourceArn='arn:aws:dynamodb:ap-southeast-2:${AWS::AccountId}:table/'+dynamo_table_name ) print('getting the tags:',response['Tags'])

    for tag in response['Tags']:
        if tag['Key'].lower() == 'backup-needed' and tag['Value'].lower() == 'true':
            return True
except:
    print('i am failing to match the tag')
    return False 

The output of the below statement 👍
print('getting the tags:',response['Tags']) prints all the tag i have included the 'backup-needed' , but its not matching in the next line

Manoran29 commented 4 years ago

okay , i found the problem

Lambda was checking for the tags , while the table is being created . So i added wait for 2 sec and it worked

Thanks