I have deployed an s3 bucket via terraform using the following code:
resource "aws_s3_bucket" "storage-dev" {
bucket = "storage-dev"
}
resource "aws_s3_bucket_server_side_encryption_configuration" "storage-dev-encryption" {
bucket = aws_s3_bucket.storage-dev.id
rule {
apply_server_side_encryption_by_default {
sse_algorithm = "AES256"
}
}
}
resource "aws_s3_bucket_versioning" "storage-dev_versioning_policy" {
bucket = aws_s3_bucket.storage-dev.id
versioning_configuration {
status = "Disabled"
}
}
resource "aws_s3_bucket_public_access_block" "storage-dev_public_access" {
bucket = aws_s3_bucket.storage-dev.id
block_public_acls = false
block_public_policy = false
ignore_public_acls = false
restrict_public_buckets = false
}
output "s3_bucket_arn" {
value = aws_s3_bucket.storage-dev.arn
description = "The ARN of the S3 bucket"
}
I have a serverless aurora postgres v1 database that I'm trying to interact with, and so far the easiest method I've found an example of is querying it from a lambda function (https://github.com/RekhuGopal/PythonHacks/blob/main/AWS_RDS_Arora_Serverless/Copy_s3_to_rds_arora_Serverless.py). I want to move some data from the s3 bucket to aurora, so I set up a lambda function in the same vpc as the aurora (an aws default vpc), and tried running the following code:
import json
import json
import os
import boto3
import csv
def lambda_handler(event, context):
AWS_REGION = "##-####-1"
client = boto3.client("s3", region_name=AWS_REGION)
response = client.list_buckets()
print("Listing Amazon S3 Buckets:")
for bucket in response['Buckets']:
print(f"-- {bucket['Name']}")
print("donwloaded successfully....")
return {
'statusCode': 200,
'body': json.dumps('Hello from Lambda!')
}
Whenever I run the lambda it times out with the following error:
"errorMessage": "2023-05-26T11:37:58.483Z ffd29809-2238-####-9596-ef0c0fa07d37 Task timed out after 300.10 seconds"
As far as I know s3 buckets don't need to be in the same vpc as the resource trying to access them, so I can't figure out what's causing this connectivity issue. Any help would be much appreciated.