S3 event triggering event - Unable to validate the following destination configurations

37 views Asked by At

i am trying to perform a small project of s3 event triggering using shell scripting but i am getting following error :

An error occurred (InvalidArgument) when calling the PutBucketNotificationConfiguration operation: Unable to validate the following destination configurations ++ aws sns create-topic --name s3-lambda-sns --output json ++ jq -r .TopicArn

code used for this configuration:

# Create an S3 event trigger for the Lambda function
LambdaFunctionArn="arn:aws:lambda:us-east-1:$aws_account_id:function:s3-lambda-function"
aws s3api put-bucket-notification-configuration \
  --region "$aws_region" \
  --bucket "$bucket_name" \
  --notification-configuration '{
    "LambdaFunctionConfigurations": [{
        "LambdaFunctionArn": "'"$LambdaFunctionArn"'",
        "Events": ["s3:ObjectCreated:*"]
    }]
}'

for above i checked few things online which suggested to check permissions and are as follows:

# Create IAM Role for the project
role_response=$(aws iam create-role --role-name s3-lambda-sns --assume-role-policy-document '{
  "Version": "2012-10-17",
  "Statement": [{
    "Action": "sts:AssumeRole",
    "Effect": "Allow",
    "Principal": {
      "Service": [
         "lambda.amazonaws.com",
         "s3.amazonaws.com",
         "sns.amazonaws.com"
      ]
    }
  }]
}')

# Add Permissions to S3 Bucket to invoke Lambda
aws lambda add-permission \
  --function-name "$lambda_func_name" \
  --statement-id "s3-lambda-sns" \
  --action "lambda:InvokeFunction" \
  --principal s3.amazonaws.com \
  --source-arn "arn:aws:s3:::$bucket_name"



# Attach Permissions to the Role
aws iam attach-role-policy --role-name $role_name --policy-arn arn:aws:iam::aws:policy/AWSLambda_FullAccess
aws iam attach-role-policy --role-name $role_name --policy-arn 
arn:aws:iam::aws:policy/AmazonSNSFullAccess

Please suggest the way forward.

1

There are 1 answers

0
ddtraveller On

It looks like the error is coming from this command; aws s3api put-bucket-notification-configuration

The error is saying you don't have permissions to call lambda or the lambda doesn't exist or the path/name is off a bit, I think.

This post might help you;

https://repost.aws/questions/QU03OW1IjMRvGTTyn3ahV7xA/put-bucket-notification-configuration-question