added explanation about the necessary role for the function and clarification of the use of credentials in localstack

This commit is contained in:
Sebastian Rieger
2022-06-22 16:28:10 +02:00
parent a39227feea
commit 20f012a42d
5 changed files with 32 additions and 29 deletions

View File

@ -9,28 +9,35 @@ from botocore.exceptions import ClientError
#
################################################################################################
# main change from real AWS Academy access to local emulated localstack is to change the endpoint
# other than that the same tools (boto3, aws-cli, aws-cdk etc. can be used)
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
# 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
# a bucket in S3 will be created to store the counter bucket names need to be world-wide unique ;)
# Hence we create a bucket name that contains your group number and the current year.
# The counter will be stores as key (file) "us-east-1" in the bucket (same name as our default region)
# in the bucket and expects a number in it to increase
groupNr = 22
currentYear = date.today().year
globallyUniqueS3GroupBucketName = "cloudcomp-counter-" + str(currentYear) + "-group" + str(groupNr)
# region = 'eu-central-1'
region = 'us-east-1'
functionName = 'cloudcomp-counter-lambda-demo'
# The Lambda function will run using privileges of a role, that allows the function to access/create
# resources in AWS (in this case read/write to S3). In AWS Academy you need to use the role that
# use created for your student account in the lab (see lab readme).
# 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
#
# 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'
# For localstack you can use any role Arn and every secret and access key. Hence you can also use
# existing AWS Academy credentials to connect to localstack
################################################################################################
#
# boto3 code