---
aws-ec2-new:
  topology:
    topology_name: ec2-new
    resource_groups:
      - resource_group_name: "aws"
        resource_group_type: "aws"
        resource_definitions:
          - name: demo-day
            role: aws_ec2
            flavor: {{ flavor | default('t2.micro') }}
            region: {{ region | default('ca-central-1') }}
            image: {{ image | default('ami-0b85d4ff00de6a225') }}
            count: 1
            {% if tags is defined %}
            instance_tags:
              {% for tag in tags %}
              - {{ tag }}
              {% endfor %}
            {% else %}
            instance_tags:
              color: blue
              shape: oval
            {% endif %}
            {% if security_groups is defined %}
            instance_tags:
              {% for group in securit_groups %}
              - {{ group }}
              {% endfor %}
            {% else %}
            security_group:
              - default
            {% endif %}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-ec2-key-new:
  topology:
    topology_name: aws-ec2-key-new
    resource_groups:
      - resource_group_name: "aws"
        resource_group_type: "aws"
        resource_definitions:
          - name: "ec2_linchpin_keypair"
            role: "aws_ec2_key"
            region: "{{ region | default('ca-central-1') }}"
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-sg-new:
  topology:
    topology_name: aws-sg-new
    resource_groups:
      - resource_group_name: "aws"
        resource_group_type: "aws"
        resource_definitions:
          - name: "aws_sg_test"
            role: "aws_sg"
            description: {{ description | default('aws ssh security group') }}
            region: "{{ region | default('ca-central-1') }}"
            {% if rules is defined %}
            rules:
              {% for rule in rules %}
              - rule_type: {{ rule.type }}
                from_port: {{ rule.from_port }}
                to_port: {{ rule.to_port }}
                proto: {{ rule.proto }}
                cidr_ip: {{ rule.cidr_ip }}
              {% endfor %}
            {% else %}
            rules:
              - rule_type: "inbound"
                from_port: "8"
                to_port: -1
                proto: "icmp"
                cidr_ip: "0.0.0.0/0"
              - rule_type: "inbound"
                from_port: 22
                to_port: 22
                proto: "tcp"
                cidr_ip: "0.0.0.0/0"
              - rule_type: "outbound"
                from_port: 0
                to_port: 65535
                proto: "all"
                cidr_ip: "0.0.0.0/0"
            {% endif %}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-s3-new:
  topology:
    topology_name: aws-s3-new
    resource_groups:
      - resource_group_name: "aws_s3"
        resource_group_type: "aws"
        resource_definitions:
          - name: "linchpins3bucket"
            role: "aws_s3"
            region: "{{ region | default('ca-central-1') }}"
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}


aws-ec2-eip:
  topology:
    topology_name: ec2-new
    resource_groups:
      - resource_group_name: "aws"
        resource_group_type: "aws"
        resource_definitions:
          - name: demodaycilp
            role: aws_ec2_eip
            region: "{{ region | default('ca-central-1') }}"
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}


aws-ec2-vpc-net:
  topology:
    topology_name: ec2vpc
    resource_groups:
      - resource_group_name: "awsvpc"
        resource_group_type: "aws"
        resource_definitions:
          - name: "{{ distro }}demo_day_vpc"
            role: aws_ec2_vpc_net
            region: "{{ region | default('us-east-1') }}"
            cidr_block: {{ cidr_block | default('10.10.0.0/16') }}
            {% if tags is defined %}
              tags:
              {% for key, value in tags.items() %}
                {{key}}: {{value}}
              {% endfor %}
            {% else %}
            tags:
              module: "{{ distro }}-aws_ec2_vpc_net"
              this: works
            {% endif %}
            tenancy: {{ tenancy | default('dedicated') }}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-ec2-vpc-subnet:
  topology:
    topology_name: ec2vpcsubnetdemo
    resource_groups:
      - resource_group_name: "awsvpcsubnet"
        resource_group_type: "aws"
        resource_definitions:
          - name: demovpcnetsubnet
            role: aws_ec2_vpc_net
            region: {{ region | default('us-east-1') }}
            cidr_block: {{ cidr_block | default('13.0.0.0/16') }}
            {% if tags is defined %}
              tags:
              {% for key, value in tags.items() %}
                {{key}}: {{value}}
              {% endfor %}
            {% else %}
            tags:
              module: "{{ distro }}aws_ec2_vpc_net"
              this: works
            {% endif %}
            tenancy: {{ tenancy | default('dedicated') }}
          - name: demodayvpcsubnet
            role: aws_ec2_vpc_subnet
            region: {{ region | default('us-east-1') }}
            vpc_name: demovpcnetsubnet
            cidr: {{ cidr| default('13.0.1.0/24') }}
            {% if tags is defined %}
              tags:
              {% for key, value in tags.items() %}
                {{key}}: {{value}}
              {% endfor %}
            {% else %}
            tags:
              module: "{{ distro }}aws_ec2_vpc_subnet"
              this: works
            {% endif %}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}


aws-ec2-vpc-routetable:
  topology:
    topology_name: ec2vpcroutetabledemo
    resource_groups:
      - resource_group_name: "awsroutetabledemo"
        resource_group_type: "aws"
        resource_definitions:
          - name: demo_vpc_net_r
            role: aws_ec2_vpc_net
            region: us-east-1
            cidr_block: 15.0.0.0/16
            tags:
              module: "{{ distro }}aws_ec2_vpc_net"
              this: alsoworks
            tenancy: dedicated
          - name: demo_vpc_subnet_r
            role: aws_ec2_vpc_subnet
            region: us-east-1
            vpc_name: demo_vpc_net_r
            cidr: 15.0.1.0/24
            tags:
              module: "{{ distro }}aws_ec2_vpc_subnet"
              this: alsoworks
          - name: demo_routetable
            role: aws_ec2_vpc_routetable
            region: us-east-1
            vpc_name: demo_vpc_net_r
            tags:
              module: "{{ distro }}aws_ec2_vpc_routetable"
              this: alsoworks
            subnets:
              - 'demo_vpc_subnet_r'
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}


