- 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.
PutLifecyclePolicyCommand
Creates or updates the lifecycle policy for the specified repository. For more information, see Lifecycle policy template .
Example Syntax
Use a bare-bones client and the command you need to make an API call.
import { ECRClient, PutLifecyclePolicyCommand } from "@aws-sdk/client-ecr"; // ES Modules import
// const { ECRClient, PutLifecyclePolicyCommand } = require("@aws-sdk/client-ecr"); // CommonJS import
const client = new ECRClient(config);
const input = { // PutLifecyclePolicyRequest
registryId: "STRING_VALUE",
repositoryName: "STRING_VALUE", // required
lifecyclePolicyText: "STRING_VALUE", // required
};
const command = new PutLifecyclePolicyCommand(input);
const response = await client.send(command);
// { // PutLifecyclePolicyResponse
// registryId: "STRING_VALUE",
// repositoryName: "STRING_VALUE",
// lifecyclePolicyText: "STRING_VALUE",
// };
PutLifecyclePolicyCommand Input
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
lifecyclePolicyText Required | string | undefined | The JSON repository policy text to apply to the repository. |
repositoryName Required | string | undefined | The name of the repository to receive the policy. |
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. |
PutLifecyclePolicyCommand Output
Parameter | Type | Description |
---|
Parameter | Type | Description |
---|---|---|
$metadata Required | ResponseMetadata | Metadata pertaining to this request. |
lifecyclePolicyText | string | undefined | The JSON repository policy text. |
registryId | string | undefined | The registry ID associated with the request. |
repositoryName | string | undefined | The repository name 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 could not be found. Check the spelling of the specified repository and ensure that you are performing operations on the correct registry. |
ServerException | server | These errors are usually caused by a server-side issue. |
ValidationException | client | There was an exception validating this request. |
ECRServiceException | Base exception class for all service exceptions from ECR service. |