AWSTemplateFormatVersion: "2010-09-09"

Description: AWS CloudFormation workshop - Linting and testing - VPC and Security Group template (uksb-1q9p31idr) (tag:linting-and-testing).

Parameters:
  VpcIpv4Cidr:
    Description: The IPv4 CIDR block you wish to assign to your VPC.
    Type: String
    Default: 10.0.0.0/16

Resources:
  Vpc:
    Type: AWS::EC2::VPC
    Properties:
      CidrBlock: !Ref VpcIpv4Cidr

  SecurityGroup:
    # This example SecurityGroup resource contains a circular
    # dependency error: SourceSecurityGroupId references the same
    # SecurityGroup resource you are describing
    Type: AWS::EC2::SecurityGroup
    Properties:
      GroupDescription: Example Security Group
      SecurityGroupIngress:
        - Description: Example rule to allow tcp/443 traffic from SecurityGroup
          FromPort: 443
          ToPort: 443
          IpProtocol: tcp
          SourceSecurityGroupId: !Ref SecurityGroup
      SecurityGroupEgress:
        - Description: Example rule limiting egress traffic to 127.0.0.1/32
          CidrIp: 127.0.0.1/32
          IpProtocol: "-1"
      VpcId: !Ref Vpc