Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Add experience for creating necessary network configurations needed to create an EC2 instance #122

Closed
wants to merge 17 commits into from
Closed
2 changes: 2 additions & 0 deletions changelogs/fragments/add_configure_ec2_experience.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- Add experience for creating AWS EC2 instance with all the necessary network configurations.
Empty file.
2 changes: 2 additions & 0 deletions extensions/patterns/configure_aws_network/group_vars/all.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
organization: Default
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
---
- name: Create necessary network resources
hosts: localhost
gather_facts: false
tasks:
- name: Get list of internal sg rules
ansible.builtin.set_fact:
sg_rules: "{{ security_group_rules | split(';') | list }}"

- name: Set default value for the security group rules if nothing is passed.
ansible.builtin.set_fact:
sg_internal_rules: "{{ sg_rules | default([

Check warning on line 12 in extensions/patterns/configure_aws_network/playbooks/run_configure_aws_network.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

jinja[spacing]

Jinja2 spacing could be improved: {{ sg_rules | default([ {'proto': 'tcp', 'port': '22', 'cidr_ip': vpc_cidr} ]) }} -> {{ sg_rules | default([{'proto': 'tcp', 'port': '22', 'cidr_ip': vpc_cidr}]) }}
{'proto': 'tcp', 'port': '22', 'cidr_ip': vpc_cidr}
]) }}"

- name: Configure Network resources
ansible.builtin.include_role:
name: cloud.aws_ops.ec2_networking_resources
vars:
aws_region: "{{ region }}"

Check failure on line 20 in extensions/patterns/configure_aws_network/playbooks/run_configure_aws_network.yaml

View workflow job for this annotation

GitHub Actions / ansible-lint

var-naming[no-role-prefix]

Variables names from within roles should use ec2_networking_resources_ as a prefix. (vars: aws_region)
ec2_networking_resources_vpc_name: "{{ vpc_name }}"
ec2_networking_resources_vpc_cidr_block: "{{ vpc_cidr }}"
ec2_networking_resources_subnet_cidr_block: "{{ subnet }}"
ec2_networking_resources_sg_internal_name: "{{ security_group_internal_name }}"
ec2_networking_resources_sg_internal_description: "{{ security_group_internal_description }}"
ec2_networking_resources_sg_internal_rules: "{{ sg_internal_rules }}"
44 changes: 44 additions & 0 deletions extensions/patterns/configure_aws_network/setup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
# Labels
#
controller_labels:
- name: cloud.aws_ops
organization: "{{ organization }}"
- name: configure_aws_network_pattern
organization: "{{ organization }}"
- name: run_configure_aws_network
organization: "{{ organization }}"

# Projects
#
controller_projects:
- name: AWS Operations / Configure AWS Network Pattern Project
organization: "{{ organization }}"
scm_branch: experience
scm_clean: 'no'
scm_delete_on_update: 'no'
scm_type: git
scm_update_on_launch: 'no'
scm_url: https://github.com/GomathiselviS/cloud.aws_ops.git


# Job Templates
#
controller_templates:
- name: AWS Operations / Configure AWS Network for EC2
ask_inventory_on_launch: true
ask_execution_environment_on_launch: true
ask_credential_on_launch: true
ask_verbosity_on_launch: true
description: This job template creates the necessary network infrastructure needed to configure AWS EC2 instance
project: AWS Operations / Configure AWS Network Pattern Project
playbook: extensions/patterns/configure_aws_network/playbooks/run_configure_aws_network.yaml
job_type: "run"
organization: "{{ organization }}"
labels:
- cloud.aws_ops
- configure_aws_network_pattern
- run_configure_aws_network
credentials: aws-instance
survey_enabled: true
survey_spec: "{{ lookup('file', pattern.path.replace('setup.yml', '') + 'template_surveys/configure_aws_network.yml') | from_yaml }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
name: "AWS Network Configuration Survey"
description: "Survey to configure aws network Rresources to create an EC2 instance"
spec:
- type: "text"
question_name: "AWS region"
question_description: "The AWS region where the resources should be created."
variable: "region"
required: true

- type: "text"
question_name: "VPC name"
question_description: "The name of the VPC to create."
variable: "vpc_name"
required: true

- type: "text"
question_name: "VPC CIDR block"
question_description: "The CIDR block to use for the VPC being created."
variable: "vpc_cidr"
required: true

- type: "text"
question_name: "Subnet CIDR block"
question_description: "The CIDR block to use for subnet being created."
variable: "subnet"
required: true

- type: "text"
question_name: "Internal Security Group name"
question_description: "The name of the security group to create."
variable: "security_group_internal_name"
required: true

- type: "text"
question_name: "Internal Security Group description"
question_description: "The name of the security group to create."
variable: "security_group_internal_description"
required: true

- type: "text"
question_name: "Dict of Internal Security Group rules, seperated by semi colon"
question_description: 'Dictionaries of Security Group Rules. e.g. {"proto": "tcp", "ports": "22", "cidr_ip": "10.1.1.0/16"}; {"proto": "tcp", "ports": "8000-8010", "cidr_ip": "10.1.1.0/16"}'
variable: "security_group_rules"
required: false
Loading