retrieve Role ARN, and removed AWS Academy hints in localstack example

This commit is contained in:
Sebastian Rieger
2022-06-21 14:41:56 +02:00
parent d796ecc305
commit bbaa2ef220
2 changed files with 20 additions and 20 deletions

View File

@ -25,9 +25,9 @@ functionName = 'cloudcomp-counter-lambda-demo'
# see ARN for AWS Academy LabRole function here:
# https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/LabRole?section=permissions
# roleName = 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# roleName = 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
roleName = 'arn:aws:iam::488766701848:role/LabRole'
# roleArn = 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# roleArn = 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
roleArn = 'arn:aws:iam::488766701848:role/LabRole'
################################################################################################
#
@ -46,11 +46,20 @@ def cleanup_s3_bucket(s3_bucket):
client = boto3.setup_default_session(region_name=region)
iamClient = boto3.client('iam')
s3Client = boto3.client('s3')
s3Resource = boto3.resource('s3')
lClient = boto3.client('lambda')
apiClient = boto3.client("apigatewayv2")
print("Getting AWS Academy LabRole ARN...")
print("------------------------------------")
response = iamClient.list_roles()
for role in response["Roles"]:
if role["RoleName"] == "LabRole":
roleArn = role["Arn"]
print(roleArn)
print("Deleting old function...")
print("------------------------------------")
try:
@ -93,7 +102,7 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
response = lClient.create_function(
FunctionName=functionName,
Runtime='python3.9',
Role=roleName,
Role=roleArn,
Code={
'ZipFile': zipfileContent
},