SetVaultAccessPolicyCommand

This operation configures an access policy for a vault and will overwrite an existing policy. To configure a vault access policy, send a PUT request to the access-policy subresource of the vault. An access policy is specific to a vault and is also called a vault subresource. You can set one access policy per vault and the policy can be up to 20 KB in size. For more information about vault access policies, see Amazon Glacier Access Control with Vault Access Policies .

Example Syntax

Use a bare-bones client and the command you need to make an API call.

import { GlacierClient, SetVaultAccessPolicyCommand } from "@aws-sdk/client-glacier"; // ES Modules import
// const { GlacierClient, SetVaultAccessPolicyCommand } = require("@aws-sdk/client-glacier"); // CommonJS import
const client = new GlacierClient(config);
const input = { // SetVaultAccessPolicyInput
  accountId: "STRING_VALUE", // required
  vaultName: "STRING_VALUE", // required
  policy: { // VaultAccessPolicy
    Policy: "STRING_VALUE",
  },
};
const command = new SetVaultAccessPolicyCommand(input);
const response = await client.send(command);
// {};

Example Usage

 Loading code editorLoading code editor

SetVaultAccessPolicyCommand Input

Parameter
Type
Description
accountId
Required
string | undefined

The AccountId value is the AWS account ID of the account that owns the vault. You can either specify an AWS account ID or optionally a single '-' (hyphen), in which case Amazon S3 Glacier uses the AWS account ID associated with the credentials used to sign the request. If you use an account ID, do not include any hyphens ('-') in the ID.

vaultName
Required
string | undefined

The name of the vault.

policy
VaultAccessPolicy | undefined

The vault access policy as a JSON string.

SetVaultAccessPolicyCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.

Throws

Name
Fault
Details
InvalidParameterValueException
client

Returned if a parameter of the request is incorrectly specified.

MissingParameterValueException
client

Returned if a required header or parameter is missing from the request.

ResourceNotFoundException
client

Returned if the specified resource (such as a vault, upload ID, or job ID) doesn't exist.

ServiceUnavailableException
server

Returned if the service cannot complete the request.

GlacierServiceException
Base exception class for all service exceptions from Glacier service.