aws-ec2-vpc-endpoint:
  topology:
    topology_name: ec2vpcendpoint
    resource_groups:
      - resource_group_name: "awsroutetabledemo"
        resource_group_type: "aws"
        resource_definitions:
          - name: demo_vpc_net_ep
            role: aws_ec2_vpc_net
            region: us-east-1
            cidr_block: 17.0.0.0/16
            tags:
              module: "{{ distro }}aws_ec2_vpc_net"
              some: aws_ec2_vpc_ep
              this: alsoworks
            tenancy: dedicated
          - name: demo_vpc_subnet_ep
            role: aws_ec2_vpc_subnet
            region: us-east-1
            vpc_name: demo_vpc_net_ep
            cidr: 17.0.1.0/24
            tags:
              module: "{{ distro }}aws_ec2_vpc_subnet"
              this: alsoworks
          - name: demo_routetable_ep
            role: aws_ec2_vpc_routetable
            region: us-east-1
            vpc_name: demo_vpc_net_ep
            tags:
              module: "{{ distro }}aws_ec2_vpc_routetable"
              this: alsoworks
            subnets:
              - 'demo_vpc_subnet_ep'
          - name: demo_ec2_vpc_ep
            role: aws_ec2_vpc_endpoint
            region: us-east-1
            vpc_name: demo_vpc_net_ep
            service: com.amazonaws.us-east-1.s3
            route_table_name: demo_routetable_ep
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-ec2-vpc-nat-gateway:
  topology:
    topology_name: {{ distro | default('test-')}}ec2vpcnatgateway
    resource_groups:
      - resource_group_name: "aws_ec2_vpc_nat_gateway"
        resource_group_type: "aws"
        resource_definitions:
          - name: demo_vpc_net_ep_ci_lp
            role: aws_ec2_vpc_net
            region: ca-central-1
            cidr_block: 17.0.0.0/16
            tags:
              module: ec2vpcnatgateway_demo
              desc: provisioned_by_linchpin
              distro: {{ distro | default('test')}}
          - name: demo_vpc_subnet_ep_ci_lp
            role: aws_ec2_vpc_subnet
            region: ca-central-1
            vpc_name: demo_vpc_net_ep_ci_lp
            cidr: 17.0.1.0/24
            tags:
              module: ec2vpcnatgateway_demo
              distro: {{ distro | default('test')}}
          - name: demo_vpc_nat_gateway_ci_lp
            role: aws_ec2_vpc_nat_gateway
            region: ca-central-1
            subnet_filters:
              "tag:module": ec2vpcnatgateway_demo
              "tag:distro": {{ distro | default('test')}}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}


aws-ec2-elb-lb:
  topology:
    topology_name: ec2elblb
    resource_groups:
      - resource_group_name: "awsec2elblbdemo"
        resource_group_type: "aws"
        resource_definitions:
          - name: "{{ distro }}demoec2elblbcilp"
            role: aws_ec2_elb_lb
            region: {{ region | default('ca-central-1') }}
            {% if zones is defined %}
            zones:
              {% for zone in zones %}
              - {{ zone }}
              {% endfor %}
            {% else %}
            zones:
            - ca-central-1a
            - ca-central-1b
            {% endif %}
            {% if listeners is defined %}
            listeners:
              {% for listener in listeners %}
            - protocol: {{ listener.protocol }}
              load_balancer_port: {{ listener.lb_port }}
              instance_port: {{ listener.instance_port }}
              proxy_protocol: {{ listener.proxy }}
              {% endfor %}
            {% else %}
            listeners:
            - protocol: http # options are http, https, ssl, tcp
              load_balancer_port: 80
              instance_port: 80
              proxy_protocol: True
            {% endif %}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-ec2-vpc-internet-gateway:
  topology:
    topology_name: ec2vpc
    resource_groups:
      - resource_group_name: "awsvpc-net"
        resource_group_type: "aws"
        resource_definitions:
          - name: "{{ distro | default('fedora') }}-vpc-test"
            role: aws_ec2_vpc_net
            region: ca-central-1
            cidr_block: 10.10.0.0/16
            tags:
              module: aws_ec2_vpc_net
              this: works
            tenancy: dedicated
          - name: demo_vpc_internet_gateway
            role: aws_ec2_vpc_internet_gateway
            region: ca-central-1
            vpc_name: "{{ distro | default('fedora') }}-vpc-test"
           #vpc_id is optional, normally you can choose put vpc_id or vpc_name, but not both
           # vpc_id: {{ vpc_id|default('vpc-0546ae7a407edb9a9') }}
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

aws-ec2-template:
  topology:
    topology_name: aws-template-inventory
    resource_groups:
      - resource_group_name: "aws-template-inventory"
        resource_group_type: "aws"
        resource_definitions:
        - name: "template-inventory{{ distro }}"
          flavor: t2.micro
          role: aws_ec2
          region: ca-central-1
          image: ami-0b85d4ff00de6a225
          count: 1
          instance_tags:
            color: blue
            shape: oval
            desc: provisioned_by_linchpin
            distro: "{{ distro }}"
          security_group:
          - default
        {% if credentials is defined %}
        credentials:
          filename: {{ credentials.filename }}
          profile: {{ credentials.profile }}
        {% else %}
        credentials:
          filename: aws.key
          profile: default
        {% endif %}

  layout:
    inventory_layout:
      vars:
        hostname: __IP__
      hosts:
        example-node:
          count: 1
          host_groups:
            - example
