PutResourcePolicy - Amazon Systems Manager
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

PutResourcePolicy

Creates or updates a Systems Manager resource policy. A resource policy helps you to define the IAM entity (for example, an Amazon Web Services account) that can manage your Systems Manager resources. The following resources support Systems Manager resource policies.

  • OpsItemGroup - The resource policy for OpsItemGroup enables Amazon Web Services accounts to view and interact with OpsCenter operational work items (OpsItems).

  • Parameter - The resource policy is used to share a parameter with other accounts using Amazon Resource Access Manager (Amazon RAM).

    To share a parameter, it must be in the advanced parameter tier. For information about parameter tiers, see Managing parameter tiers. For information about changing an existing standard parameter to an advanced parameter, see Changing a standard parameter to an advanced parameter.

    To share a SecureString parameter, it must be encrypted with a customer managed key, and you must share the key separately through Amazon Key Management Service. Amazon managed keys cannot be shared. Parameters encrypted with the default Amazon managed key can be updated to use a customer managed key instead. For Amazon KMS key definitions, see Amazon KMS concepts in the Amazon Key Management Service Developer Guide.

    Important

    While you can share a parameter using the Systems Manager PutResourcePolicy operation, we recommend using Amazon Resource Access Manager (Amazon RAM) instead. This is because using PutResourcePolicy requires the extra step of promoting the parameter to a standard Amazon RAM Resource Share using the Amazon RAM PromoteResourceShareCreatedFromPolicy API operation. Otherwise, the parameter won't be returned by the Systems Manager DescribeParameters API operation using the --shared option.

    For more information, see Sharing a parameter in the Amazon Systems Manager User Guide

Request Syntax

{ "Policy": "string", "PolicyHash": "string", "PolicyId": "string", "ResourceArn": "string" }

Request Parameters

For information about the parameters that are common to all actions, see Common Parameters.

The request accepts the following data in JSON format.

Policy

A policy you want to associate with a resource.

Type: String

Pattern: ^(?!\s*$).+

Required: Yes

PolicyHash

ID of the current policy version. The hash helps to prevent a situation where multiple users attempt to overwrite a policy. You must provide this hash when updating or deleting a policy.

Type: String

Required: No

PolicyId

The policy ID.

Type: String

Required: No

ResourceArn

Amazon Resource Name (ARN) of the resource to which you want to attach a policy.

Type: String

Length Constraints: Minimum length of 20. Maximum length of 2048.

Required: Yes

Response Syntax

{ "PolicyHash": "string", "PolicyId": "string" }

Response Elements

If the action is successful, the service sends back an HTTP 200 response.

The following data is returned in JSON format by the service.

PolicyHash

ID of the current policy version.

Type: String

PolicyId

The policy ID. To update a policy, you must specify PolicyId and PolicyHash.

Type: String

Errors

For information about the errors that are common to all actions, see Common Errors.

InternalServerError

An error occurred on the server side.

HTTP Status Code: 500

MalformedResourcePolicyDocumentException

The specified policy document is malformed or invalid, or excessive PutResourcePolicy or DeleteResourcePolicy calls have been made.

HTTP Status Code: 400

ResourceNotFoundException

The specified parameter to be shared could not be found.

HTTP Status Code: 400

ResourcePolicyConflictException

The hash provided in the call doesn't match the stored hash. This exception is thrown when trying to update an obsolete policy version or when multiple requests to update a policy are sent.

HTTP Status Code: 400

ResourcePolicyInvalidParameterException

One or more parameters specified for the call aren't valid. Verify the parameters and their values and try again.

HTTP Status Code: 400

ResourcePolicyLimitExceededException

The PutResourcePolicy API action enforces two limits. A policy can't be greater than 1024 bytes in size. And only one policy can be attached to OpsItemGroup. Verify these limits and try again.

HTTP Status Code: 400

ResourcePolicyNotFoundException

No policies with the specified policy ID and hash could be found.

HTTP Status Code: 400

See Also

For more information about using this API in one of the language-specific Amazon SDKs, see the following: