amazon-web-services

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

Send StringSet to DynamoDB from JSON file using Boto3

Send StringSet to DynamoDB from JSON file using Boto3 Question: Problem description How can I create an item to send to DynamoDB from a JSON file, and have the type in DynamoDB end up as a StringSet as defined in AWS documentation using Python? I am using the Boto3 put_item API. Approaches attempted I’ve found …

Total answers: 2

Building an AMI using Packer with Python & Python modules (using pip) installed via powershell script

Building an AMI using Packer with Python & Python modules (using pip) installed via powershell script Question: Using Packer, I am trying to create a Windows AMI with Python + the cryptography module installed. Here is the installation command I’m using for Python: Invoke-Expression "python-3.6.8-amd64.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0" Standalone that works fine. If I …

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

Lambda function triggered when adding files to a S3 bucket

Lambda function triggered when adding files to a S3 bucket Question: I am having a problem with the behavior of a Lambda function. Ultimately, I want my lambda function to read some information about json files that I upload to my S3 bucket. Here is a test function: import boto3 import json s3=boto3.client(‘s3’) def LambdaHandler(event,context): …

Total answers: 2

Python Lambda Function returning KeyError

Python Lambda Function returning KeyError Question: Currently trying to create a (simple) Lambda function in AWS using Python 3.8: import json import urllib3 def lambda_handler(event, context): status_code = 200 array_of_rows_to_return = [ ] http = urllib3.PoolManager() try: event_body = event["body"] payload = json.loads(event_body) rows = payload["data"] for row in rows: row_number = row[0] from_currency = …

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

Saving a json/txt file to S3 from Lambda

Saving a json/txt file to S3 from Lambda Question: I am using lambda to run a program. Once it is run I need to save some data as a json file or txt. I tried to see if there is a way to write a file in lambda and save it but there are no …

Total answers: 1

multiline string substitution in python

Multiline string substitution in Python Question: I am trying this out: account = "11111111111" tenant_name= "Demo" project_name= "demo" sns_access_policy = """{ "Version": "2012-10-17", "Statement": [ { "Sid": "0", "Effect": "Allow", "Principal": { "Service": "codestar-notifications.amazonaws.com" }, "Action": "sns:Publish", "Resource": "arn:aws:sns:eu-west-1:{account_id}:{tenant_name}-{project_name}-pipeline-monitoring" } ] }""" sns_access_policy = sns_access_policy.replace("{account_id}",account).replace("{tenant_name}",tenant_name).replace("{project_name}",project_name) This is doing my work, but I am looking for …

Total answers: 1