How AWS Systems Manager works with IAM - AWS Systems Manager

How AWS Systems Manager works with IAM

Before you use IAM to manage access to Systems Manager, you should understand what IAM features are available to use with Systems Manager. To get a high-level view of how Systems Manager and other AWS services work with IAM, see AWS Services That Work with IAM in the IAM User Guide.

Systems Manager identity-based policies

With IAM identity-based policies, you can specify allowed or denied actions and resources as well as the conditions under which actions are allowed or denied. Systems Manager supports specific actions, resources, and condition keys. To learn about all of the elements that you use in a JSON policy, see IAM JSON Policy Elements Reference in the IAM User Guide.

Actions

Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions.

The Action element of a JSON policy describes the actions that you can use to allow or deny access in a policy. Policy actions usually have the same name as the associated AWS API operation. There are some exceptions, such as permission-only actions that don't have a matching API operation. There are also some operations that require multiple actions in a policy. These additional actions are called dependent actions.

Include actions in a policy to grant permissions to perform the associated operation.

Policy actions in Systems Manager use the following prefix before the action: ssm:. For example, to grant someone permission to create a Systems Manager parameter with the Systems Manager PutParameter API operation, you include the ssm:PutParameter action in their policy. Policy statements must include either an Action or NotAction element. Systems Manager defines its own set of actions that describe tasks that you can perform with this service.

To specify multiple actions in a single statement, separate them with commas as follows:

