If you type a command that leaves authentication information, such as the mysql command, in the shell in the lambda code, the authentication information will remain in the log.
What should I do to avoid leaving authentication information in the log?
Here is an example code:
def lambda_handler(event, context):
try:
# all running EC2 instances
ec2_resp=ec2.describe_instances(Filters=[{'Name':'instance-state-name', 'Values':['running']}])
ec2_count=len(ec2_resp['Reservations'])
ifec2_count == 0:
logger.info ('No EC2 is running')
# Get All InstanceID
instances=[i["InstanceId"] for linec2_resp["Reservations"] for ir["Instances"]]
US>ssm.send_command(
InstanceIds=instances,
DocumentName="AWS-RunShellScript",
Parameters = {
"commands": [
"mysql-u {username} --password={password}-e'DROP DATABASE db2';
],
"executionTimeout": ["3600"]
},
)
except Exception as:
logger.error(e)
raise
Not only Lambda, but also SSM RunCommand will have logs, and it may be in EC2.In other words, it is a problem when you include a password string in the command line as shellscript regardless of whether it is python or lambda.
Mysql himself describes it as an End User Guidelines for Password Security.
Another option is
There seems to be , but considering security, the only option seems to be to save the file in EC2.
Alternatively, the password is currently
Lambda→SSM RunCommand→mysql
The reason is that it crosses functions with , so for example, you can save the password in SSM Parameters and retrieve it from EC2 with awscli without going through Lambda and SSM RunCommand.
mysql-u {username} --password=$(awssm get-parameter --name parameter name --with-decryption --query Parameter.Value --output text) -e'DROP DATABASE db2'
MySQL does not solve the problem of leaving passwords on command lines, but it does not remain in various AWS logs as you may have asked.
617 Uncaught (inpromise) Error on Electron: An object could not be cloned
911 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
572 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
610 GDB gets version error when attempting to debug with the Presense SDK (IDE)
© 2024 OneMinuteCode. All rights reserved.