Trying to read ssm parameter and working fine but write as text and uploading inside my bucket its not happening please find below code

0 votes
import boto3
import os


client = boto3.client('ssm')
s3 = boto3.client("s3")


def lambda_handler(event, context):
    parameter = client.get_parameter(Name='otherparam', WithDecryption=True)
    #print(parameter)
    return parameter ['Parameter']['Value']
    #file = open("/sample.txt", "w")
    #file.write(parameter)
    #file.close
    with open("/tmp/log.txt", "w") as f:
        file.write(parameter)
    
    s3.upload_file("/tmp/log.txt", "copys3toecsbucket-117", "logs.txt")
    #bucket = "copys3toecsbucket-117"
    #file = "/sample.txt"
    #response = s3_client.put_object(Body=file,Bucket='bucket',key='file')
    print(response)
    

trying in aws lambda only. how to convert ssm parameter into text file which will be trigger file for next step and upload in s3 bucket?

Dec 22, 2022 in AWS by Tejashwini
• 3,820 points
547 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

0 votes
1 answer
+1 vote
2 answers

Want my AWS s3 Bucket to read Name from CloudWatch Event

CloudTrail events for S3 bucket level operations ...READ MORE

answered May 28, 2018 in AWS by Cloud gunner
• 4,670 points
2,078 views
+1 vote
1 answer

Redirect working from www.xyz.com to https://xyz.com but not from https://www.xyz.com

Make sure you have created the certificate ...READ MORE

answered Aug 28, 2018 in AWS by Priyaj
• 58,020 points
1,676 views
+2 votes
1 answer

<Error> <Code>AccessDenied</Code> not able to connect s3 bucket.

Hi@akhtar, You have to give permissions to your ...READ MORE

answered Jun 3, 2020 in AWS by MD
• 95,460 points
29,412 views
0 votes
1 answer

AWS S3 uploading hidden files by default

versioning is enabled in your bucket. docs.aws.amazon.com/AmazonS3/latest/user-guide/….... the ...READ MORE

answered Oct 4, 2018 in AWS by Priyaj
• 58,020 points
5,957 views
–1 vote
1 answer

How to decrypt the encrypted S3 file using aws-encryption-cli --decrypt

Use command : aws s3 presign s3://mybucket/abc_count.png you get ...READ MORE

answered Oct 22, 2018 in AWS by Priyaj
• 58,020 points
5,204 views
0 votes
1 answer

Import my AWS credentials using python script

Using AWS Cli  Configure your IAM user then ...READ MORE

answered Nov 16, 2018 in AWS by Jino
• 5,820 points
2,867 views
0 votes
2 answers
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP