-
Notifications
You must be signed in to change notification settings - Fork 342
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…1184) [PR #1150/395d4fda backport][stable-5] ec2_instance: fix to handle create instance in specified AZ This is a backport of PR #1150 as merged into main (395d4fd). SUMMARY This PR adds a fix to allow launching an instance in specified AZ when vpc_subnet_id is not specified. The current code does not consider the AZ and launches the instance in default subnet of default vpc for the specified region. https://github.com/ansible-collections/amazon.aws/blob/main/plugins/modules/ec2_instance.py#L1584-L1593 Fixes #1120 ISSUE TYPE Bugfix Pull Request COMPONENT NAME ec2_instance ADDITIONAL INFORMATION Without the fix, the below playbook will launch instance in default subnet ignoring specified AZ. Example Playbook to launch instance in us-west-2b AZ. --- - name: Spin up ec2 instance hosts: localhost gather_facts: false tasks: - name: Launch regular ec2 instances in us-west-1b amazon.aws.ec2_instance: name: "test-instance-us-west-1b" instance_type: t2.micro image_id: ami-xxxxx state: present availability_zone: us-west-1b region: us-west-1 tags: terminate-this: yes network: assign_public_ip: yes register: create_result - ec2_instance_info: instance_ids: - "{{ create_result.instance_ids[0] }}" region: us-west-1 register: info_result - assert: that: info_result.instances[0].placement.availability_zone == 'us-west-1b' Reviewed-by: Mark Chappell <None>
- Loading branch information
1 parent
469b675
commit 96af8b5
Showing
3 changed files
with
219 additions
and
1 deletion.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/1150-ec2_instance-fix-instance-creation-in-az.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
minor_changes: | ||
- ec2_instance - minor fix for launching an instance in specified AZ when `vpc_subnet_id` is not provided (https://github.com/ansible-collections/amazon.aws/pull/1150). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters