| by Arround The Web | No comments

How to Solve Execution Role Error to Use Lambda With SQS Service?

AWS Lambda function allows the user to build backend code for the application on the cloud as it can create serverless resources. The function can also be integrated with AWS services to use with other services. Each function has its execution role attached to it that must contain the necessary permissions to integrate it with other services.

This guide will explain the process of solving the permission attached to the IAM execution role error for using AWS Lambda with Amazon SQS service.

How to Use Lambda With Amazon SQS Service?

To use the Lambda function with Amazon SQS service, it is required to create a Lambda function from the AWS Lambda service dashboard. After creating the Lambda function, simply click on the “Add trigger” button to use the Amazon SQS service with the function:

Select the SQS service to configure the trigger and then type the ARN of the Amazon SQS queue resource:

Scroll down the page to click on the “Add” button to complete the configuration of the Trigger:

The error has occurred that the execution role with the Lambda function does not have enough permissions to add the trigger with it:

How to Solve Execution Role Error to Use Lambda With SQS Service?

To solve the above-mentioned error, simply visit the IAM dashboard from the AWS Console:

Click on the “Roles” button from the left panel to head to its page from the IAM dashboard:

Create IAM Role

On this page, simply click on the “Create role” button to start configuring it:

Select the “AWS service” option as the trusted entity type to create the IAM role for:

Select the Lambda option for the use case and click on the “Next” button:

Add Permissions

On this page, choose the following permissions to attach to the IAM role:

  • AmazonSQSFullAccess
  • AWSLambdaBasicExecutionRole
  • AWSLambdaSQSQueueExecutionRole
  • AWSXRayDaemonWriteAccess

After attaching the required permissions, head to the next page by clicking on its button from the bottom of the page:

Review Role Configurations

Type the name of the IAM role and review the configuration on this page:

The following screenshot displays the list of permissions added to the role:

After reviewing the configurations and permissions for the IAM role, click on the “Create role” button:

The IAM role is created successfully and it can be used with the AWS Lambda function:

Update Lambda Function

Head inside the Lambda function page and click on the “Configuration” section:

Locate the “Permissions” section from the left panel and click on the “Edit” button from the Execution role:

Change the IAM Role

Select the Existing role from this page and click on the “Save” button to change the IAM role and attach it with the Lambda function:

Add Trigger

After updating the configurations for the Lambda function, simply click on the “Add trigger” button:

Select the SQS service and type the ARN for its resource created on the SQS service:

Scroll down to the bottom of the page and click on the “Add” button to add the trigger with the Lambda:

The trigger has been added successfully after solving the permissions error for the execution role:

That is all about solving the execution role error to attach required permissions to use the SQS queue with AWS Lambda service.

Conclusion

To solve the execution role error for adding required permissions using Amazon SQS with the Lambda function, simply visit the IAM dashboard. Head inside the “Roles” page from the IAM dashboard and configure the role using the Lambda use case. Add the required permissions before creating it and then attach it with the Lambda function by editing the configurations section. This guide has explained the process of solving the execution role error by adding the required permissions with it.

Share Button

Source: linuxhint.com

Leave a Reply