Amazon Lex Identity-Based Policy Examples - Amazon Lex

Amazon Lex Identity-Based Policy Examples

By default, IAM users and roles don't have permission to create or modify Amazon Lex resources. They also can't perform tasks using the AWS Management Console, AWS CLI, or AWS API. An IAM administrator must create IAM policies that grant users and roles permission to perform specific API operations on the specified resources that they need. The administrator must then attach those policies to the IAM users or groups that require those permissions.

To learn how to create an IAM identity-based policy using example JSON policy documents, see Creating Policies on the JSON Tab in the IAM User Guide.

Policy Best Practices

Identity-based policies are very powerful. They determine whether someone can create, access, or delete Amazon Lex resources in your account. These actions can incur costs for your AWS account. When you create or edit identity-based policies, follow these guidelines and recommendations:

  • Get Started Using AWS Managed Policies – To start using Amazon Lex quickly, use AWS managed policies to give your employees the permissions they need. These policies are already available in your account and are maintained and updated by AWS. For more information, see Get Started Using Permissions With AWS Managed Policies in the IAM User Guide.

  • Grant Least Privilege – When you create custom policies, grant only the permissions required to perform a task. Start with a minimum set of permissions and grant additional permissions as necessary. Doing so is more secure than starting with permissions that are too lenient and then trying to tighten them later. For more information, see Grant Least Privilege in the IAM User Guide.

  • Enable MFA for Sensitive Operations – For extra security, require IAM users to use multi-factor authentication (MFA) to access sensitive resources or API operations. For more information, see Using Multi-Factor Authentication (MFA) in AWS in the IAM User Guide.

  • Use Policy Conditions for Extra Security– To the extent that it's practical, define the conditions under which your identity-based policies allow access to a resource. For example, you can write conditions to specify a range of allowable IP addresses that a request must come from. You can also write conditions to allow requests only within a specified date or time range, or to require the use of SSL or MFA. For more information, see IAM JSON Policy Elements: Condition in the IAM User Guide.

AWS Managed (Predefined) Policies for Amazon Lex

AWS addresses many common use cases by providing standalone IAM policies that are created and administered by AWS. These policies are called AWS managed policies. AWS managed policies make it easier for you to assign appropriate permissions to users, groups, and roles than if you had to write the policies yourself.. For more information, see AWS Managed Policies in the IAM User Guide.

The following AWS managed policies, which you can attach to groups and roles in your account, are specific to Amazon Lex:

  • AmazonLexReadOnly — Grants read-only access to Amazon Lex resources.

  • AmazonLexRunBotsOnly — Grants access to run Amazon Lex conversational bots.

  • AmazonLexFullAccess — Grants full access to create, read, update, delete, and run all Amazon Lex resources. Also grants the ability to associate Lambda functions whose name starts with AmazonLex with Amazon Lex intents.

Note

You can review these permissions policies by signing in to the IAM console and searching for specific policies.

The AmazonLexFullAccess policy doesn't grant the user permission to use the KendraSearchIntent intent to query an Amazon Kendra index. To query an index, you must add additional permissions to the policy. For the required permissions, see IAM Policy for Amazon Kendra Search.

You can also create your own custom IAM policies to allow permissions for Amazon Lex API actions. You can attach these custom policies to the IAM roles or groups that require those permission.

Example: Allow Users to View Their Own Permissions

This example policy allows IAM users to view the inline and managed policies that are attached to their user identity. This policy includes permissions to complete this action on the console or programmatically using the AWS CLI or AWS API.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ViewOwnUserInfo", "Effect": "Allow", "Action": [ "iam:GetUserPolicy", "iam:ListGroupsForUser", "iam:ListAttachedUserPolicies", "iam:ListUserPolicies", "iam:GetUser" ], "Resource": [ "arn:aws:iam::*:user/${aws:username}" ] }, { "Sid": "NavigateInConsole", "Effect": "Allow", "Action": [ "iam:GetGroupPolicy", "iam:GetPolicyVersion", "iam:GetPolicy", "iam:ListAttachedGroupPolicies", "iam:ListGroupPolicies", "iam:ListPolicyVersions", "iam:ListPolicies", "iam:ListUsers" ], "Resource": "*" } ] }

Example: Delete All Amazon Lex Bots

This example policy grants an IAM user in your AWS account permission to delete any bot in your account.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "lex:DeleteBot" ], "Resource": [ "*" ] } ] }

Example: Allow a user to migrate a bot to Amazon Lex V2 APIs

The following IAM permission policy allows a user to start migrating a bot from Amazon Lex to Amazon Lex V2 APIs and to see the list of migrations and their progress.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "startMigration", "Effect": "Allow", "Action": "lex:StartMigration", "Resource": "arn:aws:lex:<Region>:<123456789012>:bot:*" }, { "Sid": "passRole", "Effect": "Allow", "Action": "iam:PassRole", "Resource": "arn:aws:iam::<123456789012>:role/<v2 bot role>" }, { "Sid": "allowOperations", "Effect": "Allow", "Action": [ "lex:CreateBot", "lex:CreateIntent", "lex:UpdateSlot", "lex:DescribeBotLocale", "lex:UpdateBotAlias", "lex:CreateSlotType", "lex:DeleteBotLocale", "lex:DescribeBot", "lex:UpdateBotLocale", "lex:CreateSlot", "lex:DeleteSlot", "lex:UpdateBot", "lex:DeleteSlotType", "lex:DescribeBotAlias", "lex:CreateBotLocale", "lex:DeleteIntent", "lex:StartImport", "lex:UpdateSlotType", "lex:UpdateIntent", "lex:DescribeImport" ], "Resource": [ "arn:aws:lex:<Region>:<123456789012>:bot/*", "arn:aws:lex:<Region>:<123456789012>:bot-alias/*/*" ] }, { "Sid": "showBots", "Effect": "Allow", "Action": [ "lex:CreateUploadUrl", "lex:ListBots" ], "Resource": "*" }, { "Sid": "showMigrations", "Effect": "Allow", "Action": [ "lex:GetMigration", "lex:GetMigrations" ], "Resource": "*" } ] }

Example: Use a Tag to Access a Resource

This example policy grants an IAM user or role in your AWS account permission to use the PostText operation with any resource tagged with the key Department and the value Support.

{ "Version": "2012-10-17", "Statement": [ { "Action": "lex:PostText", "Effect": "Allow", "Resource": "*", "Condition": { "StringEquals": { "lex:ResourceTag/Department": "Support" } } } ] }