4
votes

I need to update the version of my lambda function in API Gateway with boto3, test:3 to test:4.

description

From what I understood, I would need to use the update_integration() function in boto3 and update with patchOperations, but I don't understand how as there isn't a lot of documentation about it.

client = boto3.client(
    'apigateway', 
    aws_access_key_id='access_key',
    aws_secret_access_key='secret_key',
    region_name = 'us-east-1'
)
response = client.update_integration(...) # something here?

Any suggestion?

------- EDIT -------

arn = 'arn:aws:apigateway:us-east-1:lambda:path/2015-03- 
31/functions/{lambdaFunctionArn}'

response = client.update_integration(
    restApiId= '{restApiId}',
    resourceId= '{resourceId}',
    httpMethod='POST',
    patchOperations=[
        {
            'op': 'replace',
            'path': '/uri',
            'value': arn
        }
    ]
)

I found that solution on this forum: https://forums.aws.amazon.com/thread.jspa?messageID=694264&#694264 but I keep getting this error:

botocore.errorfactory.BadRequestException: An error occurred (BadRequestException) when calling the UpdateIntegration operation: Role ARN must be specified for AWS integrations

1

1 Answers

2
votes

I found the solution. I should have added /invocations at the end of arn:

arn = 'arn:aws:apigateway:us-east-1:lambda:path/2015-03- 
31/functions/{lambdaFunctionArn}/invocations'

response = client.update_integration(
    restApiId= '{restApiId}',
    resourceId= '{resourceId}',
    httpMethod='POST',
    patchOperations=[
        {
            'op': 'replace',
            'path': '/uri',
            'value': arn
        }
    ]
)