2

When trying to create a commit using boto3's codecommit client, somehow I got AttributeError on create_commit, but other commands works as expected.

Here is the code I'm using:

client = boto3.client(
            'codecommit',
            aws_access_key_id=access_key,
            aws_secret_access_key=secret_key,
        )

resp = client.create_commit(
            repositoryName='my_repo',
            branchName='master',
            authorName='My Name',
            email='my_email@gmail.com',
            putFiles=[
                {
                    'filePath': '1.json',
                    'fileMode': 'NORMAL',
                    'fileContent': '%s' % (content, ),
                }
            ]
        )

Repository is an empty so parentCommitId is not required.

And it says:

AttributeError: 'CodeCommit' object has no attribute 'create_commit'

Does anyone face this kind of issue?

Hayk Davtyan
  • 797
  • 6
  • 7

2 Answers2

0

I asked my same issue to AWS Support, and I got an answer.

This issues happens because current AWS Lambda runtime (Python 3.7) is using Boto3 library of v1.9.42. and this version of the library does not contains contains create_commit API.

Recommended Workaround is uploading a deployment package containing the latest Boto3 python package (v.1.9.202) and Lambda python code.

Check this out: https://docs.aws.amazon.com/ko_kr/lambda/latest/dg/lambda-python-how-to-create-deployment-package.html

Junho Kim
  • 257
  • 1
  • 3
  • 10
0

Check for boto3 version installed in your system using

pip show boto3

If the system version is 1.9 kindly upgrade it to v1.16 since v1.9 does not have the create_commit API.


If there are dependencies on v1.9 then create a virtual environment

In Mac / Ubuntu

python3 -m venv env

In Windows

py -m venv env

Reference links to Boto3 versions -

Mohseen Mulla
  • 542
  • 7
  • 15