"Action": [ "ssm:action1", "ssm:action2"

You can specify multiple actions using wildcards (*). For example, to specify all actions that begin with the word Describe, include the following action:

"Action": "ssm:Describe*"

To see a list of Systems Manager actions, see Actions Defined by AWS Systems Manager in the Service Authorization Reference.

Resources

Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions.

The Resource JSON policy element specifies the object or objects to which the action applies. Statements must include either a Resource or a NotResource element. As a best practice, specify a resource using its Amazon Resource Name (ARN). You can do this for actions that support a specific resource type, known as resource-level permissions.

For actions that don't support resource-level permissions, such as listing operations, use a wildcard (*) to indicate that the statement applies to all resources.

"Resource": "*"

For example, the Systems Manager maintenance window resource has the following ARN format.

arn:aws:ssm:region:account-id:maintenancewindow/window-id

To specify the mw-0c50858d01EXAMPLE maintenance windows in your statement, use an ARN similar to the following.

"Resource": "arn:aws:ssm:us-east-2:123456789012:maintenancewindow/mw-0c50858d01EXAMPLE"

To specify all maintenance windows that belong to a specific account, use the wildcard (*).

"Resource": "arn:aws:ssm:us-east-2:123456789012:maintenancewindow/*"

For Parameter Store API actions, you can provide or restrict access to all parameters in one level of a hierarchy by using hierarchical names and AWS Identity and Access Management (IAM) policies as follows.

"Resource": "arn:aws:ssm:us-west-2:123456789012:parameter/Dev/ERP/Oracle/*"

Some Systems Manager actions, such as those for creating resources, cannot be performed on a specific resource. In those cases, you must use the wildcard (*).

"Resource": "*"

Some Systems Manager API actions accept multiple resources. To specify multiple resources in a single statement, separate their ARNs with commas as follows.

"Resource": [ "resource1", "resource2"
Note

Most AWS services treat a colon (:) or a forward slash (/) as the same character in ARNs. However, Systems Manager requires an exact match in resource patterns and rules. When creating event patterns, be sure to use the correct ARN characters so that they match the resource's ARN.

The following table describes the ARN formats for the resource types supported by Systems Manager.

Resource type ARN format
Association arn:aws:ssm:region:account-id:association/association-id
Automation execution arn:aws:ssm:region:account-id:automation-execution/automation-execution-id
Automation definition (with version subresource)

arn:aws:ssm:region:account-id:automation-definition/automation-definition-id:version-id

Document

arn:aws:ssm:region:account-id:document/document-name

Maintenance window

arn:aws:ssm:region:account-id:maintenancewindow/window-id

Managed instance

arn:aws:ssm:region:account-id:managed-instance/managed-instance-id

Managed instance inventory arn:aws:ssm:region:account-id:managed-instance-inventory/managed-instance-id
Parameter

A one-level parameter:

  • arn:aws:ssm:region:account-id:parameter/parameter-name/

A parameter named with a hierarchical construction:

  • arn:aws:ssm:region:account-id:parameter/parameter-name-root/level-2/level-3/level-4/level-5

Patch baseline

arn:aws:ssm:region:account-id:patchbaseline/patch-baseline-id

Session

arn:aws:ssm:region:account-id:session/session-id

All Systems Manager resources

arn:aws:ssm:*

All Systems Manager resources owned by the specified account in the specified Region

arn:aws:ssm:region:account-id:*

For automation definitions, Systems Manager supports a second-level resource, version ID. In AWS, these second-level resources are known as subresources. Specifying a version subresource for an automation definition resource lets you provide access to certain versions of an automation definition. For example, you might want to ensure that only the latest version of an automation definition is used in your instance management.

To organize and manage parameters, you can create names for parameters with a hierarchical construction. With hierarchical construction, a parameter name can include a path that you define by using forward slashes. You can name a parameter resource with a maximum of fifteen levels. We suggest that you create hierarchies that reflect an existing hierarchical structure in your environment. For more information, see Creating Systems Manager parameters.

In most cases, the session ID is constructed using the ID of the account user who started the session, plus an alphanumeric suffix. For example:

arn:aws:us-east-2:111122223333:session/JohnDoe-1a2b3c4sEXAMPLE

However, if the user ID is not available, the ARN is constructed this way instead:

arn:aws:us-east-2:111122223333:session/session-1a2b3c4sEXAMPLE

For more information about the format of ARNs, see Amazon Resource Names (ARNs) and AWS Service Namespaces in the Amazon Web Services General Reference.

For a list of Systems Manager resource types and their ARNs, see Resources Defined by AWS Systems Manager in the Service Authorization Reference. To learn with which actions you can specify the ARN of each resource, see Actions Defined by AWS Systems Manager.

Condition keys

Administrators can use AWS JSON policies to specify who has access to what. That is, which principal can perform actions on what resources, and under what conditions.

The Condition element (or Condition block) lets you specify conditions in which a statement is in effect. The Condition element is optional. You can create conditional expressions that use condition operators, such as equals or less than, to match the condition in the policy with values in the request.

If you specify multiple Condition elements in a statement, or multiple keys in a single Condition element, AWS evaluates them using a logical AND operation. If you specify multiple values for a single condition key, AWS evaluates the condition using a logical OR operation. All of the conditions must be met before the statement's permissions are granted.

You can also use placeholder variables when you specify conditions. For example, you can grant an IAM user permission to access a resource only if it is tagged with their IAM user name. For more information, see IAM policy elements: variables and tags in the IAM User Guide.

AWS supports global condition keys and service-specific condition keys. To see all AWS global condition keys, see AWS global condition context keys in the IAM User Guide.

Systems Manager defines its own set of condition keys and also supports using some global condition keys. To see all AWS global condition keys, see AWS Global Condition Context Keys in the IAM User Guide.

To see a list of Systems Manager condition keys, see Condition Keys for AWS Systems Manager in the Service Authorization Reference. To learn with which actions and resources you can use a condition key, see Actions Defined by AWS Systems Manager.

For information about using the ssm:resourceTag/* condition key, see the following topics:

For information about using the ssm:Recursive and ssm:Overwrite condition keys, see Working with parameter hierarchies.

Examples

To view examples of Systems Manager identity-based policies, see AWS Systems Manager identity-based policy examples.

Systems Manager resource-based policies

Other AWS services, such as Amazon Simple Storage Service, support resource-based permissions policies. For example, you can attach a permissions policy to an S3 bucket to manage access permissions to that bucket.

Systems Manager does not support resource-based policies.

Authorization based on Systems Manager tags

You can attach tags to Systems Manager resources or pass tags in a request to Systems Manager. To control access based on tags, you provide tag information in the condition element of a policy using the ssm:resourceTag/key-name, aws:ResourceTag/key-name, aws:RequestTag/key-name, or aws:TagKeys condition keys. You can add tags to the following resource types when you create or update them:

  • Document

  • Managed instance

  • Maintenance window

  • Parameter

  • Patch baseline

  • OpsItem

For information about tagging Systems Manager resources, see Tagging Systems Manager resources.

To view an example identity-based policy for limiting access to a resource based on the tags on that resource, see Viewing Systems Manager documents based on tags.

Systems Manager IAM roles

An IAM role is an entity within your AWS account that has specific permissions.

Using temporary credentials with Systems Manager

You can use temporary credentials to sign in with federation, assume an IAM role, or to assume a cross-account role. You obtain temporary security credentials by calling AWS STS API operations such as AssumeRole or GetFederationToken.

Systems Manager supports using temporary credentials.

Service-linked roles

Service-linked roles allow AWS services to access resources in other services to complete an action on your behalf. Service-linked roles appear in your IAM account and are owned by the service. An IAM administrator can view but not edit the permissions for service-linked roles.

Systems Manager supports service-linked roles. For details about creating or managing Systems Manager service-linked roles, see Using service-linked roles for Systems Manager.

Service roles

This feature allows a service to assume a service role on your behalf. This role allows the service to access resources in other services to complete an action on your behalf. Service roles appear in your IAM account and are owned by the account. This means that an IAM administrator can change the permissions for this role. However, doing so might break the functionality of the service.

Systems Manager supports service roles.

Choosing an IAM role in Systems Manager

For Systems Manager to interact with your managed instances, you must choose a role to allow Systems Manager to access instances on your behalf. If you have previously created a service role or service-linked role, then Systems Manager provides you with a list of roles to choose from. It's important to choose a role that allows access to start and stop managed instances.

To access EC2 instances, the role your AWS account needs is an IAM instance profile. For information, see Create an IAM instance profile for Systems Manager.

To access on-premises instances or virtual machines (VMs), the role your AWS account needs is an IAM service role for a hybrid environment. For information, see Create an IAM service role for a hybrid environment.

An Automation workflow can be initiated under the context of a service role (or assume role). This allows the service to perform actions on your behalf. If you do not specify an assume role, Automation uses the context of the user who invoked the execution. However, certain situations require that you specify a service role for Automation. For more information, see Configuring a service role (assume role) access for Automation workflows.

AWS managed policies for AWS Systems Manager

AWS addresses many common use cases by providing standalone IAM policies that are created and administered by AWS. These AWS managed policies grant necessary permissions for common use cases so you can avoid having to investigate which permissions are needed. (You can also create your own custom IAM policies to allow permissions for Systems Manager actions and resources.) For more information, see AWS Managed Policies in the IAM User Guide.

The following AWS managed policies, which you can attach to users in your account, are specific to AWS Systems Manager:

  • AmazonSSMFullAccess – User trust policy that grants full access to the Systems Manager API and documents.

  • AmazonSSMReadOnlyAccess – User trust policy that grants access to Systems Manager read-only API actions, such as Get* and List*.

  • AmazonSSMAutomationApproverAccess – User trust policy that enables access to view automation executions and send approval decisions to automation that is waiting for approval.

  • AmazonSSMAutomationRole – Service role policy that provides permissions for the AWS Systems Manager automation service to run activities defined within automation documents. Assign this policy to administrators and trusted power users.

  • AmazonSSMMaintenanceWindowRole – Service role policy for Systems Manager Maintenance Windows.

  • AmazonSSMDirectoryServiceAccess – Instance trust policy that allows SSM Agent to access AWS Directory Service on behalf of the user for requests to join the domain by the managed instance.

  • AmazonSSMManagedInstanceCore – Instance trust policy that enables an instance to use AWS Systems Manager service core functionality.

  • AmazonSSMServiceRolePolicy – Service role policy that provides access to AWS resources managed or used by AWS Systems Manager.

  • AWSResourceAccessManagerServiceRolePolicy – Service role policy containing read-only AWS Resource Access Manager access to the account's AWS Organizations structure. It also contains IAM permissions to self-delete the role.

  • AmazonEC2RoleforSSM – This policy will be deprecated soon. In its place, use the AmazonSSMManagedInstanceCore policy to enable AWS Systems Manager service core functionality on EC2 instances. For information, see Create an IAM instance profile for Systems Manager.

Note

In a hybrid environment, you need an additional IAM role that allows servers and VMs to communicate with the Systems Manager service. This is the IAM service role for Systems Manager. This role grants AWS Security Token Service (AWS STS) AssumeRole trust to the Systems Manager service. The AssumeRole action returns a set of temporary security credentials (consisting of an access key ID, a secret access key, and a security token). You use these temporary credentials to access AWS resources that you might not normally have access to. For more information, see Create an IAM service role for a hybrid environment and AssumeRole in AWS Security Token Service API Reference.