boto3

Error No file found while converting file present in s3 using boto3

Error No file found while converting file present in s3 using boto3 Question: I have a csv files present in s3 I am able to print bucket name, key and file content But while converting to json I am getting Error no file found There is only one csv file which is of 1 KB …

Total answers: 2

Cannot find AWS_KEY_ID to connect to Boto3

Cannot find AWS_KEY_ID to connect to Boto3 Question: I am just getting started using Boto3 to connect to AWS, and I cannot get it to work. This is my code: #client client = boto3.client(‘s3’) list_bucket=client.list_buckets() print(list_bucket) This is the error message I receive: botocore.exceptions.NoCredentialsError: Unable to locate credentials I tried to set up CLI access …

Total answers: 1

Boto3 Dynamodb list_append Invalid type for parameter ExpressionAttributeNames type: <class 'set'>, valid types: <class 'dict'>

Boto3 Dynamodb list_append Invalid type for parameter ExpressionAttributeNames type: <class 'set'>, valid types: <class 'dict'> Question: Error message is throwing me. I have update_item updating an existing list. When I put everything in the UpdateExpression, it works fine. When I use the equivalent with ExpressionAttributeNames, I get the error in the title. They look equivalent …

Total answers: 1

Create EC2 instance, start instance and run Linux command using Boto3

Create EC2 instance, start instance and run Linux command using Boto3 Question: I am trying to create an AWS EC2 instance, start it, execute a simple Linux command and print the output. However, I keep getting: botocore.errorfactory.InvalidInstanceId: An error occurred (InvalidInstanceId) when calling the SendCommand operation: Instances [[the_instance_id]] not in a valid state for account …

Total answers: 1

Add key/value pair to existing secrets path in AWS secrets manager without overwriting it using boto3

Add key/value pair to existing secrets path in AWS secrets manager without overwriting it using boto3 Question: I have this code which I’m using to put secrets in AWS secrets manager class SecretsManagerSecret: """Encapsulates Secrets Manager functions.""" def __init__(self, env): """ :param env: Environment on which DAG is running """ self.secretsmanager_client = boto3.client("secretsmanager", region_name="us-east-1") self.env …

Total answers: 1

AccessDenied when calling Boto3 assume_role from EC2 even with service principal

AccessDenied when calling Boto3 assume_role from EC2 even with service principal Question: I’m running into an issue when trying to have a Python script running on an EC2 instance assume a role to perform S3 tasks. Here’s what I have done. Created a IAM role with AmazonS3FullAccess permissions and got the following ARN: arn:aws:iam::<account_number>:role/<role_name> The …

Total answers: 1

boto3 get_query_runtime_statistics sometimes not returning "rows" data

boto3 get_query_runtime_statistics sometimes not returning "rows" data Question: I have a lambda that attempts to find out whether a previously executed athena query has returned any rows or not. To do so I am using the boto3 function get_query_runtime_statistics and then extracting the "Rows" data: response = athena_client.get_query_runtime_statistics(QueryExecutionId=query_id) row_count = response["QueryRuntimeStatistics"]["Rows"]["OutputRows"] However, in a previous …

Total answers: 2

how to Read .Sql file stored in S3 containing multiple SQL statements

how to Read .Sql file stored in S3 containing multiple SQL statements Question: I have a .sql file stored in S3 location in AWS which contains multiple SQL statements separated by semi colon as below: Query1; _______________ Query2; _______________ Query3; tried using 2 methods in AWS Glue job to read this S3 .sql file but …

Total answers: 1

How to get a specific key in a list of dicts in JSON

How to get a specific key in a list of dicts in JSON Question: I am trying to get the StackId through list_stacks() of the last deleted stack with the name BastionInfraStack (the most recent one). The list_stacks() command returns the following: { "StackSummaries": [ { "StackId": "arn:aws:cloudformation:us-east-2:111111111:stack/Dev-BastionInfraStack/34deb540-9c2f-11ed-90a7-022b01b65a64", "StackName": "Dev-BastionInfraStack", "CreationTime": "2023-01-24T21:36:48.468000+00:00", "LastUpdatedTime": "2023-01-24T21:37:26.782000+00:00", "DeletionTime": …

Total answers: 1

Clone private github repo to launched EC2 instance

Clone private github repo to launched EC2 instance Question: I’m building a scrip that launches and connects to an EC2 instance. After all setup of the instance I have to copy my private repo to it, and then run it. The code works fine for public repo. Also if I manually launch an instance, connect …

Total answers: 1