Skip to content

Commit

Permalink
Merge pull request #124 from GomathiselviS/fix_ec2_networking
Browse files Browse the repository at this point in the history
Add module_defaults to ec2_networking_resources role
  • Loading branch information
GomathiselviS authored Nov 22, 2024
2 parents c6d1a7c + bef455c commit 829bcf0
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions roles/ec2_networking_resources/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,25 +1,29 @@
---
- name: Create VPC
amazon.aws.ec2_vpc_net:
name: "{{ ec2_networking_resources_vpc_name }}"
cidr_block: "{{ ec2_networking_resources_vpc_cidr_block }}"
register: ec2_networking_resources_vpc_result
- name: Run ec2_networking_resources role
module_defaults:
group/aws: "{{ aws_setup_credentials__output }}"
block:
- name: Create VPC
amazon.aws.ec2_vpc_net:
name: "{{ ec2_networking_resources_vpc_name }}"
cidr_block: "{{ ec2_networking_resources_vpc_cidr_block }}"
register: ec2_networking_resources_vpc_result

- name: Create VPC subnet
amazon.aws.ec2_vpc_subnet:
vpc_id: "{{ ec2_networking_resources_vpc_result.vpc.id }}"
cidr: "{{ ec2_networking_resources_subnet_cidr_block }}"
register: ec2_networking_resources_subnet_result
- name: Create VPC subnet
amazon.aws.ec2_vpc_subnet:
vpc_id: "{{ ec2_networking_resources_vpc_result.vpc.id }}"
cidr: "{{ ec2_networking_resources_subnet_cidr_block }}"
register: ec2_networking_resources_subnet_result

- name: Create route table
amazon.aws.ec2_vpc_route_table:
vpc_id: "{{ ec2_networking_resources_vpc_result.vpc.id }}"
subnets:
- "{{ ec2_networking_resources_subnet_result.subnet.id }}"
- name: Create route table
amazon.aws.ec2_vpc_route_table:
vpc_id: "{{ ec2_networking_resources_vpc_result.vpc.id }}"
subnets:
- "{{ ec2_networking_resources_subnet_result.subnet.id }}"

- name: Create security group for internal access
amazon.aws.ec2_security_group:
vpc_id: "{{ ec2_networking_resources_vpc_result.vpc.id }}"
name: "{{ ec2_networking_resources_sg_internal_name }}"
description: "{{ ec2_networking_resources_sg_internal_description }}"
rules: "{{ ec2_networking_resources_sg_internal_rules }}"
- name: Create security group for internal access
amazon.aws.ec2_security_group:
vpc_id: "{{ ec2_networking_resources_vpc_result.vpc.id }}"
name: "{{ ec2_networking_resources_sg_internal_name }}"
description: "{{ ec2_networking_resources_sg_internal_description }}"
rules: "{{ ec2_networking_resources_sg_internal_rules }}"

0 comments on commit 829bcf0

Please sign in to comment.