Protected
Retrieves the repository policy for the specified repository.
Use a bare-bones client and the command you need to make an API call.
import { ECRClient, GetRepositoryPolicyCommand } from "@aws-sdk/client-ecr"; // ES Modules import// const { ECRClient, GetRepositoryPolicyCommand } = require("@aws-sdk/client-ecr"); // CommonJS importconst client = new ECRClient(config);const command = new GetRepositoryPolicyCommand(input);const response = await client.send(command);
input
response
config
InvalidParameterException (client fault)
The specified parameter is invalid. Review the available parameters for the API request.
RepositoryNotFoundException (client fault)
The specified repository could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry.
RepositoryPolicyNotFoundException (client fault)
The specified repository and registry combination does not have an associated repository policy.
ServerException (server fault)
These errors are usually caused by a server-side issue.
To get the current policy for a repository
// This example obtains the repository policy for the repository named ubuntu.const input = { "repositoryName": "ubuntu"};const command = new GetRepositoryPolicyCommand(input);const response = await client.send(command);/* response =={ "policyText": "{\n \"Version\" : \"2008-10-17\",\n \"Statement\" : [ {\n \"Sid\" : \"new statement\",\n \"Effect\" : \"Allow\",\n \"Principal\" : {\n \"AWS\" : \"arn:aws:iam::012345678901:role/CodeDeployDemo\"\n },\n\"Action\" : [ \"ecr:GetDownloadUrlForLayer\", \"ecr:BatchGetImage\", \"ecr:BatchCheckLayerAvailability\" ]\n } ]\n}", "registryId": "012345678901", "repositoryName": "ubuntu"}*/// example id: getrepositorypolicy-example-1470867669211
Readonly
Static
Retrieves the repository policy for the specified repository.
Example
Use a bare-bones client and the command you need to make an API call.
See
input
shape.response
shape.config
shape.Throws
InvalidParameterException (client fault)
The specified parameter is invalid. Review the available parameters for the API request.
Throws
RepositoryNotFoundException (client fault)
The specified repository could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry.
Throws
RepositoryPolicyNotFoundException (client fault)
The specified repository and registry combination does not have an associated repository policy.
Throws
ServerException (server fault)
These errors are usually caused by a server-side issue.
Example
To get the current policy for a repository