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

[PR #1150/395d4fda backport][stable-5] ec2_instance: fix to handle create instance in specified AZ #1184

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Oct 19, 2022

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'

ec2_instance: fix to handle create instance in specified AZ

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: Mike Graves <[email protected]>
Reviewed-by: Gonéri Le Bouder <[email protected]>
(cherry picked from commit 395d4fd)
@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Oct 19, 2022
@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review integration tests/integration module module new_contributor Help guide this first time contributor plugins plugin (any type) tests tests labels Oct 19, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 4m 20s
✔️ build-ansible-collection SUCCESS in 4m 58s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 11m 06s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 9m 35s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 29s
✔️ ansible-test-units-amazon-aws-python36 SUCCESS in 6m 49s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 6m 22s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 49s
✔️ cloud-tox-py3 SUCCESS in 3m 40s
✔️ ansible-test-splitter SUCCESS in 2m 55s
✔️ integration-amazon.aws-1 SUCCESS in 47m 43s
✔️ integration-amazon.aws-2 SUCCESS in 30m 05s
✔️ integration-amazon.aws-3 SUCCESS in 29m 10s
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
⚠️ integration-amazon.aws-14 SKIPPED
⚠️ integration-amazon.aws-15 SKIPPED
⚠️ integration-amazon.aws-16 SKIPPED
⚠️ integration-amazon.aws-17 SKIPPED
⚠️ integration-amazon.aws-18 SKIPPED
⚠️ integration-community.aws-1 SKIPPED
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED
⚠️ integration-community.aws-14 SKIPPED
⚠️ integration-community.aws-15 SKIPPED
⚠️ integration-community.aws-16 SKIPPED
⚠️ integration-community.aws-17 SKIPPED
⚠️ integration-community.aws-18 SKIPPED
✔️ ansible-test-changelog SUCCESS in 2m 12s

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 96af8b5 into stable-5 Oct 19, 2022
@softwarefactory-project-zuul softwarefactory-project-zuul bot deleted the patchback/backports/stable-5/395d4fda1ec549020d070d4465835166094e4777/pr-1150 branch October 19, 2022 17:00
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…tions#1184)

ecs_tag/efs_tag - add resource_tags as alias for tags

SUMMARY
Cleanup related to the tagging fragment
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ecs_tag
efs_tag
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…tions#1184)

ecs_tag/efs_tag - add resource_tags as alias for tags

SUMMARY
Cleanup related to the tagging fragment
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ecs_tag
efs_tag
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Chappell <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…tions#1184)

ecs_tag/efs_tag - add resource_tags as alias for tags

SUMMARY
Cleanup related to the tagging fragment
ISSUE TYPE

Feature Pull Request

COMPONENT NAME
ecs_tag
efs_tag
ADDITIONAL INFORMATION

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mark Chappell <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug community_review integration tests/integration mergeit Merge the PR (SoftwareFactory) module module new_contributor Help guide this first time contributor plugins plugin (any type) tests tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants