{
  "typeName" : "AWS::ImageBuilder::LifecyclePolicy",
  "description" : "Resource schema for AWS::ImageBuilder::LifecyclePolicy",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-imagebuilder.git",
  "properties" : {
    "Arn" : {
      "description" : "The Amazon Resource Name (ARN) of the lifecycle policy.",
      "type" : "string"
    },
    "Name" : {
      "description" : "The name of the lifecycle policy.",
      "type" : "string"
    },
    "Description" : {
      "description" : "The description of the lifecycle policy.",
      "type" : "string"
    },
    "Status" : {
      "description" : "The status of the lifecycle policy.",
      "type" : "string",
      "enum" : [ "DISABLED", "ENABLED" ]
    },
    "ExecutionRole" : {
      "description" : "The execution role of the lifecycle policy.",
      "type" : "string"
    },
    "ResourceType" : {
      "description" : "The resource type of the lifecycle policy.",
      "type" : "string",
      "enum" : [ "AMI_IMAGE", "CONTAINER_IMAGE" ]
    },
    "PolicyDetails" : {
      "description" : "The policy details of the lifecycle policy.",
      "type" : "array",
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/PolicyDetail"
      }
    },
    "ResourceSelection" : {
      "description" : "The resource selection of the lifecycle policy.",
      "$ref" : "#/definitions/ResourceSelection"
    },
    "Tags" : {
      "description" : "The tags associated with the lifecycle policy.",
      "type" : "object",
      "additionalProperties" : false,
      "patternProperties" : {
        ".{1,}" : {
          "type" : "string"
        }
      }
    }
  },
  "definitions" : {
    "PolicyDetail" : {
      "description" : "The policy detail of the lifecycle policy.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Action" : {
          "$ref" : "#/definitions/Action"
        },
        "Filter" : {
          "$ref" : "#/definitions/Filter"
        },
        "ExclusionRules" : {
          "$ref" : "#/definitions/ExclusionRules"
        }
      },
      "required" : [ "Action", "Filter" ]
    },
    "Action" : {
      "description" : "The action of the policy detail.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Type" : {
          "description" : "The action type of the policy detail.",
          "type" : "string",
          "enum" : [ "DELETE", "DEPRECATE", "DISABLE" ]
        },
        "IncludeResources" : {
          "$ref" : "#/definitions/IncludeResources"
        }
      },
      "required" : [ "Type" ]
    },
    "Filter" : {
      "description" : "The filters to apply of the policy detail.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Type" : {
          "description" : "The filter type.",
          "type" : "string",
          "enum" : [ "AGE", "COUNT" ]
        },
        "Value" : {
          "description" : "The filter value.",
          "type" : "integer"
        },
        "Unit" : {
          "description" : "The value's time unit.",
          "$ref" : "#/definitions/TimeUnit"
        },
        "RetainAtLeast" : {
          "description" : "The minimum number of Image Builder resources to retain.",
          "type" : "integer"
        }
      },
      "required" : [ "Type", "Value" ]
    },
    "ExclusionRules" : {
      "description" : "The exclusion rules to apply of the policy detail.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "TagMap" : {
          "description" : "The Image Builder tags to filter on.",
          "type" : "object",
          "additionalProperties" : false,
          "patternProperties" : {
            ".{1,}" : {
              "type" : "string"
            }
          }
        },
        "Amis" : {
          "$ref" : "#/definitions/AmiExclusionRules"
        }
      }
    },
    "TimeUnit" : {
      "description" : "A time unit.",
      "type" : "string",
      "enum" : [ "DAYS", "WEEKS", "MONTHS", "YEARS" ]
    },
    "IncludeResources" : {
      "description" : "The included resources of the policy detail.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Amis" : {
          "description" : "Use to configure lifecycle actions on AMIs.",
          "type" : "boolean"
        },
        "Containers" : {
          "description" : "Use to configure lifecycle actions on containers.",
          "type" : "boolean"
        },
        "Snapshots" : {
          "description" : "Use to configure lifecycle actions on snapshots.",
          "type" : "boolean"
        }
      }
    },
    "AmiExclusionRules" : {
      "description" : "The AMI exclusion rules for the policy detail.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "IsPublic" : {
          "description" : "Use to apply lifecycle policy actions on whether the AMI is public.",
          "type" : "boolean"
        },
        "Regions" : {
          "description" : "Use to apply lifecycle policy actions on AMIs distributed to a set of regions.",
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "type" : "string"
          }
        },
        "SharedAccounts" : {
          "description" : "Use to apply lifecycle policy actions on AMIs shared with a set of regions.",
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "type" : "string"
          }
        },
        "LastLaunched" : {
          "description" : "Use to apply lifecycle policy actions on AMIs launched before a certain time.",
          "$ref" : "#/definitions/LastLaunched"
        },
        "TagMap" : {
          "description" : "The AMIs to select by tag.",
          "type" : "object",
          "additionalProperties" : false,
          "patternProperties" : {
            ".{1,}" : {
              "type" : "string"
            }
          }
        }
      }
    },
    "LastLaunched" : {
      "description" : "The last launched time of a resource.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Value" : {
          "description" : "The last launched value.",
          "type" : "integer"
        },
        "Unit" : {
          "description" : "The value's time unit.",
          "$ref" : "#/definitions/TimeUnit"
        }
      },
      "required" : [ "Value", "Unit" ]
    },
    "ResourceSelection" : {
      "description" : "The resource selection for the lifecycle policy.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Recipes" : {
          "description" : "The recipes to select.",
          "type" : "array",
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/RecipeSelection"
          }
        },
        "TagMap" : {
          "description" : "The Image Builder resources to select by tag.",
          "type" : "object",
          "additionalProperties" : false,
          "patternProperties" : {
            ".{1,}" : {
              "type" : "string"
            }
          }
        }
      }
    },
    "RecipeSelection" : {
      "description" : "The recipe to apply the lifecycle policy for.",
      "type" : "object",
      "additionalProperties" : false,
      "properties" : {
        "Name" : {
          "description" : "The recipe name.",
          "type" : "string"
        },
        "SemanticVersion" : {
          "description" : "The recipe version.",
          "type" : "string"
        }
      },
      "required" : [ "Name", "SemanticVersion" ]
    }
  },
  "required" : [ "Name", "ExecutionRole", "ResourceType", "PolicyDetails", "ResourceSelection" ],
  "primaryIdentifier" : [ "/properties/Arn" ],
  "readOnlyProperties" : [ "/properties/Arn" ],
  "createOnlyProperties" : [ "/properties/Name" ],
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "imagebuilder:TagResource", "imagebuilder:UntagResource" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "iam:PassRole", "imagebuilder:CreateLifecyclePolicy", "imagebuilder:GetLifecyclePolicy", "imagebuilder:TagResource" ]
    },
    "update" : {
      "permissions" : [ "iam:PassRole", "imagebuilder:GetLifecyclePolicy", "imagebuilder:UpdateLifecyclePolicy", "imagebuilder:TagResource", "imagebuilder:UntagResource" ]
    },
    "read" : {
      "permissions" : [ "imagebuilder:GetLifecyclePolicy" ]
    },
    "delete" : {
      "permissions" : [ "imagebuilder:GetLifecyclePolicy", "imagebuilder:DeleteLifecyclePolicy", "imagebuilder:UntagResource" ]
    },
    "list" : {
      "permissions" : [ "imagebuilder:ListLifecyclePolicies" ]
    }
  },
  "additionalProperties" : false
}