1. Docs
  2. Clouds
  3. AWS
  4. AWS Guides
  5. Creating an AWS ECR Service with Pulumi

Creating an AWS ECR Service with Pulumi

    Create an AWS ECR resource using @pulumi/aws

    The @pulumi/aws library enables fine-grained control over the AWS ECR resource meaning it can be coded, deployed, and managed entirely in code.

    const aws = require("@pulumi/aws");
    const repository = new aws.ecr.Repository("myrepository");
    const repositoryPolicy = new aws.ecr.RepositoryPolicy("myrepositorypolicy", {
        repository: repository.id,
        policy: JSON.stringify({
            Version: "2012-10-17",
            Statement: [{
                Sid: "new policy",
                Effect: "Allow",
                Principal: "*",
                Action: [
    const lifecyclePolicy = new aws.ecr.LifecyclePolicy("mylifecyclepolicy", {
        repository: repository.id,
        policy: JSON.stringify({
            rules: [{
                rulePriority: 1,
                description: "Expire images older than 14 days",
                selection: {
                    tagStatus: "untagged",
                    countType: "sinceImagePushed",
                    countUnit: "days",
                    countNumber: 14
                action: {
                    type: "expire"
      Pulumi AI - What cloud infrastructure would you like to build? Generate Program