{
  "typeName" : "AWS::CloudFormation::StackSet",
  "description" : "StackSet as a resource provides one-click experience for provisioning a StackSet and StackInstances",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-cloudformation.git",
  "resourceLink" : {
    "templateUri" : "/cloudformation/home?region=${awsRegion}#/stacksets/${StackSetId}",
    "mappings" : {
      "StackSetId" : "/StackSetId"
    }
  },
  "definitions" : {
    "Tag" : {
      "description" : "Tag type enables you to specify a key-value pair that can be used to store information about an AWS CloudFormation StackSet.",
      "type" : "object",
      "properties" : {
        "Key" : {
          "description" : "A string used to identify this tag. You can specify a maximum of 127 characters for a tag key.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 128,
          "pattern" : "^(?!aws:.*)[a-zA-Z0-9\\s\\:\\_\\.\\/\\=\\+\\-]+$"
        },
        "Value" : {
          "description" : "A string containing the value for this tag. You can specify a maximum of 256 characters for a tag value.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    },
    "AutoDeployment" : {
      "type" : "object",
      "properties" : {
        "Enabled" : {
          "description" : "If set to true, StackSets automatically deploys additional stack instances to AWS Organizations accounts that are added to a target organization or organizational unit (OU) in the specified Regions. If an account is removed from a target organization or OU, StackSets deletes stack instances from the account in the specified Regions.",
          "type" : "boolean"
        },
        "RetainStacksOnAccountRemoval" : {
          "description" : "If set to true, stack resources are retained when an account is removed from a target organization or OU. If set to false, stack resources are deleted. Specify only if Enabled is set to True.",
          "type" : "boolean"
        },
        "DependsOn" : {
          "description" : "A list of StackSet ARNs that this StackSet depends on for auto-deployment operations. When auto-deployment is triggered, operations will be sequenced to ensure all dependencies complete successfully before this StackSet's operation begins.",
          "type" : "array",
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/StackSetArn"
          }
        }
      },
      "additionalProperties" : false
    },
    "StackSetArn" : {
      "description" : "The Amazon Resource Number (ARN) of a stack set.",
      "type" : "string"
    },
    "Account" : {
      "description" : "AWS account that you want to create stack instances in the specified Region(s) for.",
      "type" : "string",
      "pattern" : "^[0-9]{12}$"
    },
    "Region" : {
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9-]{1,128}$"
    },
    "OrganizationalUnitId" : {
      "type" : "string",
      "pattern" : "^(ou-[a-z0-9]{4,32}-[a-z0-9]{8,32}|r-[a-z0-9]{4,32})$"
    },
    "Capability" : {
      "type" : "string",
      "enum" : [ "CAPABILITY_IAM", "CAPABILITY_NAMED_IAM", "CAPABILITY_AUTO_EXPAND" ]
    },
    "RegionConcurrencyType" : {
      "description" : "The concurrency type of deploying StackSets operations in regions, could be in parallel or one region at a time",
      "type" : "string",
      "enum" : [ "SEQUENTIAL", "PARALLEL" ]
    },
    "ConcurrencyMode" : {
      "description" : "Specifies how the concurrency level behaves during the operation execution.",
      "type" : "string",
      "enum" : [ "STRICT_FAILURE_TOLERANCE", "SOFT_FAILURE_TOLERANCE" ]
    },
    "Active" : {
      "description" : "When true, StackSets performs non-conflicting operations concurrently and queues conflicting operations. After conflicting operations finish, StackSets starts queued operations in request order.",
      "type" : "boolean"
    },
    "OperationPreferences" : {
      "description" : "The user-specified preferences for how AWS CloudFormation performs a stack set operation.",
      "type" : "object",
      "properties" : {
        "FailureToleranceCount" : {
          "type" : "integer",
          "minimum" : 0
        },
        "FailureTolerancePercentage" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 100
        },
        "MaxConcurrentCount" : {
          "type" : "integer",
          "minimum" : 1
        },
        "MaxConcurrentPercentage" : {
          "type" : "integer",
          "minimum" : 0,
          "maximum" : 100
        },
        "RegionOrder" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/Region"
          }
        },
        "RegionConcurrencyType" : {
          "$ref" : "#/definitions/RegionConcurrencyType"
        },
        "ConcurrencyMode" : {
          "$ref" : "#/definitions/ConcurrencyMode"
        }
      },
      "additionalProperties" : false
    },
    "Parameter" : {
      "type" : "object",
      "properties" : {
        "ParameterKey" : {
          "description" : "The key associated with the parameter. If you don't specify a key and value for a particular parameter, AWS CloudFormation uses the default value that is specified in your template.",
          "type" : "string"
        },
        "ParameterValue" : {
          "description" : "The input value associated with the parameter.",
          "type" : "string"
        }
      },
      "required" : [ "ParameterKey", "ParameterValue" ],
      "additionalProperties" : false
    },
    "DeploymentTargets" : {
      "description" : " The AWS OrganizationalUnitIds or Accounts for which to create stack instances in the specified Regions.",
      "type" : "object",
      "properties" : {
        "Accounts" : {
          "description" : "AWS accounts that you want to create stack instances in the specified Region(s) for.",
          "type" : "array",
          "minItems" : 1,
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/Account"
          }
        },
        "AccountsUrl" : {
          "description" : "Returns the value of the AccountsUrl property.",
          "type" : "string",
          "minLength" : 1,
          "maxLength" : 5120,
          "pattern" : "(s3://|http(s?)://).+"
        },
        "OrganizationalUnitIds" : {
          "description" : "The organization root ID or organizational unit (OU) IDs to which StackSets deploys.",
          "type" : "array",
          "minItems" : 1,
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/OrganizationalUnitId"
          }
        },
        "AccountFilterType" : {
          "description" : "The filter type you want to apply on organizational units and accounts.",
          "type" : "string",
          "enum" : [ "NONE", "UNION", "INTERSECTION", "DIFFERENCE" ]
        }
      },
      "additionalProperties" : false
    },
    "StackInstances" : {
      "description" : "Stack instances in some specific accounts and Regions.",
      "type" : "object",
      "properties" : {
        "DeploymentTargets" : {
          "$ref" : "#/definitions/DeploymentTargets"
        },
        "Regions" : {
          "description" : "The names of one or more Regions where you want to create stack instances using the specified AWS account(s).",
          "type" : "array",
          "minItems" : 1,
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/Region"
          }
        },
        "ParameterOverrides" : {
          "description" : "A list of stack set parameters whose values you want to override in the selected stack instances.",
          "type" : "array",
          "uniqueItems" : true,
          "insertionOrder" : false,
          "items" : {
            "$ref" : "#/definitions/Parameter"
          }
        }
      },
      "required" : [ "DeploymentTargets", "Regions" ],
      "additionalProperties" : false
    }
  },
  "properties" : {
    "StackSetName" : {
      "description" : "The name to associate with the stack set. The name must be unique in the Region where you create your stack set.",
      "type" : "string",
      "pattern" : "^[a-zA-Z][a-zA-Z0-9\\-]{0,127}$",
      "maxLength" : 128
    },
    "StackSetId" : {
      "description" : "The ID of the stack set that you're creating.",
      "type" : "string"
    },
    "AdministrationRoleARN" : {
      "description" : "The Amazon Resource Number (ARN) of the IAM role to use to create this stack set. Specify an IAM role only if you are using customized administrator roles to control which users or groups can manage specific stack sets within the same administrator account.",
      "type" : "string",
      "minLength" : 20,
      "maxLength" : 2048
    },
    "AutoDeployment" : {
      "description" : "Describes whether StackSets automatically deploys to AWS Organizations accounts that are added to the target organization or organizational unit (OU). Specify only if PermissionModel is SERVICE_MANAGED.",
      "$ref" : "#/definitions/AutoDeployment"
    },
    "Capabilities" : {
      "description" : "In some cases, you must explicitly acknowledge that your stack set template contains certain capabilities in order for AWS CloudFormation to create the stack set and related stack instances.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Capability"
      }
    },
    "Description" : {
      "description" : "A description of the stack set. You can use the description to identify the stack set's purpose or other important information.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 1024
    },
    "ExecutionRoleName" : {
      "description" : "The name of the IAM execution role to use to create the stack set. If you do not specify an execution role, AWS CloudFormation uses the AWSCloudFormationStackSetExecutionRole role for the stack set operation.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 64
    },
    "OperationPreferences" : {
      "$ref" : "#/definitions/OperationPreferences"
    },
    "StackInstancesGroup" : {
      "description" : "A group of stack instances with parameters in some specific accounts and regions.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/StackInstances"
      }
    },
    "Parameters" : {
      "description" : "The input parameters for the stack set template.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Parameter"
      }
    },
    "PermissionModel" : {
      "description" : "Describes how the IAM roles required for stack set operations are created. By default, SELF-MANAGED is specified.",
      "type" : "string",
      "enum" : [ "SERVICE_MANAGED", "SELF_MANAGED" ]
    },
    "Tags" : {
      "description" : "The key-value pairs to associate with this stack set and the stacks created from it. AWS CloudFormation also propagates these tags to supported resources that are created in the stacks. A maximum number of 50 tags can be specified.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "maxItems" : 50,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "TemplateBody" : {
      "description" : "The structure that contains the template body, with a minimum length of 1 byte and a maximum length of 51,200 bytes.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 51200
    },
    "TemplateURL" : {
      "description" : "Location of file containing the template body. The URL must point to a template (max size: 460,800 bytes) that is located in an Amazon S3 bucket.",
      "type" : "string",
      "minLength" : 1,
      "maxLength" : 5120
    },
    "CallAs" : {
      "description" : "Specifies the AWS account that you are acting from. By default, SELF is specified. For self-managed permissions, specify SELF; for service-managed permissions, if you are signed in to the organization's management account, specify SELF. If you are signed in to a delegated administrator account, specify DELEGATED_ADMIN.",
      "type" : "string",
      "enum" : [ "SELF", "DELEGATED_ADMIN" ]
    },
    "ManagedExecution" : {
      "description" : "Describes whether StackSets performs non-conflicting operations concurrently and queues conflicting operations.",
      "type" : "object",
      "properties" : {
        "Active" : {
          "$ref" : "#/definitions/Active"
        }
      },
      "additionalProperties" : false
    }
  },
  "required" : [ "StackSetName", "PermissionModel" ],
  "oneOf" : [ {
    "required" : [ "TemplateURL" ]
  }, {
    "required" : [ "TemplateBody" ]
  } ],
  "additionalProperties" : false,
  "createOnlyProperties" : [ "/properties/PermissionModel", "/properties/StackSetName" ],
  "writeOnlyProperties" : [ "/properties/TemplateURL", "/properties/OperationPreferences", "/properties/StackInstancesGroup", "/properties/CallAs" ],
  "readOnlyProperties" : [ "/properties/StackSetId" ],
  "primaryIdentifier" : [ "/properties/StackSetId" ],
  "additionalIdentifiers" : [ [ "/properties/StackSetName" ] ],
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : false,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "cloudformation:TagResource", "cloudformation:UntagResource" ]
  },
  "handlers" : {
    "create" : {
      "permissions" : [ "cloudformation:GetTemplateSummary", "cloudformation:CreateStackSet", "cloudformation:CreateStackInstances", "cloudformation:DescribeStackSetOperation", "cloudformation:ListStackSetOperationResults", "cloudformation:TagResource", "iam:PassRole" ],
      "timeoutInMinutes" : 2160
    },
    "read" : {
      "permissions" : [ "cloudformation:DescribeStackSet", "cloudformation:ListStackInstances", "cloudformation:DescribeStackInstance" ]
    },
    "update" : {
      "permissions" : [ "cloudformation:GetTemplateSummary", "cloudformation:UpdateStackSet", "cloudformation:CreateStackInstances", "cloudformation:DeleteStackInstances", "cloudformation:UpdateStackInstances", "cloudformation:DescribeStackSet", "cloudformation:DescribeStackSetOperation", "cloudformation:ListStackSetOperationResults", "cloudformation:TagResource", "cloudformation:UntagResource", "iam:PassRole" ],
      "timeoutInMinutes" : 2160
    },
    "delete" : {
      "permissions" : [ "cloudformation:DeleteStackSet", "cloudformation:DeleteStackInstances", "cloudformation:DescribeStackSet", "cloudformation:DescribeStackSetOperation", "cloudformation:ListStackSetOperationResults", "cloudformation:UntagResource" ],
      "timeoutInMinutes" : 2160
    },
    "list" : {
      "permissions" : [ "cloudformation:ListStackSets" ]
    }
  }
}