Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mandar242 committed Nov 22, 2024
1 parent ec7de80 commit ca18ea3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
10 changes: 5 additions & 5 deletions roles/ec2_instance_create/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,6 @@ The following variables can be set in the role to customize EC2 instance creatio
* **ec2_instance_create_vpc_subnet_id**: (Required)
The ID of the VPC subnet in which the instance will be launched.

* **ec2_instance_create_vpc_id**: (Optional)
The ID of the VPC used for security group and internet gateway.
Required if `ec2_instance_create_associate_external_sg` is `true` or `ec2_instance_create_associate_igw` is `true`.

* **ec2_instance_create_external_sg_id**: (Optional)
The ID or name of the existing security group to be associated with EC2 instance.
Mutually exclusive with `ec2_instance_create_associate_external_sg`.
Expand All @@ -49,12 +45,16 @@ The following variables can be set in the role to customize EC2 instance creatio
A dictionary of tags to assign to the EC2 instance.

* **ec2_instance_create_wait_for_boot**: (Optional)
Whether to wait for the EC2 instance to be in the "running" state before continuing. Default is `true`.
Whether to wait for the EC2 instance to be in the "running" or "terminated" state before continuing. Default is `true`.

### Optional Networking Resources

#### Elastic IP

* **ec2_instance_create_vpc_id**: (Optional)
The ID of the VPC used for security group and internet gateway.
Required if `ec2_instance_create_associate_external_sg` is `true` or `ec2_instance_create_associate_igw` is `true`.

* **ec2_instance_create_associate_eip**: (Optional)
Whether to create an Elastic IP (EIP) and associate it with the EC2 instance. Default is `false`.
If set to `true` and provided VPC doesn't have an Internet Gateway (IGW) attached, please set `ec2_instance_create_associate_igw` to true to avoid failure due to VPC not having IGW attached.
Expand Down
1 change: 1 addition & 0 deletions roles/ec2_instance_create/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
---
ec2_instance_create_operation: create
ec2_instance_create_associate_eip: false
ec2_instance_create_associate_external_sg: false
ec2_instance_create_associate_igw: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Please provide only one to either associate existing or create new sg."
when: ec2_instance_create_external_sg_id is defined and ec2_instance_create_associate_external_sg is defined and ec2_instance_create_external_sg_id != None and ec2_instance_create_associate_external_sg is true

- name: Verify that the instance and security group with same name does not exist
- name: Verify that an instance with same name does not exist
block:
- name: Get instane info with provided name
amazon.aws.ec2_instance_info:
Expand Down Expand Up @@ -56,8 +56,8 @@
block:
- name: Define security group
amazon.aws.ec2_security_group:
name: "{{ ec2_instance_create_external_sg_name | default('ec2_instance_create-default-external-sg') }}"
description: "{{ ec2_instance_create_external_sg_description | default('Security group for external access') }}"
name: "{{ ec2_instance_create_external_sg_name }}"
description: "{{ ec2_instance_create_external_sg_description }}"
vpc_id: "{{ ec2_instance_create_vpc_id }}"
rules: "{{ ec2_instance_create_external_sg_rules }}"
tags: "{{ ec2_instance_create_sg_tags | default(omit) }}"
Expand All @@ -68,7 +68,7 @@
instance_ids:
- "{{ ec2_instance.instance_ids[0] }}"
security_groups:
- "{{ ec2_instance_create_external_sg_name | default('ec2_instance_create-default-external-sg') }}"
- "{{ ec2_instance_create_external_sg_name }}"
vpc_subnet_id: "{{ ec2_instance_create_vpc_subnet_id }}"
register: ec2_instance_associate_external_sg

Expand Down

0 comments on commit ca18ea3

Please sign in to comment.