{
  "typeName" : "AWS::Budgets::BudgetsAction",
  "description" : "An example resource schema demonstrating some basic constructs and validation rules.",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "Subscriber" : {
      "type" : "object",
      "properties" : {
        "Type" : {
          "type" : "string",
          "enum" : [ "SNS", "EMAIL" ]
        },
        "Address" : {
          "type" : "string"
        }
      },
      "required" : [ "Type", "Address" ],
      "additionalProperties" : false
    },
    "ActionThreshold" : {
      "type" : "object",
      "properties" : {
        "Value" : {
          "type" : "number"
        },
        "Type" : {
          "type" : "string",
          "enum" : [ "PERCENTAGE", "ABSOLUTE_VALUE" ]
        }
      },
      "required" : [ "Value", "Type" ],
      "additionalProperties" : false
    },
    "IamActionDefinition" : {
      "type" : "object",
      "properties" : {
        "PolicyArn" : {
          "type" : "string"
        },
        "Roles" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          },
          "minItems" : 1,
          "maxItems" : 100
        },
        "Groups" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          },
          "minItems" : 1,
          "maxItems" : 100
        },
        "Users" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          },
          "minItems" : 1,
          "maxItems" : 100
        }
      },
      "required" : [ "PolicyArn" ],
      "additionalProperties" : false
    },
    "ScpActionDefinition" : {
      "type" : "object",
      "properties" : {
        "PolicyId" : {
          "type" : "string"
        },
        "TargetIds" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          },
          "minItems" : 1,
          "maxItems" : 100
        }
      },
      "required" : [ "PolicyId", "TargetIds" ],
      "additionalProperties" : false
    },
    "SsmActionDefinition" : {
      "type" : "object",
      "properties" : {
        "Subtype" : {
          "type" : "string",
          "enum" : [ "STOP_EC2_INSTANCES", "STOP_RDS_INSTANCES" ]
        },
        "Region" : {
          "type" : "string"
        },
        "InstanceIds" : {
          "type" : "array",
          "items" : {
            "type" : "string"
          },
          "minItems" : 1,
          "maxItems" : 100
        }
      },
      "required" : [ "Subtype", "Region", "InstanceIds" ],
      "additionalProperties" : false
    },
    "Definition" : {
      "type" : "object",
      "properties" : {
        "IamActionDefinition" : {
          "$ref" : "#/definitions/IamActionDefinition"
        },
        "ScpActionDefinition" : {
          "$ref" : "#/definitions/ScpActionDefinition"
        },
        "SsmActionDefinition" : {
          "$ref" : "#/definitions/SsmActionDefinition"
        }
      },
      "additionalProperties" : false
    },
    "ResourceTag" : {
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string"
        },
        "Value" : {
          "type" : "string"
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    }
  },
  "properties" : {
    "ActionId" : {
      "type" : "string"
    },
    "BudgetName" : {
      "type" : "string"
    },
    "NotificationType" : {
      "type" : "string",
      "enum" : [ "ACTUAL", "FORECASTED" ]
    },
    "ActionType" : {
      "type" : "string",
      "enum" : [ "APPLY_IAM_POLICY", "APPLY_SCP_POLICY", "RUN_SSM_DOCUMENTS" ]
    },
    "ActionThreshold" : {
      "$ref" : "#/definitions/ActionThreshold"
    },
    "ExecutionRoleArn" : {
      "type" : "string"
    },
    "ApprovalModel" : {
      "type" : "string",
      "enum" : [ "AUTOMATIC", "MANUAL" ]
    },
    "Subscribers" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Subscriber"
      },
      "maxItems" : 11,
      "minItems" : 1
    },
    "Definition" : {
      "$ref" : "#/definitions/Definition"
    },
    "ResourceTags" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/ResourceTag"
      }
    }
  },
  "additionalProperties" : false,
  "required" : [ "BudgetName", "NotificationType", "ActionType", "ActionThreshold", "ExecutionRoleArn", "Definition", "Subscribers" ],
  "readOnlyProperties" : [ "/properties/ActionId" ],
  "createOnlyProperties" : [ "/properties/ActionType", "/properties/BudgetName" ],
  "primaryIdentifier" : [ "/properties/ActionId", "/properties/BudgetName" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "budgets:CreateBudgetAction", "iam:PassRole", "budgets:TagResource" ]
    },
    "read" : {
      "permissions" : [ "budgets:DescribeBudgetAction", "budgets:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "budgets:UpdateBudgetAction", "iam:PassRole", "budgets:TagResource", "budgets:UntagResource", "budgets:ListTagsForResource" ]
    },
    "delete" : {
      "permissions" : [ "budgets:DeleteBudgetAction" ]
    },
    "list" : {
      "permissions" : [ "budgets:DescribeBudgetActionsForAccount", "budgets:DescribeBudgetActionsForBudget" ]
    }
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/ResourceTags",
    "permissions" : [ "budgets:TagResource", "budgets:UntagResource", "budgets:ListTagsForResource" ]
  }
}