EC2 object has no attribute terminate_client_vpn_connections

0

Hi,
Hoping someone can point me in the right direction. I'm going to post the code in here as it may help.
(Python 2.7)
It's not finished but i'm stuck at running the termination of the connection.
(note:parts of the code are missing at the variables due to the plain text formatting on the forum)

import boto3
import gzip
import json
import base64

client = boto3.client('ec2')

def lambda_handler(event, context):
print(json.dumps(event, indent=0))
SourceIP = event['device-ip']
VPNEndpoint = event['client-vpn-endpoint-id']
ClientId = event['connection-id']
if SourceIP == 'X.X.X.X':
response = client.terminate_client_vpn_connections(
ClientVpnEndpointId=='VPNEndpoint',
ConnectionId=='ClientId',
DryRun==True
)
else:
print('Access OK')

It pulls the json for a matching value.
I get the following error when the condition is true...

errorMessage": "'EC2' object has no attribute 'terminate_client_vpn_connections'

I pretty sure the issue is related to the Python SDK boto3 runtime version not supporting this new method.
The method as far as i can see is available with Boto3 1.9.78 but according to documentation the Lambda runtime is still 1.7.74 botocore-1.10.74

I have followed online docs to install boto3 1.9.78 (with respective boto-core) in a new directory, install boto3 via pip using a requirements.txt with the boto version i need.

Problem is, any compression i use (zip, gzip, bzip2 --best -9) leaves the file too large that when uploaded to lambda doesn't allow me to view the inline code...
Error
"The deployment package of your Lambda function "test-vpn" is too large to enable inline code editing. However, you can still invoke your function"

Any idea's anyone?
PS: Genuine question - Anyone know why AWS don't update the lambda runtime to newest versions?

Thank you
S

Edited by: shughes78 on Jan 14, 2019 11:48 AM

feita há 5 anos423 visualizações
1 Resposta
0

Ok, i've managed to get this uploaded ok but still working on how to reference the new boto version.

I'm going to close this as the main issue although outstanding, i should be able to resolve.

respondido há 5 anos

Você não está conectado. Fazer login para postar uma resposta.

Uma boa resposta responde claramente à pergunta, dá feedback construtivo e incentiva o crescimento profissional de quem perguntou.

Diretrizes para responder a perguntas