

Run the function by choosing the Test button.Ĭheck the output from the function. Make sure to provide the correct ARN information (from the epic Create a role in Account A) for the RoleArn field, and change region_name according to your requirements.

CONFIGURE RAZORSQL TO CONNECT TO DYNAMO DB CODE
In the Code tab, paste the contents of the lambda_write_function.py file, which is provided in the Additional information section. In the navigation pane of the console, choose Functions, and then choose Create function.įor Permissions, Change default execution role, choose Use an existing role.įor Existing role, choose DynamoDB-FullAccess-in-Account-A. The Review page displays the account number for Account A, the AmazonDynamoDBFullAccess policy, and any tags you entered.įor Role name, type a unique name for your role (for example, DynamoDB-FullAccess-For-Account-B), and add an optional role description.įor more information about creating roles, see the IAM documentation. (Optional) Add metadata to the role by attaching tags as key-value pairs.Ĭhoose Next: Review. For a list of other policies you can choose instead, see Example policies in the IAM documentation. This policy allows all actions on DynamoDB. In the list of DynamoDB policies, select AmazonDynamoDBFullAccess. In the Filter policies box, type DynamoDB.

In the navigation pane of the console, choose Roles, and then choose Create role.įor Select type of trusted entity, choose Another AWS account.įor Account ID, type the ID for Account B. In Account B, if you want to use Amazon EC2 instead of AWS Lambda, create the respective IAM policy and role, and then attach them to the EC2 instance. For example, if you want to grant access to an Amazon Relational Database Service (Amazon RDS) database in Account A, create a role for that database and bind it with a trust relationship.

You can use the same steps for other AWS services as well, but make sure that you grant and configure the appropriate permissions in both accounts. This pattern illustrates cross-account access with Lambda and DynamoDB. If you’re implementing this pattern in a production environment, use the code as a reference and customize it for your own environment. The code is provided for illustration and testing purposes only. This pattern includes sample code in the Additional information section to illustrate how you can configure a Lambda function in Account B to read and write to the DynamoDB table in Account A. With IAM, you can manage users, security credentials such as access keys, and permissions that control which AWS resources users and applications can access. IAM – AWS Identity and Access Management (IAM) is a web service for securely controlling access to AWS services. You pay only for the compute time that you consume-there is no charge when your code is not running. Lambda runs your code only when needed and scales automatically, from a few requests per day to thousands per second. Amazon DynamoDB – Amazon DynamoDB is a fully managed NoSQL database service that provides fast and predictable performance with seamless scalability.ĪWS Lambda – AWS Lambda is a compute service that supports running code without provisioning or managing servers.
