Open Selkubi opened 1 month ago
Problems and current solutions
1- The S3 bucket does not process UTF8 CSV as good as simple CSV (at least the ones coming out of my excel. Try to use always the csv(comma delimited) when converting as possible (this can not be fixed by defining type in the lambda function using open(file, mode='r', encoding='utf-8')
)
s3-metadata-obelix
).eu-central-1
).Ligand#
as a string or number depending on your use case.AmazonS3ReadOnlyAccess
(for read access to the S3 bucket).AmazonDynamoDBFullAccess
(for read and write access to DynamoDB).{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Effect": "Allow",
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::<s3-bucket-name>/*",
"arn:aws:s3:::<s3-bucket-name>"
]
},
{
"Effect": "Allow",
"Action": [
"dynamodb:*"
],
"Resource": "arn:aws:dynamodb:eu-central-1:058264498638:table/<db-table-name>"
},
{
"Effect": "Allow",
"Action": [
"dynamodb:ListTables",
"dynamodb:Scan",
"dynamodb:UpdateItem"
],
"Resource": "arn:aws:dynamodb:eu-central-1:058264498638:table/<db-table-name>/*"
}
]
}
lambda_import_csv
) and click Create role.s3-metadata-obelix
).lambda_import_csv
).s3-metadata-obelix
) and DynamoDB table (eg. obelixtest_sort_key
).s3-metadata-obelix
).YOUR_ACCOUNT_ID
with the AWS Account ID and update the bucket name if necessary:
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::058264498638:role/lambda_import_csv"
},
"Action": [
"s3:GetObject",
"s3:ListBucket"
],
"Resource": [
"arn:aws:s3:::s3-metadata-obelix",
"arn:aws:s3:::s3-metadata-obelix/*"
]
}
]
}
s3-metadata-obelix
).obelixtest_sort_key
table).{
"Records": [
{
"s3": {
"bucket": {
"name": "s3-metadata-obelix"
},
"object": {
"key": "metadata_all.csv"
}
}
}
]
}
S3-to-dynamodb-sns-metadata-f37bb411-26a1-4833-909c-ee93bf358218.zip
To test querying from the DynamoDB table from your own environment, you need boto3. with that you can query according to any attribute or key. I've attached an example py script, ObelixNestedQuery.zip, to do simple queries. Make sure to write your own dynamodb Table name for the table variable and have the right authentications to be able to query from your IDE (for Vs code, you can use AWS CLI extension for this among others).
This function should get the data in a metadata format, matches it with the Exp_ID that is manually entered in the metadata and appends all the new information under a dictionary called "meta". This way we can separate dat and metadata when querying and this is especially helpful when we dont know the names of the attributes that will be used in the queries.