Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cloud-computing-msc-ai-examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Sebastian Rieger
cloud-computing-msc-ai-examples
Commits
bbaa2ef2
Commit
bbaa2ef2
authored
3 years ago
by
Sebastian Rieger
Browse files
Options
Downloads
Patches
Plain Diff
retrieve Role ARN, and removed AWS Academy hints in localstack example
parent
d796ecc3
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
example-projects/counter-demo/aws-lambda-localstack/start.py
+7
-16
7 additions, 16 deletions
example-projects/counter-demo/aws-lambda-localstack/start.py
example-projects/counter-demo/aws-lambda/start.py
+13
-4
13 additions, 4 deletions
example-projects/counter-demo/aws-lambda/start.py
with
20 additions
and
20 deletions
example-projects/counter-demo/aws-lambda-localstack/start.py
+
7
−
16
View file @
bbaa2ef2
...
@@ -27,9 +27,9 @@ functionName = 'cloudcomp-counter-lambda-demo'
...
@@ -27,9 +27,9 @@ functionName = 'cloudcomp-counter-lambda-demo'
# see ARN for AWS Academy LabRole function here:
# 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
# https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/LabRole?section=permissions
# role
Name
= 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# role
Arn
= 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# role
Name
= 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
# role
Arn
= 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
role
Name
=
'
arn:aws:iam::488766701848:role/LabRole
'
role
Arn
=
'
arn:aws:iam::488766701848:role/LabRole
'
################################################################################################
################################################################################################
#
#
...
@@ -104,7 +104,7 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
...
@@ -104,7 +104,7 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
response
=
lClient
.
create_function
(
response
=
lClient
.
create_function
(
FunctionName
=
functionName
,
FunctionName
=
functionName
,
Runtime
=
'
python3.9
'
,
Runtime
=
'
python3.9
'
,
Role
=
role
Name
,
Role
=
role
Arn
,
Code
=
{
Code
=
{
'
ZipFile
'
:
zipfileContent
'
ZipFile
'
:
zipfileContent
},
},
...
@@ -118,18 +118,9 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
...
@@ -118,18 +118,9 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
)
)
lambdaFunctionARN
=
response
[
'
FunctionArn
'
]
lambdaFunctionARN
=
response
[
'
FunctionArn
'
]
print
(
"
Lambda Function and S3 Bucket to store the counter are available. Sadly, AWS Academy labs do not allow
\n
"
print
(
"
Lambda Function and S3 Bucket to store the counter are available.
\n
"
"
creating an API gateway to be able to access the Lambda function directly via HTTP from the browser, as
\n
"
"
shown in https://348yxdily0.execute-api.eu-central-1.amazonaws.com/default/cloudcomp-counter-demo.
\n
"
"
\n
"
"
\n
"
"
However you can now run invoke-function.py to view an increment the counter. You can also use
\n
"
"
You can now run invoke-function.py to view an increment the counter.
\n
"
"
the test button in the Lambda AWS console. In this case you need to send the content
\n
"
"
\n
"
"
{
\n
"
"
\"
input
\"
:
\"
1
\"\n
"
"
}
\n
"
"
\n
"
"
to increment the counter by 1.
\n
"
"
Try to understand how Lambda can be used to cut costs regarding cloud services and what its pros
\n
"
"
Try to understand how Lambda can be used to cut costs regarding cloud services and what its pros
\n
"
"
and cons are.
\n
"
)
"
and cons are.
\n
"
)
...
...
This diff is collapsed.
Click to expand it.
example-projects/counter-demo/aws-lambda/start.py
+
13
−
4
View file @
bbaa2ef2
...
@@ -25,9 +25,9 @@ functionName = 'cloudcomp-counter-lambda-demo'
...
@@ -25,9 +25,9 @@ functionName = 'cloudcomp-counter-lambda-demo'
# see ARN for AWS Academy LabRole function here:
# 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
# https://us-east-1.console.aws.amazon.com/iamv2/home?region=us-east-1#/roles/details/LabRole?section=permissions
# role
Name
= 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# role
Arn
= 'arn:aws:iam::309000625112:role/service-role/cloudcomp-counter-demo-role-6rs7pah3'
# role
Name
= 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
# role
Arn
= 'arn:aws:iam::919927306708:role/cloudcomp-s3-access'
role
Name
=
'
arn:aws:iam::488766701848:role/LabRole
'
role
Arn
=
'
arn:aws:iam::488766701848:role/LabRole
'
################################################################################################
################################################################################################
#
#
...
@@ -46,11 +46,20 @@ def cleanup_s3_bucket(s3_bucket):
...
@@ -46,11 +46,20 @@ def cleanup_s3_bucket(s3_bucket):
client
=
boto3
.
setup_default_session
(
region_name
=
region
)
client
=
boto3
.
setup_default_session
(
region_name
=
region
)
iamClient
=
boto3
.
client
(
'
iam
'
)
s3Client
=
boto3
.
client
(
'
s3
'
)
s3Client
=
boto3
.
client
(
'
s3
'
)
s3Resource
=
boto3
.
resource
(
'
s3
'
)
s3Resource
=
boto3
.
resource
(
'
s3
'
)
lClient
=
boto3
.
client
(
'
lambda
'
)
lClient
=
boto3
.
client
(
'
lambda
'
)
apiClient
=
boto3
.
client
(
"
apigatewayv2
"
)
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
(
"
Deleting old function...
"
)
print
(
"
------------------------------------
"
)
print
(
"
------------------------------------
"
)
try
:
try
:
...
@@ -93,7 +102,7 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
...
@@ -93,7 +102,7 @@ with open('lambda-deployment-archive.zip', mode='rb') as file:
response
=
lClient
.
create_function
(
response
=
lClient
.
create_function
(
FunctionName
=
functionName
,
FunctionName
=
functionName
,
Runtime
=
'
python3.9
'
,
Runtime
=
'
python3.9
'
,
Role
=
role
Name
,
Role
=
role
Arn
,
Code
=
{
Code
=
{
'
ZipFile
'
:
zipfileContent
'
ZipFile
'
:
zipfileContent
},
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment