Last active
March 21, 2023 07:56
-
-
Save alvonx/775bce3416eebf00caa85292a8bbf10c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import json | |
import boto3 | |
def lambda_handler(event, context): | |
page_name = event['queryStringParameters']['page'] | |
page_start_time = event['queryStringParameters']['starttime'] | |
print(page_name) | |
print(page_start_time) | |
ssm_client = boto3.client('ssm') | |
response = ssm_client.send_command( | |
DocumentName='AWS-RunShellScript', | |
Parameters={ | |
'commands': [ | |
f"rm -rf /var/www/html/{page_name}.html" | |
] | |
}, | |
InstanceIds=['i-<instance-id>'] | |
) | |
return { | |
'statusCode': 200, | |
'headers': { | |
'Access-Control-Allow-Headers': 'Content-Type', | |
'Access-Control-Allow-Origin': '*', | |
'Access-Control-Allow-Methods': 'OPTIONS,POST,GET' | |
}, | |
'body': json.dumps({ | |
"msg": "page-deleted" | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment