-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveStack.py
More file actions
27 lines (24 loc) · 936 Bytes
/
removeStack.py
File metadata and controls
27 lines (24 loc) · 936 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import json
import boto3
import os
client = boto3.client('cloudformation')
def lambda_handler(event, context):
# TODO implement
stackName = event["id"]
print(stackName)
capabilities = ['CAPABILITY_IAM']
lambda_client = boto3.client('lambda')
role_response = (lambda_client.get_function_configuration(
FunctionName = os.environ['AWS_LAMBDA_FUNCTION_NAME'])
)
print(role_response)
roleArn = role_response['Role']
resourceTypes = ['AWS::*']
response = client.delete_stack(
StackName=stackName,
RoleARN=roleArn
)
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}