# etc/simple-ec2.yml
AWSTemplateFormatVersion: "2010-09-09"
Parameters:
  KeyPairName:
    Description: >
      The EC2 key pair used for the instance
    Type: AWS::EC2::KeyPair::KeyName
  EnvironmentType:
    Type: String
    Description: Environment this instance is used by
    Default: Staging
    AllowedValues:
      - Staging
      - Production
  VPCStackName:
    Type: String
    Description: VPC stack to launch the instance into
  ImageId:
    Type: String
  AlarmSnsTopic:
    Type: String
    Description: Optional topic arn for CloudWatch alarms
  UniqueName:
    Type: String
    Description: Unique name for associated resources (CamelCase; should not include env name)
    AllowedPattern: ^[a-zA-Z][a-zA-Z0-9\-]*$
Conditions:
  IsProduction: !Equals [!Ref EnvironmentType, Production]
  CreateAlarms: !Not [!Equals [!Ref AlarmSnsTopic, ""]]
Resources:
  SolrInstance:
    Type: AWS::EC2::Instance
    Properties:
      InstanceType: t2.medium
      ImageId: !Ref ImageId
      KeyName: !Ref KeyPairName
      SecurityGroupIds:
        - !GetAtt SecurityGroup.GroupId
      SubnetId:
        Fn::ImportValue:
          !Sub ${VPCStackName}-Subnet1
      Tags:
        # - Key: Project
        #   Value: !Ref ProjectName
        - Key: Environment
          Value: !Ref EnvironmentType
        - Key: "prx:cloudformation:stack-name"
          Value: !Ref AWS::StackName
        - Key: "prx:cloudformation:stack-id"
          Value: !Ref AWS::StackId
  SecurityGroup:
    Type: AWS::EC2::SecurityGroup
    DeletionPolicy: Retain
    Properties:
      GroupName: !Sub ${UniqueName}${EnvironmentType}Solr
      GroupDescription: !Sub ${UniqueName} ${EnvironmentType} Solr Security Group
      SecurityGroupIngress:
        - CidrIp: 0.0.0.0/0
          IpProtocol: tcp
          FromPort: 22
          ToPort: 22
        - CidrIp: 0.0.0.0/0
          IpProtocol: tcp
          FromPort: 8009
          ToPort: 8009
        - CidrIp: 0.0.0.0/0
          IpProtocol: tcp
          FromPort: 8983
          ToPort: 8983
      Tags:
        - Key: Name
          Value: !Sub ${UniqueName}${EnvironmentType}Solr
        # - Key: Project
        #   Value: !Ref ProjectName
        - Key: Environment
          Value: !Ref EnvironmentType
        - Key: "prx:cloudformation:stack-name"
          Value: !Ref AWS::StackName
        - Key: "prx:cloudformation:stack-id"
          Value: !Ref AWS::StackId
      VpcId:
        Fn::ImportValue: !Sub ${VPCStackName}-VPC

Add simple, generic EC2 instance template
Add simple, generic EC2 instance template
