{
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-pcs.git",
  "tagging" : {
    "permissions" : [ "pcs:TagResource", "pcs:ListTagsForResource", "pcs:UntagResource" ],
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "tagProperty" : "/properties/Tags",
    "cloudFormationSystemTags" : true
  },
  "handlers" : {
    "read" : {
      "permissions" : [ "pcs:GetComputeNodeGroup", "pcs:ListTagsForResource" ]
    },
    "create" : {
      "permissions" : [ "ec2:DescribeImages", "ec2:DescribeVpcs", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeLaunchTemplates", "ec2:DescribeLaunchTemplateVersions", "ec2:DescribeInstanceTypes", "ec2:DescribeInstanceTypeOfferings", "ec2:RunInstances", "ec2:CreateFleet", "ec2:CreateTags", "iam:PassRole", "iam:GetInstanceProfile", "pcs:CreateComputeNodeGroup", "pcs:GetComputeNodeGroup", "pcs:ListTagsForResource", "pcs:TagResource" ],
      "timeoutInMinutes" : 60
    },
    "update" : {
      "permissions" : [ "ec2:DescribeImages", "ec2:DescribeVpcs", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeLaunchTemplates", "ec2:DescribeLaunchTemplateVersions", "ec2:DescribeInstanceTypes", "ec2:DescribeInstanceTypeOfferings", "ec2:RunInstances", "ec2:CreateFleet", "ec2:CreateTags", "iam:PassRole", "iam:GetInstanceProfile", "pcs:GetComputeNodeGroup", "pcs:UpdateComputeNodeGroup", "pcs:ListTagsForResource", "pcs:TagResource", "pcs:UntagResource" ],
      "timeoutInMinutes" : 60
    },
    "list" : {
      "permissions" : [ "pcs:ListClusters", "pcs:ListComputeNodeGroups" ],
      "handlerSchema" : {
        "properties" : {
          "ClusterId" : {
            "$ref" : "resource-schema.json#/properties/ClusterId"
          }
        },
        "required" : [ "ClusterId" ]
      }
    },
    "delete" : {
      "permissions" : [ "ec2:DescribeImages", "ec2:DescribeVpcs", "ec2:DescribeSubnets", "ec2:DescribeSecurityGroups", "ec2:DescribeLaunchTemplates", "ec2:DescribeLaunchTemplateVersions", "ec2:DescribeInstanceTypes", "ec2:DescribeInstanceTypeOfferings", "ec2:TerminateInstances", "ec2:CreateFleet", "ec2:CreateTags", "iam:PassRole", "iam:GetInstanceProfile", "pcs:GetComputeNodeGroup", "pcs:DeleteComputeNodeGroup", "pcs:ListTagsForResource", "pcs:TagResource", "pcs:UntagResource" ],
      "timeoutInMinutes" : 60
    }
  },
  "typeName" : "AWS::PCS::ComputeNodeGroup",
  "readOnlyProperties" : [ "/properties/Arn", "/properties/ErrorInfo", "/properties/Id", "/properties/Status" ],
  "description" : "AWS::PCS::ComputeNodeGroup resource creates an AWS PCS compute node group.",
  "createOnlyProperties" : [ "/properties/Name", "/properties/ClusterId", "/properties/InstanceConfigs" ],
  "additionalProperties" : false,
  "primaryIdentifier" : [ "/properties/Arn" ],
  "definitions" : {
    "InstanceConfig" : {
      "description" : "An EC2 instance configuration AWS PCS uses to launch compute nodes.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "InstanceType" : {
          "description" : "The EC2 instance type that AWS PCS can provision in the compute node group.",
          "type" : "string"
        }
      }
    },
    "ErrorInfo" : {
      "description" : "An error that occurred during resource provisioning.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Message" : {
          "description" : "The detailed error information.",
          "type" : "string"
        },
        "Code" : {
          "description" : "The short-form error code.",
          "type" : "string"
        }
      }
    },
    "SubnetId" : {
      "description" : "A VPC subnet ID.",
      "type" : "string"
    },
    "SlurmCustomSetting" : {
      "description" : "Additional settings that directly map to Slurm settings.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "ParameterValue" : {
          "description" : "The value for the configured Slurm setting.",
          "type" : "string"
        },
        "ParameterName" : {
          "description" : "AWS PCS supports configuration of the following Slurm parameters for compute node groups: Weight and RealMemory.",
          "type" : "string"
        }
      },
      "required" : [ "ParameterName", "ParameterValue" ]
    }
  },
  "required" : [ "ClusterId", "CustomLaunchTemplate", "IamInstanceProfileArn", "InstanceConfigs", "ScalingConfiguration", "SubnetIds" ],
  "properties" : {
    "Status" : {
      "description" : "The provisioning status of the compute node group. The provisioning status doesn't indicate the overall health of the compute node group.",
      "type" : "string",
      "enum" : [ "CREATING", "ACTIVE", "UPDATING", "DELETING", "CREATE_FAILED", "DELETE_FAILED", "UPDATE_FAILED" ]
    },
    "ClusterId" : {
      "description" : "The ID of the cluster of the compute node group.",
      "type" : "string"
    },
    "ErrorInfo" : {
      "description" : "The list of errors that occurred during compute node group provisioning.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/ErrorInfo"
      }
    },
    "SpotOptions" : {
      "description" : "Additional configuration when you specify SPOT as the purchase option.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "AllocationStrategy" : {
          "description" : "The Amazon EC2 allocation strategy AWS PCS uses to provision EC2 instances. AWS PCS supports lowest price, capacity optimized, and price capacity optimized. If you don't provide this option, it defaults to price capacity optimized.",
          "type" : "string",
          "enum" : [ "lowest-price", "capacity-optimized", "price-capacity-optimized" ]
        }
      }
    },
    "SlurmConfiguration" : {
      "description" : "Additional options related to the Slurm scheduler.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "ScaleDownIdleTimeInSeconds" : {
          "description" : "The time before an idle node is scaled down.",
          "maximum" : 10000000,
          "type" : "integer",
          "minimum" : 1
        },
        "SlurmCustomSettings" : {
          "description" : "Additional Slurm-specific configuration that directly maps to Slurm settings.",
          "insertionOrder" : false,
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/SlurmCustomSetting"
          }
        }
      }
    },
    "SubnetIds" : {
      "description" : "The list of subnet IDs where instances are provisioned by the compute node group. The subnets must be in the same VPC as the cluster.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/SubnetId"
      }
    },
    "Name" : {
      "description" : "The name that identifies the compute node group.",
      "type" : "string"
    },
    "ScalingConfiguration" : {
      "description" : "Specifies the boundaries of the compute node group auto scaling.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "MaxInstanceCount" : {
          "description" : "The upper bound of the number of instances allowed in the compute fleet.",
          "type" : "integer",
          "minimum" : 0
        },
        "MinInstanceCount" : {
          "description" : "The lower bound of the number of instances allowed in the compute fleet.",
          "type" : "integer",
          "minimum" : 0
        }
      },
      "required" : [ "MaxInstanceCount", "MinInstanceCount" ]
    },
    "InstanceConfigs" : {
      "description" : "A list of EC2 instance configurations that AWS PCS can provision in the compute node group.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/InstanceConfig"
      }
    },
    "Id" : {
      "description" : "The generated unique ID of the compute node group.",
      "type" : "string"
    },
    "PurchaseOption" : {
      "description" : "Specifies how EC2 instances are purchased on your behalf. AWS PCS supports On-Demand, Spot, Capacity Block, and Interruptible Capacity Reservation instances. For more information, see Instance purchasing options in the Amazon Elastic Compute Cloud User Guide. If you don't provide this option, it defaults to On-Demand.",
      "type" : "string",
      "enum" : [ "ONDEMAND", "SPOT", "CAPACITY_BLOCK", "INTERRUPTIBLE_CAPACITY_RESERVATION" ]
    },
    "Arn" : {
      "description" : "The unique Amazon Resource Name (ARN) of the compute node group.",
      "type" : "string"
    },
    "CustomLaunchTemplate" : {
      "description" : "An Amazon EC2 launch template AWS PCS uses to launch compute nodes.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Version" : {
          "description" : "The version of the EC2 launch template to use to provision instances.",
          "type" : "string"
        },
        "TemplateId" : {
          "description" : "The ID of the EC2 launch template to use to provision instances.",
          "type" : "string"
        }
      },
      "required" : [ "Version" ]
    },
    "Tags" : {
      "patternProperties" : {
        "^.+$" : {
          "type" : "string"
        }
      },
      "description" : "1 or more tags added to the resource. Each tag consists of a tag key and tag value. The tag value is optional and can be an empty string.",
      "additionalProperties" : false
    },
    "AmiId" : {
      "pattern" : "^ami-[a-z0-9]+$",
      "description" : "The ID of the Amazon Machine Image (AMI) that AWS PCS uses to launch instances. If not provided, AWS PCS uses the AMI ID specified in the custom launch template.",
      "type" : "string"
    },
    "IamInstanceProfileArn" : {
      "pattern" : "^arn:aws([a-zA-Z-]{0,10})?:iam::[0-9]{12}:instance-profile/.{1,128}$",
      "description" : "The Amazon Resource Name (ARN) of the IAM instance profile used to pass an IAM role when launching EC2 instances. The role contained in your instance profile must have pcs:RegisterComputeNodeGroupInstance permissions attached to provision instances correctly.",
      "type" : "string"
    }
  }
}