{
  "tagging" : {
    "permissions" : [ "directconnect:TagResource", "directconnect:UntagResource" ],
    "taggable" : true,
    "tagOnCreate" : true,
    "tagUpdatable" : true,
    "tagProperty" : "/properties/Tags",
    "cloudFormationSystemTags" : true
  },
  "typeName" : "AWS::DirectConnect::PublicVirtualInterface",
  "readOnlyProperties" : [ "/properties/BgpPeers/*/BgpPeerId", "/properties/VirtualInterfaceArn", "/properties/VirtualInterfaceId" ],
  "description" : "Resource Type definition for AWS::DirectConnect::PublicVirtualInterface",
  "createOnlyProperties" : [ "/properties/AllocatePublicVirtualInterfaceRoleArn", "/properties/RouteFilterPrefixes", "/properties/Vlan" ],
  "primaryIdentifier" : [ "/properties/VirtualInterfaceArn" ],
  "required" : [ "BgpPeers", "ConnectionId", "VirtualInterfaceName", "Vlan" ],
  "sourceUrl" : "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git",
  "propertyTransform" : {
    "/properties/ConnectionId" : "$lowercase($substringAfter(ConnectionId, \"/\"))"
  },
  "handlers" : {
    "read" : {
      "permissions" : [ "directconnect:DescribeVirtualInterfaces" ]
    },
    "create" : {
      "permissions" : [ "directconnect:ConfirmPublicVirtualInterface", "directconnect:CreateBGPPeer", "directconnect:CreatePublicVirtualInterface", "directconnect:DescribeVirtualInterfaces", "directconnect:TagResource", "sts:AssumeRole" ]
    },
    "update" : {
      "permissions" : [ "directconnect:AssociateVirtualInterface", "directconnect:CreateBGPPeer", "directconnect:DeleteBGPPeer", "directconnect:DescribeVirtualInterfaces", "directconnect:TagResource", "directconnect:UntagResource", "directconnect:UpdateVirtualInterfaceAttributes" ]
    },
    "list" : {
      "permissions" : [ "directconnect:DescribeVirtualInterfaces" ]
    },
    "delete" : {
      "permissions" : [ "directconnect:DeleteVirtualInterface", "directconnect:DescribeVirtualInterfaces" ]
    }
  },
  "writeOnlyProperties" : [ "/properties/AllocatePublicVirtualInterfaceRoleArn" ],
  "additionalIdentifiers" : [ [ "/properties/VirtualInterfaceId" ] ],
  "additionalProperties" : false,
  "definitions" : {
    "BgpPeer" : {
      "description" : "Information about a BGP peer.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "BgpPeerId" : {
          "pattern" : "^dxpeer-[a-z0-9]{8}$",
          "type" : "string"
        },
        "AuthKey" : {
          "pattern" : "^[A-Za-z0-9\\\\!\"#$%&'()*+,\\-./:;<=>?@\\[\\]\\^_`{|}~]{6,80}$",
          "description" : "The authentication key for BGP configuration. This string has a minimum length of 6 characters and and a maximum length of 80 characters.",
          "type" : "string"
        },
        "AddressFamily" : {
          "pattern" : "^(ipv4)|(ipv6)$",
          "description" : "The address family for the BGP peer.",
          "type" : "string"
        },
        "AmazonAddress" : {
          "pattern" : "^[0-9a-fA-F:.]+/[0-9]+$",
          "description" : "The IP address assigned to the Amazon interface.",
          "type" : "string"
        },
        "Asn" : {
          "pattern" : "^[1-9][0-9]*$",
          "description" : "The autonomous system (AS) number for Border Gateway Protocol (BGP) configuration.",
          "type" : "string"
        },
        "CustomerAddress" : {
          "pattern" : "^[0-9a-fA-F:.]+/[0-9]+$",
          "description" : "The IP address assigned to the customer interface.",
          "type" : "string"
        }
      },
      "required" : [ "AddressFamily", "Asn" ]
    },
    "Tag" : {
      "description" : "A key-value pair to associate with a resource.",
      "additionalProperties" : false,
      "type" : "object",
      "properties" : {
        "Value" : {
          "minLength" : 0,
          "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 -.",
          "type" : "string",
          "maxLength" : 256
        },
        "Key" : {
          "minLength" : 1,
          "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 -.",
          "type" : "string",
          "maxLength" : 128
        }
      },
      "required" : [ "Key", "Value" ]
    }
  },
  "replacementStrategy" : "delete_then_create",
  "properties" : {
    "BgpPeers" : {
      "minItems" : 1,
      "maxItems" : 2,
      "uniqueItems" : true,
      "description" : "The BGP peers configured on this virtual interface.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/BgpPeer"
      }
    },
    "ConnectionId" : {
      "pattern" : "^((arn:aws[a-z-]*:directconnect:[a-z0-9-]+:[0-9]{12}:(dxcon/dxcon|dxlag/dxlag))|dx(con|lag))-[a-z0-9A-Z]{8,21}$",
      "description" : "The ID or ARN of the connection or LAG.",
      "anyOf" : [ {
        "relationshipRef" : {
          "typeName" : "AWS::DirectConnect::Connection",
          "propertyPath" : "/properties/ConnectionId"
        }
      }, {
        "relationshipRef" : {
          "typeName" : "AWS::DirectConnect::Connection",
          "propertyPath" : "/properties/ConnectionArn"
        }
      }, {
        "relationshipRef" : {
          "typeName" : "AWS::DirectConnect::Lag",
          "propertyPath" : "/properties/LagId"
        }
      }, {
        "relationshipRef" : {
          "typeName" : "AWS::DirectConnect::Lag",
          "propertyPath" : "/properties/LagArn"
        }
      } ],
      "type" : "string"
    },
    "RouteFilterPrefixes" : {
      "minItems" : 1,
      "uniqueItems" : true,
      "description" : "The routes to be advertised to the AWS network in this region.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "pattern" : "^[0-9a-fA-F:.]+/[0-9]+$",
        "description" : "A CIDR block for the advertised route. An IPv6 CIDR must use /64 or shorter.",
        "type" : "string"
      }
    },
    "VirtualInterfaceId" : {
      "pattern" : "^dxvif-[a-z0-9]{8}$",
      "description" : "The ID of the virtual interface.",
      "type" : "string"
    },
    "VirtualInterfaceName" : {
      "pattern" : "^[\\w \\-_,\\/]{1,100}$",
      "description" : "The name of the virtual interface assigned by the customer network. The name has a maximum of 100 characters. The following are valid characters: a-z, 0-9 and a hyphen (-).",
      "type" : "string"
    },
    "VirtualInterfaceArn" : {
      "pattern" : "^arn:aws[a-z-]*:directconnect:[a-z0-9-]+:[0-9]{12}:dxvif/dxvif-[a-z0-9]{8}$",
      "description" : "The ARN of the virtual interface.",
      "type" : "string"
    },
    "Vlan" : {
      "description" : "The ID of the VLAN.",
      "maximum" : 4095,
      "type" : "integer",
      "minimum" : 0
    },
    "Tags" : {
      "minItems" : 1,
      "uniqueItems" : true,
      "description" : "The tags associated with the public virtual interface.",
      "insertionOrder" : false,
      "type" : "array",
      "items" : {
        "$ref" : "#/definitions/Tag"
      }
    },
    "AllocatePublicVirtualInterfaceRoleArn" : {
      "pattern" : "^arn:aws[a-z-]*:iam::[0-9]{12}:role/.+$",
      "description" : "The Amazon Resource Name (ARN) of the role to allocate the public virtual interface. Needs directconnect:AllocatePublicVirtualInterface permissions and tag permissions if applicable.",
      "type" : "string"
    }
  }
}