List of all roles with attached policies with Boto3

Found a useful thread here that helped me get part of a script to get a list of all roles and its attached policies: response = client.list_attached_role_policies( RoleName=’MyRoleName’ ) I am …

Getting “not all arguments converted during string formatting” exception in AWS Lambda function

I am trying to write an AWS Lambda function in python that retrieves records from a table. I have no trouble running the code locally. However, when I run the code in AWS Lambda function, I get the …

when calling the UpdateMethod operation getting invalid path error for /methodIntegration/uri

I’m updating an API in AWS API Gateway. This is my lambda function: response = client.update_method( restApiId=rest_api_id, resourceId=resource_id, …

AWS Lambda – Combine multiple CSV files from S3 into one file

I am trying to understand and learn how to get all my files from the specific bucket into one csv file. I have the files that are like logs and are always in the same format and are kept in the same …

Update values in Dynamodb by modifying the previous values

I created a dynamodb table and I am using the lambda function to update the values in the dynamodb table. The problem with my function for updating the values, not modifying the older values which …

Unable to import module ‘lambda_function’: No module named *

I am trying to run a python lambda function that uses additional packages. However whenever I upload the .zip file to the lambda console I get the error: { “errorMessage”: “Unable to …

Pyathena is super slow compared to querying from Athena

I run a query from AWS Athena console and takes 10s. The same query run from Sagemaker using PyAthena takes 155s. Is PyAthena slowing it down or is the data transfer from Athena to sagemaker so time …

Include only .gz extension files from S3 bucket

I want to process/download .gz files from S3 bucket. There are more than 10,000 files on S3 so I am using import boto3 s3 = boto3.resource(‘s3’) bucket = s3.Bucket(‘my-bucket’) objects = bucket….

AWS lambda expected intended block error in Python

I am following the below document to connect to Cloudwatch logs to ELK. https://medium.com/@sohit_kumar/streaming-aws-cloudwatch-logs-to-your-own-elk-logging-solution-2bbd32f25100 I get a “expected an indented block” syntax error in python for this line. try: logs = awslogs_handler(s, event) Can someone help me figure this out? Not sure what im missing. Thanks! Answer You need to use something like this: An indent block(contains four whitespaces) are required. You can read more here

Serving static files in elastick beanstalk

I’m deploying a python3 flask application in aws elasitc beanstalk (Amazon Linux 2 platform). The folder structure is as follows: In the template files, importing of static resources are defiled as: i.e. JS file: In the EB configurations, I’ve defined the static resources as below But the problem is, these resources are not loading and giving 404. i.e.: https://example.com/static/js/jquery.js cannot be loaded. But if I try https://example.com/js/jquery.js, it works. Have I done the configurations wrong?? Answer Based on the comments. The issue was due to overwriting /static path. In python EB environments, /static path is used by default to server