{
 "$schema": "https://raw.githubusercontent.com/aws-cloudformation/cloudformation-resource-schema/master/src/main/resources/schema/provider.definition.schema.v1.json",
 "additionalProperties": false,
 "createOnlyProperties": [
  "/properties/GroupDescription",
  "/properties/GroupName",
  "/properties/VpcId"
 ],
 "definitions": {
  "Egress": {
   "additionalProperties": false,
   "properties": {
    "CidrIp": {
     "format": "ipv4-network",
     "type": "string"
    },
    "CidrIpv6": {
     "format": "ipv6-network",
     "type": "string"
    },
    "Description": {
     "type": "string"
    },
    "DestinationPrefixListId": {
     "type": "string"
    },
    "DestinationSecurityGroupId": {
     "format": "AWS::EC2::SecurityGroup.Id",
     "type": "string"
    },
    "FromPort": {
     "minimum": -1,
     "type": "integer"
    },
    "IpProtocol": {
     "type": "string"
    },
    "ToPort": {
     "minimum": -1,
     "type": "integer"
    }
   },
   "required": [
    "IpProtocol"
   ],
   "requiredXor": [
    "CidrIp",
    "CidrIpv6",
    "DestinationSecurityGroupId",
    "DestinationPrefixListId"
   ],
   "type": "object"
  },
  "Ingress": {
   "additionalProperties": false,
   "properties": {
    "CidrIp": {
     "format": "ipv4-network",
     "type": "string"
    },
    "CidrIpv6": {
     "format": "ipv6-network",
     "type": "string"
    },
    "Description": {
     "type": "string"
    },
    "FromPort": {
     "minimum": -1,
     "type": "integer"
    },
    "IpProtocol": {
     "type": "string"
    },
    "SourcePrefixListId": {
     "type": "string"
    },
    "SourceSecurityGroupId": {
     "format": "AWS::EC2::SecurityGroup.Id",
     "type": "string"
    },
    "SourceSecurityGroupName": {
     "format": "AWS::EC2::SecurityGroup.Name",
     "type": "string"
    },
    "SourceSecurityGroupOwnerId": {
     "type": "string"
    },
    "ToPort": {
     "minimum": -1,
     "type": "integer"
    }
   },
   "required": [
    "IpProtocol"
   ],
   "requiredXor": [
    "CidrIp",
    "CidrIpv6",
    "SourcePrefixListId",
    "SourceSecurityGroupId",
    "SourceSecurityGroupName"
   ],
   "type": "object"
  },
  "Tag": {
   "additionalProperties": false,
   "properties": {
    "Key": {
     "type": "string"
    },
    "Value": {
     "type": "string"
    }
   },
   "required": [
    "Value",
    "Key"
   ],
   "type": "object"
  }
 },
 "dependentRequired": {
  "SecurityGroupEgress": [
   "VpcId"
  ]
 },
 "primaryIdentifier": [
  "/properties/Id"
 ],
 "properties": {
  "GroupDescription": {
   "maxLength": 255,
   "minLength": 0,
   "pattern": "^([a-z,A-Z,0-9,. _\\-:/()#,@[\\]+=&;\\{\\}!$*])*$",
   "type": "string"
  },
  "GroupId": {
   "format": "AWS::EC2::SecurityGroup.Id",
   "type": "string"
  },
  "GroupName": {
   "format": "AWS::EC2::SecurityGroup.Name",
   "type": "string"
  },
  "Id": {
   "anyOf": [
    {
     "format": "AWS::EC2::SecurityGroup.Id"
    },
    {
     "format": "AWS::EC2::SecurityGroup.Name"
    }
   ],
   "type": "string"
  },
  "SecurityGroupEgress": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/Egress"
   },
   "type": "array",
   "uniqueItems": false
  },
  "SecurityGroupIngress": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/Ingress"
   },
   "type": "array",
   "uniqueItems": false
  },
  "Tags": {
   "insertionOrder": false,
   "items": {
    "$ref": "#/definitions/Tag"
   },
   "type": "array",
   "uniqueItems": false
  },
  "VpcId": {
   "format": "AWS::EC2::VPC.Id",
   "type": "string"
  }
 },
 "propertyTransform": {
  "/properties/SecurityGroupEgress/*/FromPort": "($mapVal := $lookup({'1': 'icmp','6': 'tcp','17': 'udp','58': 'icmpv6'}, IpProtocol);$ipProtocol := $mapVal ? $mapVal : $lowercase(IpProtocol);$ipProtocol in ['imcp', 'tcp', 'udp', 'imcp'] ? FromPort : -1)",
  "/properties/SecurityGroupEgress/*/IpProtocol": "($mapVal := $lookup({'1': 'icmp','6': 'tcp','17': 'udp','58': 'icmpv6'}, IpProtocol);$mapVal ? $mapVal : $lowercase(IpProtocol))",
  "/properties/SecurityGroupEgress/*/ToPort": "($mapVal := $lookup({'1': 'icmp','6': 'tcp','17': 'udp','58': 'icmpv6'}, IpProtocol);$ipProtocol := $mapVal ? $mapVal : $lowercase(IpProtocol);$ipProtocol in ['imcp', 'tcp', 'udp', 'imcp'] ? ToPort : -1)",
  "/properties/SecurityGroupIngress/*/FromPort": "($mapVal := $lookup({'1': 'icmp','6': 'tcp','17': 'udp','58': 'icmpv6'}, IpProtocol);$ipProtocol := $mapVal ? $mapVal : $lowercase(IpProtocol);$ipProtocol in ['imcp', 'tcp', 'udp', 'imcp'] ? FromPort : -1)",
  "/properties/SecurityGroupIngress/*/IpProtocol": "($mapVal := $lookup({'1': 'icmp','6': 'tcp','17': 'udp','58': 'icmpv6'}, IpProtocol);$mapVal ? $mapVal : $lowercase(IpProtocol))",
  "/properties/SecurityGroupIngress/*/ToPort": "($mapVal := $lookup({'1': 'icmp','6': 'tcp','17': 'udp','58': 'icmpv6'}, IpProtocol);$ipProtocol := $mapVal ? $mapVal : $lowercase(IpProtocol);$ipProtocol in ['imcp', 'tcp', 'udp', 'imcp'] ? ToPort : -1)"
 },
 "readOnlyProperties": [
  "/properties/Id",
  "/properties/GroupId"
 ],
 "required": [
  "GroupDescription"
 ],
 "tagging": {
  "cloudFormationSystemTags": true,
  "tagOnCreate": true,
  "tagProperty": "/properties/Tags",
  "tagUpdatable": true,
  "taggable": true
 },
 "typeName": "AWS::EC2::SecurityGroup",
 "writeOnlyProperties": [
  "/properties/SecurityGroupIngress/*/SourceSecurityGroupName"
 ]
}
