3

I have code that creates a boto3 client of type 'lambda'. I then use that client to call the list_functions(), create_function(), and update_function() methods. That all works well as outlined in this documentation: http://boto3.readthedocs.io/en/latest/reference/services/lambda.html#Lambda.Client.list_functions

But when i go to use the list_tags() or tag_resource() methods outline here: http://boto3.readthedocs.io/en/latest/reference/services/lambda.html#Lambda.Client.list_tags

I get an error saying:

AttributeError: 'Lambda' object has no attribute 'list_tags'

what am I doing wrong? Those methods are listed on the same doc page so I figure they are called on the same client. What gives:

    l = boto3.client(
    'lambda',
    region_name='us-east-1', 
    aws_access_key_id = 'AletitgoQ',
    aws_secret_access_key = 'XvHowdyW',
)
    l.list_tags(
         Resource="myArn"
        )        

    l.tag_resource(
            Resource="myArn",
            Tags={
                'action': 'test'
          }
      )

To make matters worse, I don't appear to be able to include the tags in the create_function() call despite what the docs say about that here: http://boto3.readthedocs.io/en/latest/reference/services/lambda.html#Lambda.Client.create_function

when i include tags in the call i get this response:

botocore.exceptions.ParamValidationError: Parameter validation failed: Unknown parameter in input: "Tags", must be one of: FunctionName, Runtime, Role, Handler, Code, Description, Timeout, MemorySize, Publish, VpcConfig, DeadLetterConfig, Environment, KMSKeyArn

compare that list to what is shown in the boto3 docs and you see that a few things are missing at the end there including tags

I'm in python 2.7 and pip confirms my boto3 is 1.4.4

1 Answer 1

5

It works just fine for me:

>>> import boto3
>>> client = boto3.client('lambda')

>>> response=client.create_function(FunctionName='bar', Runtime='python2.7', Handler='index.handler', Tags={'Action': 'Test'}, Role='arn:aws:iam::123456789012:role/my-role', Code={'S3Bucket':'my-bucket', 'S3Key':'files.zip'})

>>> client.tag_resource(Resource='arn:aws:lambda:ap-southeast-2:123456789012:function:bar', Tags={'Food':'Cheese'})
{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 204, 'RequestId': '93963c42-36d5-11e7-a457-8730520029b8', 'HTTPHeaders': {'date': 'Fri, 12 May 2017 05:40:58 GMT', 'x-amzn-requestid': '93963c42-36d5-11e7-a457-8730520029b8', 'connection': 'keep-alive', 'content-type': 'application/json'}}}

>>> client.list_tags(Resource='arn:aws:lambda:ap-southeast-2:123456789012:function:bar')
{'ResponseMetadata': {'RetryAttempts': 0, 'HTTPStatusCode': 200, 'RequestId': '9e826957-36d5-11e7-a554-a30d477976ba', 'HTTPHeaders': {'date': 'Fri, 12 May 2017 05:41:16 GMT', 'x-amzn-requestid': '9e826957-36d5-11e7-a554-a30d477976ba', 'content-length': '42', 'content-type': 'application/json', 'connection': 'keep-alive'}}, u'Tags': {u'Action': u'Test', u'Food': u'Cheese'}}
Sign up to request clarification or add additional context in comments.

2 Comments

that's odd. could you do me a favor and add a bogus tag to the create method (like taggg) and see if you get the same error message i get above?
my boto3 was up to date but not my botocore. running pip install -U boto3 fixed things

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.