{
  "typeName" : "AWS::EVS::Environment",
  "description" : "An environment created within the EVS service",
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "definitions" : {
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "type" : "object",
      "properties" : {
        "Key" : {
          "type" : "string",
          "description" : "The key name of the tag. You can specify a value that is 1 to 128 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.",
          "minLength" : 1,
          "maxLength" : 128
        },
        "Value" : {
          "type" : "string",
          "description" : "The value for the tag. You can specify a value that is 0 to 256 Unicode characters in length and cannot be prefixed with aws:. You can use any of the following characters: the set of Unicode letters, digits, whitespace, _, ., /, =, +, and -.",
          "minLength" : 0,
          "maxLength" : 256
        }
      },
      "required" : [ "Key", "Value" ],
      "additionalProperties" : false
    },
    "InitialVlanInfo" : {
      "type" : "object",
      "properties" : {
        "Cidr" : {
          "type" : "string",
          "pattern" : "^((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)/(3[0-2]|[1-2][0-9]|[0-9])$"
        }
      },
      "required" : [ "Cidr" ]
    },
    "HostName" : {
      "type" : "string",
      "pattern" : "^([a-zA-Z0-9\\-]*)$"
    },
    "HostInfoForCreate" : {
      "type" : "object",
      "properties" : {
        "HostName" : {
          "$ref" : "#/definitions/HostName"
        },
        "KeyName" : {
          "type" : "string",
          "pattern" : "^[a-zA-Z0-9_-]+$",
          "minLength" : 1,
          "maxLength" : 255
        },
        "InstanceType" : {
          "type" : "string",
          "enum" : [ "i4i.metal" ]
        },
        "PlacementGroupId" : {
          "type" : "string",
          "pattern" : "^pg-[a-f0-9]{8}([a-f0-9]{9})?$",
          "minLength" : 1,
          "maxLength" : 25
        },
        "DedicatedHostId" : {
          "type" : "string",
          "pattern" : "^h-[a-f0-9]{8}([a-f0-9]{9})?$",
          "minLength" : 1,
          "maxLength" : 25
        }
      },
      "required" : [ "HostName", "KeyName", "InstanceType" ],
      "dependencies" : {
        "PlacementGroupId" : {
          "oneOf" : [ {
            "required" : [ "DedicatedHostId" ]
          }, { } ]
        }
      }
    },
    "RouteServerPeering" : {
      "type" : "string",
      "minLength" : 3,
      "maxLength" : 21
    },
    "EnvironmentState" : {
      "type" : "string",
      "enum" : [ "CREATING", "CREATED", "DELETING", "DELETED", "CREATE_FAILED" ]
    },
    "CheckResult" : {
      "type" : "string",
      "enum" : [ "PASSED", "FAILED", "UNKNOWN" ]
    },
    "Check" : {
      "type" : "object",
      "properties" : {
        "Type" : {
          "type" : "string",
          "enum" : [ "KEY_REUSE", "KEY_COVERAGE", "REACHABILITY", "VCF_VERSION", "HOST_COUNT" ]
        },
        "Result" : {
          "$ref" : "#/definitions/CheckResult"
        },
        "ImpairedSince" : {
          "type" : "string"
        }
      },
      "required" : [ "Type", "Result" ]
    },
    "Secret" : {
      "type" : "object",
      "properties" : {
        "SecretArn" : {
          "type" : "string"
        }
      }
    },
    "SecurityGroupId" : {
      "type" : "string",
      "pattern" : "^sg-[0-9a-zA-Z]*$",
      "minLength" : 3,
      "maxLength" : 25
    },
    "Timestamp" : {
      "type" : "string"
    },
    "NetworkAclId" : {
      "type" : "string",
      "pattern" : "^acl-[a-zA-Z0-9_-]+$"
    }
  },
  "properties" : {
    "EnvironmentName" : {
      "description" : "The name of an EVS environment",
      "type" : "string",
      "pattern" : "^[a-zA-Z0-9_-]{1,100}$"
    },
    "KmsKeyId" : {
      "type" : "string"
    },
    "VpcId" : {
      "type" : "string",
      "pattern" : "^vpc-[a-f0-9]{8}([a-f0-9]{9})?$",
      "minLength" : 12,
      "maxLength" : 21
    },
    "ServiceAccessSubnetId" : {
      "type" : "string",
      "pattern" : "^subnet-[a-f0-9]{8}([a-f0-9]{9})?$",
      "minLength" : 15,
      "maxLength" : 24
    },
    "VcfVersion" : {
      "type" : "string",
      "enum" : [ "VCF-5.2.1", "VCF-5.2.2" ]
    },
    "TermsAccepted" : {
      "type" : "boolean"
    },
    "LicenseInfo" : {
      "description" : "The license information for an EVS environment",
      "type" : "object",
      "properties" : {
        "SolutionKey" : {
          "type" : "string",
          "pattern" : "^[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}$"
        },
        "VsanKey" : {
          "type" : "string",
          "pattern" : "^[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}-[a-zA-Z0-9]{5}$"
        }
      },
      "required" : [ "SolutionKey", "VsanKey" ],
      "additionalProperties" : false
    },
    "InitialVlans" : {
      "description" : "The initial Vlan configuration only required upon creation. Modification after creation will have no effect",
      "type" : "object",
      "properties" : {
        "VmkManagement" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "VmManagement" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "VMotion" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "VSan" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "VTep" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "EdgeVTep" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "NsxUpLink" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "Hcx" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "IsHcxPublic" : {
          "type" : "boolean"
        },
        "HcxNetworkAclId" : {
          "$ref" : "#/definitions/NetworkAclId"
        },
        "ExpansionVlan1" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        },
        "ExpansionVlan2" : {
          "$ref" : "#/definitions/InitialVlanInfo"
        }
      },
      "required" : [ "VmkManagement", "VmManagement", "VMotion", "VSan", "VTep", "EdgeVTep", "NsxUpLink", "Hcx", "ExpansionVlan1", "ExpansionVlan2" ]
    },
    "Hosts" : {
      "description" : "The initial hosts for environment only required upon creation. Modification after creation will have no effect",
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/HostInfoForCreate"
      },
      "minItems" : 4,
      "maxItems" : 4,
      "insertionOrder" : true
    },
    "ConnectivityInfo" : {
      "type" : "object",
      "properties" : {
        "PrivateRouteServerPeerings" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/RouteServerPeering"
          },
          "minItems" : 2,
          "maxItems" : 2
        }
      },
      "required" : [ "PrivateRouteServerPeerings" ]
    },
    "VcfHostnames" : {
      "type" : "object",
      "properties" : {
        "VCenter" : {
          "$ref" : "#/definitions/HostName"
        },
        "Nsx" : {
          "$ref" : "#/definitions/HostName"
        },
        "NsxManager1" : {
          "$ref" : "#/definitions/HostName"
        },
        "NsxManager2" : {
          "$ref" : "#/definitions/HostName"
        },
        "NsxManager3" : {
          "$ref" : "#/definitions/HostName"
        },
        "NsxEdge1" : {
          "$ref" : "#/definitions/HostName"
        },
        "NsxEdge2" : {
          "$ref" : "#/definitions/HostName"
        },
        "SddcManager" : {
          "$ref" : "#/definitions/HostName"
        },
        "CloudBuilder" : {
          "$ref" : "#/definitions/HostName"
        }
      },
      "required" : [ "VCenter", "Nsx", "NsxManager1", "NsxManager2", "NsxManager3", "NsxEdge1", "NsxEdge2", "SddcManager", "CloudBuilder" ]
    },
    "SiteId" : {
      "type" : "string"
    },
    "EnvironmentId" : {
      "type" : "string",
      "pattern" : "^(env-[a-zA-Z0-9]{10})$"
    },
    "EnvironmentArn" : {
      "type" : "string",
      "pattern" : "^arn:aws:evs:[a-z]{2}-[a-z]+-[0-9]:[0-9]{12}:environment/[a-zA-Z0-9_-]+$",
      "minLength" : 1,
      "maxLength" : 1011
    },
    "EnvironmentState" : {
      "$ref" : "#/definitions/EnvironmentState"
    },
    "StateDetails" : {
      "type" : "string"
    },
    "Checks" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Check"
      }
    },
    "Credentials" : {
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Secret"
      }
    },
    "ServiceAccessSecurityGroups" : {
      "type" : "object",
      "properties" : {
        "SecurityGroups" : {
          "type" : "array",
          "items" : {
            "$ref" : "#/definitions/SecurityGroupId"
          }
        }
      }
    },
    "Tags" : {
      "description" : "An array of key-value pairs to apply to this resource.",
      "type" : "array",
      "uniqueItems" : true,
      "insertionOrder" : false,
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "CreatedAt" : {
      "$ref" : "#/definitions/Timestamp"
    },
    "ModifiedAt" : {
      "$ref" : "#/definitions/Timestamp"
    }
  },
  "required" : [ "VpcId", "ServiceAccessSubnetId", "VcfVersion", "TermsAccepted", "LicenseInfo", "ConnectivityInfo", "VcfHostnames", "SiteId" ],
  "additionalProperties" : false,
  "primaryIdentifier" : [ "/properties/EnvironmentId" ],
  "readOnlyProperties" : [ "/properties/EnvironmentId", "/properties/Checks", "/properties/EnvironmentArn", "/properties/Credentials", "/properties/EnvironmentState", "/properties/StateDetails", "/properties/CreatedAt", "/properties/ModifiedAt" ],
  "createOnlyProperties" : [ "/properties/EnvironmentName", "/properties/VpcId", "/properties/ServiceAccessSubnetId", "/properties/VcfVersion", "/properties/TermsAccepted", "/properties/LicenseInfo", "/properties/ConnectivityInfo", "/properties/VcfHostnames", "/properties/SiteId", "/properties/KmsKeyId", "/properties/ServiceAccessSecurityGroups" ],
  "writeOnlyProperties" : [ "/properties/Hosts", "/properties/InitialVlans" ],
  "deprecatedProperties" : [ "/properties/Checks/*/ImpairedSince", "/properties/Checks/*/Result", "/properties/Checks/*/Type", "/properties/Credentials/*/SecretArn" ],
  "handlers" : {
    "create" : {
      "permissions" : [ "evs:CreateEnvironment", "evs:GetEnvironment", "evs:TagResource", "evs:ListTagsForResource", "iam:CreateServiceLinkedRole", "support:DescribeServices", "support:DescribeSupportLevel", "servicequotas:GetServiceQuota", "servicequotas:ListServiceQuotas", "ec2:CreateNetworkInterface", "ec2:AllocateHosts", "ec2:ModifyNetworkInterfaceAttribute", "ec2:DeleteNetworkInterface", "ec2:RunInstances", "ec2:CreatePlacementGroup", "ec2:CreateSubnet", "ec2:CreateTags", "secretsmanager:GetRandomPassword", "secretsmanager:CreateSecret", "secretsmanager:GetSecretValue", "secretsmanager:BatchGetSecretValue", "secretsmanager:TagResource", "kms:ListKeysForService", "kms:DescribeKey", "secretsmanager:UpdateSecret", "ec2:DeleteVolume", "ec2:DetachVolume" ],
      "timeoutInMinutes" : 720
    },
    "read" : {
      "permissions" : [ "evs:GetEnvironment", "evs:ListTagsForResource" ]
    },
    "update" : {
      "permissions" : [ "evs:TagResource", "evs:UntagResource", "evs:ListTagsForResource", "evs:GetEnvironment" ]
    },
    "delete" : {
      "permissions" : [ "evs:DeleteEnvironment", "evs:GetEnvironment", "evs:UntagResource", "ec2:TerminateInstances", "ec2:ReleaseHosts", "ec2:DescribeHosts", "ec2:DeleteSubnet", "ec2:DetachNetworkInterface", "ec2:DeletePlacementGroup", "secretsmanager:DeleteSecret" ]
    },
    "list" : {
      "permissions" : [ "evs:ListEnvironments" ]
    }
  },
  "tagging" : {
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "cloudFormationSystemTags" : true,
    "tagProperty" : "/properties/Tags",
    "permissions" : [ "evs:UntagResource", "evs:TagResource", "evs:ListTagsForResource" ]
  }
}