added API gateway, as in contrast to AWS Academy, localstack allows API gateway creation
This commit is contained in:
parent
2cba78a344
commit
d796ecc305
@ -53,6 +53,15 @@ s3Resource = boto3.resource('s3', endpoint_url=endpoint_url)
|
|||||||
lClient = boto3.client('lambda', endpoint_url=endpoint_url)
|
lClient = boto3.client('lambda', endpoint_url=endpoint_url)
|
||||||
apiClient = boto3.client("apigatewayv2", endpoint_url=endpoint_url)
|
apiClient = boto3.client("apigatewayv2", endpoint_url=endpoint_url)
|
||||||
|
|
||||||
|
print("Deleting old API gateway...")
|
||||||
|
print("------------------------------------")
|
||||||
|
response = apiClient.get_apis()
|
||||||
|
for api in response["Items"]:
|
||||||
|
if api["Name"] == functionName + '-api':
|
||||||
|
responseDelete = apiClient.delete_api(
|
||||||
|
ApiId=api["ApiId"]
|
||||||
|
)
|
||||||
|
|
||||||
print("Deleting old function...")
|
print("Deleting old function...")
|
||||||
print("------------------------------------")
|
print("------------------------------------")
|
||||||
try:
|
try:
|
||||||
@ -130,17 +139,14 @@ print("Lambda Function and S3 Bucket to store the counter are available. Sadly,
|
|||||||
#
|
#
|
||||||
# https://348yxdily0.execute-api.eu-central-1.amazonaws.com/default/cloudcomp-counter-demo
|
# https://348yxdily0.execute-api.eu-central-1.amazonaws.com/default/cloudcomp-counter-demo
|
||||||
|
|
||||||
# print("creating API gateway...")
|
print("creating API gateway...")
|
||||||
# print("------------------------------------")
|
print("------------------------------------")
|
||||||
#
|
|
||||||
# #apiArn = ""
|
response = apiClient.create_api(
|
||||||
# response = apiClient.create_api(
|
Name=functionName + '-api',
|
||||||
# Name=functionName + '-api',
|
ProtocolType='HTTP',
|
||||||
# ProtocolType='HTTP',
|
Target=lambdaFunctionARN
|
||||||
# Target=lambdaFunctionARN
|
)
|
||||||
# )
|
apiArn=response
|
||||||
# #apiArn=response['']
|
|
||||||
#
|
print("API Endpoint can be reached at: http://" + apiArn["ApiEndpoint"])
|
||||||
# #response = lClient.create_event_source_mapping(
|
|
||||||
# # EventSourceArn=apiArn,
|
|
||||||
# #)
|
|
||||||
|
@ -7,6 +7,8 @@ import boto3
|
|||||||
#
|
#
|
||||||
################################################################################################
|
################################################################################################
|
||||||
|
|
||||||
|
endpoint_url = "http://localhost.localstack.cloud:4566"
|
||||||
|
|
||||||
# you need to create a bucket in S3, here in this demo it is called "cloudcomp-counter", but
|
# you need to create a bucket in S3, here in this demo it is called "cloudcomp-counter", but
|
||||||
# bucket names need to be world wide unique ;) The demo looks for a file that is named
|
# bucket names need to be world wide unique ;) The demo looks for a file that is named
|
||||||
# "us-east-1" (same as our default region) in the bucket and expects a number in it to increase
|
# "us-east-1" (same as our default region) in the bucket and expects a number in it to increase
|
||||||
@ -40,10 +42,20 @@ def cleanup_s3_bucket(s3_bucket):
|
|||||||
|
|
||||||
client = boto3.setup_default_session(region_name=region)
|
client = boto3.setup_default_session(region_name=region)
|
||||||
s3Client = boto3.client('s3')
|
s3Client = boto3.client('s3')
|
||||||
s3Resource = boto3.resource('s3')
|
s3Resource = boto3.resource('s3', endpoint_url=endpoint_url)
|
||||||
lClient = boto3.client('lambda')
|
lClient = boto3.client('lambda', endpoint_url=endpoint_url)
|
||||||
|
apiClient = boto3.client("apigatewayv2", endpoint_url=endpoint_url)
|
||||||
|
|
||||||
|
|
||||||
|
print("Deleting old API gateway...")
|
||||||
|
print("------------------------------------")
|
||||||
|
response = apiClient.get_apis()
|
||||||
|
for api in response["Items"]:
|
||||||
|
if api["Name"] == functionName + '-api':
|
||||||
|
responseDelete = apiClient.delete_api(
|
||||||
|
ApiId=api["ApiId"]
|
||||||
|
)
|
||||||
|
|
||||||
print("Deleting old function...")
|
print("Deleting old function...")
|
||||||
print("------------------------------------")
|
print("------------------------------------")
|
||||||
try:
|
try:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user