Open Selkubi opened 6 months ago
We have decided to go for a more comprehensive cloud architecture with 2 lambda functions that puts data in the dynamoDB table. The architecture looks like the below image from Magno
There is a problem with the access permission given to the services (in the pipeline written above). I am trying to find what the problem is and update the workflow accordingly.
Here is how to create the necessary connections between S3, DynamoDB and the lambda function
Step 1: Create an S3 Bucket
Go to the S3 console:
Create a bucket:
your-bucket-name
).eu-central-1
).Step 2: Create an SNS Topic
This is a notification tool necessary to receive the experiment_id emails.
Go to the SNS console:
Create a topic:
obelix_test
).Create a subscription:
Step 3: Create a DynamoDB Table
Go to the DynamoDB console:
Create a table:
obelix_test-empty
).Exp_ID
) as a string or number depending on your use case.Step 4: Create an IAM Role for Lambda
This was necessary to work within the DCC sandbox. I am not sure how this will work like in the Obelix AWS account.
Go to the IAM console:
Create a role:
Attach policies:
Name the role:
lambda-s3-dynamodb-sns-role
).Step 5: Create the Lambda Function
Go to the Lambda console:
Create a function:
s3-to-dynamodb-sns
).lambda-s3-dynamodb-sns-role
).Configure the function:
Add environment variables:
SNS_TOPIC_ARN
with the value of your SNS topic ARN.Step 6: Set up the S3 Trigger
Step 7: Configure the bucket policy
To give the lambda function access to the s3 bucket you're using, make sure that the S3 bucket has the right policy. eg In this code, he principal/AWS field comes from the IAM of the 'role' that you have created. The ARN is shown there. { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": "arn:aws:iam::058264498638:role/lambda-s3-dynamodb-sns-role-obelix" }, "Action": [ "s3:GetObject", "s3:ListBucket" ], "Resource": [ "arn:aws:s3:::s3-test-bucket-obelix", "arn:aws:s3:::s3-test-bucket-obelix/*" ] } ] } Make sure to change the princible and the bucket names are correct
Step 8: Test the Function
Upload a test file:
Check the results: