ec2-security-group-exists

Description

Create an instance on Amazon EC2, if it doesn't exist yet.

Variables

Name Type Default Description

aws_access_key

string --

The AWS access key. Required

aws_secret_key

string --

The AWS secret key. Required

description

string --

Description of the security group. Required

group_name

string --

The name of the security group. Required

region

string --

The AWS region to use. Required

register_target

string --

The name of the variable to register the result of this frecklet.

vpc_id

string --

ID of the VPC to create the group in.

Code

doc:
  short_help: Create an instance on Amazon EC2, if it doesn't exist yet.

args:
  aws_access_key:
    doc:
      short_help: The AWS access key.
    type: string
    required: true
  aws_secret_key:
    doc:
      short_help: The AWS secret key.
    type: string
    secret: true
    required: true
  region:
    doc:
      short_help: The AWS region to use.
      references:
        AWS region documentation: https://docs.aws.amazon.com/general/latest/gr/rande.html#ec2_region
    type: string
    required: true
  group_name:
    doc:
      short_help: The name of the security group.
    type: string
    required: true
  description:
    doc:
      short_help: Description of the security group.
    type: string
    required: true
  vpc_id:
    doc:
      short_help: ID of the VPC to create the group in.
    type: string
    required: false
  register_target:
    doc:
      short_help: The name of the variable to register the result of this frecklet.
    type: string
    required: false
    cli:
      metavar: VAR_NAME

frecklets:
- frecklet:
    name: ec2_group
    type: ansible-module
    register: '{{:: register_target ::}}'
    properties:
      elevated: false
      idempotent: true
      internet: true
    desc:
      short: 'create EC2 security group: {{:: group_name ::}}'
    resources:
      python-package:
      - boto
      - boto3
      - botocore
  task:
    include-type: include
    delegate_to: localhost
  vars:
    aws_access_key: '{{:: aws_access_key ::}}'
    aws_secret_key: '{{:: aws_secret_key ::}}'
    region: '{{:: region ::}}'
    state: present
    name: '{{:: group_name ::}}'
    description: '{{:: description ::}}'
    vpc_id: '{{:: vpc_id ::}}'
    rules:
    - proto: tcp
      from_port: 22
      to_port: 22
      cidr_ip: 0.0.0.0/0
    - proto: tcp
      from_port: 80
      to_port: 80
      cidr_ip: 0.0.0.0/0
    - proto: tcp
      from_port: 443
      to_port: 443
      cidr_ip: 0.0.0.0/0
    rules_egress:
    - proto: all
      cidr_ip: 0.0.0.0/0
frecklecute --community ec2-security-group-exists --help

Usage: frecklecute ec2-security-group-exists [OPTIONS]

  Create an instance on Amazon EC2, if it doesn't exist yet.

Options:
  --aws-access-key AWS_ACCESS_KEY
                                  The AWS access key.  [required]
  --aws-secret-key AWS_SECRET_KEY
                                  The AWS secret key.  [required]
  --description DESCRIPTION       Description of the security group.
                                  [required]
  --group-name GROUP_NAME         The name of the security group.  [required]
  --region REGION                 The AWS region to use.  [required]
  --register-target VAR_NAME      The name of the variable to register the
                                  result of this frecklet.
  --vpc-id VPC_ID                 ID of the VPC to create the group in.
  --help                          Show this message and exit.
# -*- coding: utf-8 -*-


#
# module path: pycklets.ec2_security_group_exists.Ec2SecurityGroupExists
#


from dataclasses import dataclass
from pyckles import AutoPycklet
from typing import *    # noqa

@dataclass
class Ec2SecurityGroupExists(AutoPycklet):
    """Create an instance on Amazon EC2, if it doesn't exist yet.

       Args:
         aws_access_key: The AWS access key.
         aws_secret_key: The AWS secret key.
         description: Description of the security group.
         group_name: The name of the security group.
         region: The AWS region to use.
         register_target: The name of the variable to register the result of this frecklet.
         vpc_id: ID of the VPC to create the group in.

    """

    FRECKLET_ID = "ec2-security-group-exists"

    aws_access_key: str = None
    aws_secret_key: str = None
    description: str = None
    group_name: str = None
    region: str = None
    register_target: str = None
    vpc_id: str = None


    def __post_init__(self):
        super(Ec2SecurityGroupExists, self).__init__(var_names=["aws_access_key", "aws_secret_key", "description", "group_name", "region", "register_target", "vpc_id"])


frecklet_class = Ec2SecurityGroupExists
# -*- coding: utf-8 -*-


#
# module path: pycklets.ec2_security_group_exists.Ec2SecurityGroupExists
#


from pyckles import AutoPycklet

class Ec2SecurityGroupExists(AutoPycklet):
    """Create an instance on Amazon EC2, if it doesn't exist yet.

       Args:
         aws_access_key: The AWS access key.
         aws_secret_key: The AWS secret key.
         description: Description of the security group.
         group_name: The name of the security group.
         region: The AWS region to use.
         register_target: The name of the variable to register the result of this frecklet.
         vpc_id: ID of the VPC to create the group in.

    """

    FRECKLET_ID = "ec2-security-group-exists"

    def __init__(self, aws_access_key=None, aws_secret_key=None, description=None, group_name=None, region=None, register_target=None, vpc_id=None):

        super(Ec2SecurityGroupExists, self).__init__(var_names=["aws_access_key", "aws_secret_key", "description", "group_name", "region", "register_target", "vpc_id"])
        self._aws_access_key = aws_access_key
        self._aws_secret_key = aws_secret_key
        self._description = description
        self._group_name = group_name
        self._region = region
        self._register_target = register_target
        self._vpc_id = vpc_id

    @property
    def aws_access_key(self):
        return self._aws_access_key

    @aws_access_key.setter
    def aws_access_key(self, aws_access_key):
        self._aws_access_key = aws_access_key

    @property
    def aws_secret_key(self):
        return self._aws_secret_key

    @aws_secret_key.setter
    def aws_secret_key(self, aws_secret_key):
        self._aws_secret_key = aws_secret_key

    @property
    def description(self):
        return self._description

    @description.setter
    def description(self, description):
        self._description = description

    @property
    def group_name(self):
        return self._group_name

    @group_name.setter
    def group_name(self, group_name):
        self._group_name = group_name

    @property
    def region(self):
        return self._region

    @region.setter
    def region(self, region):
        self._region = region

    @property
    def register_target(self):
        return self._register_target

    @register_target.setter
    def register_target(self, register_target):
        self._register_target = register_target

    @property
    def vpc_id(self):
        return self._vpc_id

    @vpc_id.setter
    def vpc_id(self, vpc_id):
        self._vpc_id = vpc_id



frecklet_class = Ec2SecurityGroupExists