enabled API gateway in AWS lambda as it is now available for AWS academy

This commit is contained in:
Sebastian Rieger
2024-07-02 21:06:40 +02:00
parent 259afec126
commit 376d287b65
2 changed files with 46 additions and 24 deletions

View File

@ -36,8 +36,19 @@ client = boto3.setup_default_session(region_name=region)
s3Client = boto3.client('s3')
s3Resource = boto3.resource('s3')
lClient = boto3.client('lambda')
apiClient = boto3.client("apigatewayv2")
print("Searching for old API gateway...")
print("------------------------------------")
for api in apiClient.get_apis()["Items"]:
if api["Name"] == functionName + '-api':
print("Deleting old API gateway...")
print("------------------------------------")
response = apiClient.delete_api(
ApiId=api["ApiId"],
)
print("Deleting old function...")
print("------------------------------------")
try:
@ -54,5 +65,5 @@ try:
currentBucket = s3Resource.Bucket(globallyUniqueS3GroupBucketName)
cleanup_s3_bucket(currentBucket)
currentBucket.delete()
except ClientError as e:
print(e)
except s3Client.exceptions.NoSuchBucket:
print('Bucket not available. No need to delete it.')