Identity-based policy examples for Amazon GameSparks - Amazon GameSparks

Amazon GameSparks is currently in preview. Changes might be made to this service and to this documentation. We don’t recommend using this service for production workloads.

Identity-based policy examples for Amazon GameSparks

By default, AWS Identity and Access Management (IAM) users and roles don’t have permission to create or modify Amazon GameSparks resources. They also can’t perform tasks using the AWS Management Console, AWS Command Line Interface (AWS CLI), or AWS API. An IAM administrator must create IAM policies that grant users and roles permission to perform actions on the 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 the following example JSON policy documents, see Creating policies on the JSON tab in the AWS Identity and Access Management User Guide.

Policy best practices

Identity-based policies are powerful. They determine whether someone can create, access, or delete GameSparks 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:

  • 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 AWS Identity and Access Management 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 AWS Identity and Access Management 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 AWS Identity and Access Management User Guide.

Allow using the GameSparks console

To access the GameSparks console, you must have a minimum set of permissions. These permissions must allow you to list and view details about the GameSparks resources in your AWS account. If you create an identity-based policy that is more restrictive than the minimum required permissions, the console won’t function as intended for entities (IAM users or roles) with that policy.

You don’t need to allow minimum console permissions for users that make calls only to the AWS CLI or the AWS API. Instead, allow access only to the actions that match the API operation that you’re trying to perform.

The following policy allows listing and viewing games and the resources that they contain, such as stages and snapshots.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "gamesparks:List*", "gamesparks:Get*" ], "Resource": "*" } ] }

Allow modifying the game

The following policy allows modifying the TicTacToe game configuration. For example, the policy allows changing the game description and the cloud code.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "gamesparks:UpdateGame", "gamesparks:UpdateGameDocument" ], "Resource": [ "arn:aws:gamesparks:us-east-1:012345678912:game/TicTacToe" ] } ] }

Allow saving and deploying changes to the Dev stage

The following policy enables creating a snapshot and deploying it to the Dev stage in the TicTacToe game.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "gamesparks:CreateSnapshot" ], "Resource": [ "arn:aws:gamesparks:us-east-1:012345678912:game/TicTacToe" ] }, { "Effect": "Allow", "Action": [ "gamesparks:CreateStageDeployment" ], "Resource": [ "arn:aws:gamesparks:us-east-1:012345678912:game/TicTacToe/stage/Dev" ] } ] }

Allow creating a game

The following policy enables creating a game.

{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "iam:ListRoles", "iam:CreateRole", "iam:CreatePolicy", "iam:AttachRolePolicy", "gamesparks:CreateGame", "gamesparks:CreateStage" ], "Resource": "*" } ] }