- Navigation GuideYou are on a Command (operation) page with structural examples. Use the navigation breadcrumb if you would like to return to the Client landing page.
SetRepositoryPolicyCommand
Applies a repository policy to the specified public repository to control access permissions. For more information, see Amazon ECR Repository Policies in the Amazon Elastic Container Registry User Guide.
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { ECRPUBLICClient, SetRepositoryPolicyCommand } from "@aws-sdk/client-ecr-public"; // ES Modules import
// const { ECRPUBLICClient, SetRepositoryPolicyCommand } = require("@aws-sdk/client-ecr-public"); // CommonJS import
const client = new ECRPUBLICClient(config);
const input = { // SetRepositoryPolicyRequest
registryId: "STRING_VALUE",
repositoryName: "STRING_VALUE", // required
policyText: "STRING_VALUE", // required
force: true || false,
};
const command = new SetRepositoryPolicyCommand(input);
const response = await client.send(command);
// { // SetRepositoryPolicyResponse
// registryId: "STRING_VALUE",
// repositoryName: "STRING_VALUE",
// policyText: "STRING_VALUE",
// };
SetRepositoryPolicyCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
policyText Required | string | undefined | The JSON repository policy text to apply to the repository. For more information, see Amazon ECR Repository Policies in the Amazon Elastic Container Registry User Guide. |
repositoryName Required | string | undefined | The name of the repository to receive the policy. |
force | boolean | undefined | If the policy that you want to set on a repository policy would prevent you from setting another policy in the future, you must force the SetRepositoryPolicy operation. This prevents accidental repository lockouts. |
registryId | string | undefined | The Amazon Web Services account ID that's associated with the registry that contains the repository. If you do not specify a registry, the default public registry is assumed. |
SetRepositoryPolicyCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
policyText | string | undefined | The JSON repository policy text that's applied to the repository. |
registryId | string | undefined | The registry ID that's associated with the request. |
repositoryName | string | undefined | The repository name that's associated with the request. |
Throws
Name | Fault | Details |
---|
Name | Fault | Details |
---|---|---|
InvalidParameterException | client | The specified parameter is invalid. Review the available parameters for the API request. |
RepositoryNotFoundException | client | The specified repository can't be found. Check the spelling of the specified repository and ensure that you're performing operations on the correct registry. |
ServerException | server | These errors are usually caused by a server-side issue. |
UnsupportedCommandException | client | The action isn't supported in this Region. |
ECRPUBLICServiceException | Base exception class for all service exceptions from ECRPUBLIC service. |