Skip to content

Commit 608a675

Browse files
committed
add sns invoke permissions to lambda
1 parent 48b8e93 commit 608a675

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

setup_AWS.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ def setup():
146146
print ('Created Monitor Lambda Function.')
147147
except lmbda.exceptions.ResourceConflictException:
148148
print ('Skipping creation of Monitor Lambda Function. Already exists.')
149+
try:
150+
lmbda.add_permission(
151+
FunctionName='Monitor',
152+
StatementId='InvokeBySNS',
153+
Action='lambda:InvokeFunction',
154+
Principal='sns.amazonaws.com')
155+
except lmbda.exceptions.ResourceConflictException:
156+
print ('Monitor Lambda Function already has SNS invoke permission.')
149157

150158
def destroy():
151159
# Delete roles
@@ -164,7 +172,7 @@ def destroy():
164172
iam.delete_role(RoleName="LambdaFullAccess")
165173

166174
# Delete Monitor Lambda function
167-
lmbda.delete_function(FunctionName="MonitorTEST")
175+
lmbda.delete_function(FunctionName="Monitor")
168176

169177
# Delete Monitor SNS topic
170178
# create_topic is idempotent so we use it to return ARN since topic already exists

0 commit comments

Comments
 (0)