| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- # lambda_code
- import json
- import boto3
- def lambda_handler(event,context):
- client = boto3.client('ssm')
- try:
- msg =json.loads(event['body'])
- sg = msg['secret_code']
- print("secret " + sg)
- client.put_parameter(Name="Secret",Value=sg,Type='String',Overwrite=True)
- except:
- print("NO")
- return {
- "statusCode": 200,
- "headers": {
- "Content-Type": "application/json",
- },
- "body": json.dumps(event, indent=4),
- }
- # -----------------------------
- import boto3
- client = boto3.client('ssm')
- respond = client.get_parameter(Name='Secret')
- code_ori = respond['Parameter']['Value']
- def alter(file,old_str,new_str):
- file_data = ""
- with open(file, "r", encoding="utf-8") as f:
- for line in f:
- if old_str in line:
- line = line.replace(line,new_str)
- file_data += line
- with open(file,"w",encoding="utf-8") as f:
- f.write(file_data)
- f.close()
- code_pro = code_ori.replace("'", '')
- code = f"secret_code = '{code_pro}'"
- alter("/conf.toml", "secret_code", cod
|