Skip to content

Commit

Permalink
add legacy lambda
Browse files Browse the repository at this point in the history
  • Loading branch information
iakov-aws committed Nov 12, 2023
1 parent 079b705 commit b1fb4ad
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion cfn-templates/cid-cfn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -450,13 +450,46 @@ Resources:
EncryptionOption: SSE_S3
OutputLocation: !If [ NeedAthenaQueryResultsBucket, !Sub 's3://${MyAthenaQueryResultsBucket}/', !Sub 's3://${AthenaQueryResultsBucket}/' ]

#legacy version. Replaced by CustomResourceFunctionInit but we cannot remove it completely as it was removing workgroup on deletion of resource.
CustomRessourceFunctionInit:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub CidInitialSetup-DoNotRun${Suffix}
Role: !GetAtt 'InitLambdaExecutionRole.Arn'
Description: "CID legacy setup"
Runtime: python3.10
Code:
ZipFile: |
import json
import urllib3
# This is legacy lambda. You can delete it. This was created to disable delete workgroup functionality.
def lambda_handler(event, context):
url = event.get('ResponseURL')
body = {}
body['Status'] = 'SUCCESS'
body['Reason'] = 'legacy'
body['PhysicalResourceId'] = 'keep_it_constant'
body['StackId'] = event.get('StackId')
body['RequestId'] = event.get('RequestId')
body['LogicalResourceId'] = event.get('LogicalResourceId')
body['NoEcho'] = False
if not url: return
json_body = json.dumps(body)
try:
http = urllib3.PoolManager()
response = http.request('PUT', url, body=json_body, headers={'content-type' : '', 'content-length' : str(len(json_body))}, retries=False)
print(f"Status code: {response}")
except Exception as exc:
print("Failed sending PUT to CFN: " + str(exc))
CustomResourceFunctionInit:
Type: AWS::Lambda::Function
Properties:
FunctionName: !Sub "CidCustomResourceFunctionInit-DoNotRun${Suffix}"
Role: !GetAtt 'InitLambdaExecutionRole.Arn'
Description: "Do what CFN cannot: start crawler, delete bucket with objects and delete an non empty workgroup"
Runtime: python3.9
Runtime: python3.10
Architectures: [ x86_64 ] #Compatible with arm64 but it is not supported in all regions
MemorySize: 128
Timeout: 300
Expand Down

0 comments on commit b1fb4ad

Please sign in to comment.