ECR / Client / get_repository_policy

get_repository_policy#

ECR.Client.get_repository_policy(**kwargs)#

Retrieves the repository policy for the specified repository.

See also: AWS API Documentation

Request Syntax

response = client.get_repository_policy(
    registryId='string',
    repositoryName='string'
)
Parameters:
  • registryId (string) – 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.

  • repositoryName (string) –

    [REQUIRED]

    The name of the repository with the policy to retrieve.

Return type:

dict

Returns:

Response Syntax

{
    'registryId': 'string',
    'repositoryName': 'string',
    'policyText': 'string'
}

Response Structure

  • (dict) –

    • registryId (string) –

      The registry ID associated with the request.

    • repositoryName (string) –

      The repository name associated with the request.

    • policyText (string) –

      The JSON repository policy text associated with the repository.

Exceptions

Examples

This example obtains the repository policy for the repository named ubuntu.

response = client.get_repository_policy(
    repositoryName='ubuntu',
)

print(response)

Expected Output:

{
    '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',
    'ResponseMetadata': {
        '...': '...',
    },
}