GetRepositoryPolicyCommand

Retrieves the repository policy for the specified repository.

Example Syntax

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 import
const client = new ECRClient(config);
const input = { // GetRepositoryPolicyRequest
  registryId: "STRING_VALUE",
  repositoryName: "STRING_VALUE", // required
};
const command = new GetRepositoryPolicyCommand(input);
const response = await client.send(command);
// { // GetRepositoryPolicyResponse
//   registryId: "STRING_VALUE",
//   repositoryName: "STRING_VALUE",
//   policyText: "STRING_VALUE",
// };

Example Usage

// 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 is
{
policyText: `{
"Version" : "2008-10-17",
"Statement" : [ {
"Sid" : "new statement",
"Effect" : "Allow",
"Principal" : {
"AWS" : "arn:aws:iam::012345678901:role/CodeDeployDemo"
},
"Action" : [ "ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:BatchCheckLayerAvailability" ]
} ]
}`,
registryId: "012345678901",
repositoryName: "ubuntu"
}
*\/
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
JavaScriptLn 1, Col 1
Errors: 0 Warnings: 0

GetRepositoryPolicyCommand Input

See GetRepositoryPolicyCommandInput for more details

Parameter
Type
Description
repositoryName
Required
string | undefined

The name of the repository with the policy to retrieve.

registryId
string | undefined

The Amazon Web Services account ID associated with the registry that contains the repository. If you do not specify a registry, the default registry is assumed.

GetRepositoryPolicyCommand Output

Parameter
Type
Description
$metadata
Required
ResponseMetadata
Metadata pertaining to this request.
policyText
string | undefined

The JSON repository policy text associated with the repository.

registryId
string | undefined

The registry ID associated with the request.

repositoryName
string | undefined

The repository name associated with the request.

Throws

Name
Fault
Details
InvalidParameterException
client

The specified parameter is invalid. Review the available parameters for the API request.

RepositoryNotFoundException
client

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

The specified repository and registry combination does not have an associated repository policy.

ServerException
server

These errors are usually caused by a server-side issue.

ECRServiceException
Base exception class for all service exceptions from ECR service.