Skip to content

Commit

Permalink
Migrate ec2_instance modules
Browse files Browse the repository at this point in the history
Moves ec2_instance and ec2_instance_info from community.aws to amazon.aws
via git patch.
  • Loading branch information
jillr committed May 7, 2021
1 parent f9c07d4 commit 18679c7
Show file tree
Hide file tree
Showing 9 changed files with 29 additions and 22 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/migrate_ec2_instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
major_changes:
- ec2_instance - The module has been migrated from the ``community.aws`` collection. Playbooks using the Fully Qualified Collection Name for this module should be updated to use ``amazon.aws.ec2_instance``.
- ec2_instance_info - The module has been migrated from the ``community.aws`` collection. Playbooks using the Fully Qualified Collection Name for this module should be updated to use ``amazon.aws.ec2_instance_info``.
2 changes: 2 additions & 0 deletions meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ action_groups:
- ec2_eni_info
- ec2_group
- ec2_group_info
- ec2_instance
- ec2_instance_info
- ec2_key
- ec2_snapshot
- ec2_snapshot_info
Expand Down
18 changes: 9 additions & 9 deletions plugins/modules/ec2_instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@
vpc_subnet_id:
description:
- The subnet ID in which to launch the instance (VPC)
If none is provided, M(community.aws.ec2_instance) will chose the default zone of the default VPC.
If none is provided, M(amazon.aws.ec2_instance) will chose the default zone of the default VPC.
aliases: ['subnet_id']
type: str
network:
Expand Down Expand Up @@ -287,19 +287,19 @@
# Note: These examples do not set authentication details, see the AWS Guide for details.
- name: Terminate every running instance in a region. Use with EXTREME caution.
community.aws.ec2_instance:
amazon.aws.ec2_instance:
state: absent
filters:
instance-state-name: running
- name: restart a particular instance by its ID
community.aws.ec2_instance:
amazon.aws.ec2_instance:
state: restarted
instance_ids:
- i-12345678
- name: start an instance with a public IP address
community.aws.ec2_instance:
amazon.aws.ec2_instance:
name: "public-compute-instance"
key_name: "prod-ssh-key"
vpc_subnet_id: subnet-5ca1ab1e
Expand All @@ -312,7 +312,7 @@
Environment: Testing
- name: start an instance and Add EBS
community.aws.ec2_instance:
amazon.aws.ec2_instance:
name: "public-withebs-instance"
vpc_subnet_id: subnet-5ca1ab1e
instance_type: t2.micro
Expand All @@ -325,7 +325,7 @@
delete_on_termination: true
- name: start an instance with a cpu_options
community.aws.ec2_instance:
amazon.aws.ec2_instance:
name: "public-cpuoption-instance"
vpc_subnet_id: subnet-5ca1ab1e
tags:
Expand All @@ -340,7 +340,7 @@
threads_per_core: 1
- name: start an instance and have it begin a Tower callback on boot
community.aws.ec2_instance:
amazon.aws.ec2_instance:
name: "tower-callback-test"
key_name: "prod-ssh-key"
vpc_subnet_id: subnet-5ca1ab1e
Expand All @@ -358,7 +358,7 @@
SomeThing: "A value"
- name: start an instance with ENI (An existing ENI ID is required)
community.aws.ec2_instance:
amazon.aws.ec2_instance:
name: "public-eni-instance"
key_name: "prod-ssh-key"
vpc_subnet_id: subnet-5ca1ab1e
Expand All @@ -375,7 +375,7 @@
image_id: ami-123456
- name: add second ENI interface
community.aws.ec2_instance:
amazon.aws.ec2_instance:
name: "public-eni-instance"
network:
interfaces:
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/ec2_instance_facts.py
14 changes: 7 additions & 7 deletions plugins/modules/ec2_instance_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,30 @@
# Note: These examples do not set authentication details, see the AWS Guide for details.
- name: Gather information about all instances
community.aws.ec2_instance_info:
amazon.aws.ec2_instance_info:
- name: Gather information about all instances in AZ ap-southeast-2a
community.aws.ec2_instance_info:
amazon.aws.ec2_instance_info:
filters:
availability-zone: ap-southeast-2a
- name: Gather information about a particular instance using ID
community.aws.ec2_instance_info:
amazon.aws.ec2_instance_info:
instance_ids:
- i-12345678
- name: Gather information about any instance with a tag key Name and value Example
community.aws.ec2_instance_info:
amazon.aws.ec2_instance_info:
filters:
"tag:Name": Example
- name: Gather information about any instance in states "shutting-down", "stopping", "stopped"
community.aws.ec2_instance_info:
amazon.aws.ec2_instance_info:
filters:
instance-state-name: [ "shutting-down", "stopping", "stopped" ]
- name: Gather information about any instance with Name beginning with RHEL and an uptime of at least 60 minutes
community.aws.ec2_instance_info:
amazon.aws.ec2_instance_info:
region: "{{ ec2_region }}"
uptime: 60
filters:
Expand Down Expand Up @@ -577,7 +577,7 @@ def main():
supports_check_mode=True,
)
if module._name == 'ec2_instance_facts':
module.deprecate("The 'ec2_instance_facts' module has been renamed to 'ec2_instance_info'", date='2021-12-01', collection_name='community.aws')
module.deprecate("The 'ec2_instance_facts' module has been renamed to 'ec2_instance_info'", date='2021-12-01', collection_name='amazon.aws')

try:
connection = module.client('ec2')
Expand Down
2 changes: 0 additions & 2 deletions tests/integration/targets/ec2_instance/aliases
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
cloud/aws
shippable/aws/group3

ec2_instance_info
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ subnet_a_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.32.0/24'
subnet_a_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.32.'
subnet_b_cidr: '10.{{ 256 | random(seed=vpc_seed) }}.33.0/24'
subnet_b_startswith: '10.{{ 256 | random(seed=vpc_seed) }}.33.'
first_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy"
second_iam_role: "ansible-test-sts-{{ resource_prefix | hash('md5') }}-test-policy-2"
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
- name: "Create IAM role for test"
iam_role:
state: present
name: "ansible-test-sts-{{ resource_prefix }}-test-policy"
name: '{{ first_iam_role }}'
assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}"
create_instance_profile: yes
managed_policy:
Expand All @@ -12,7 +12,7 @@
- name: "Create second IAM role for test"
iam_role:
state: present
name: "ansible-test-sts-{{ resource_prefix }}-test-policy-2"
name: '{{ second_iam_role }}'
assume_role_policy_document: "{{ lookup('file','assume-role-policy.json') }}"
create_instance_profile: yes
managed_policy:
Expand Down Expand Up @@ -119,8 +119,8 @@
managed_policy:
- AmazonEC2ContainerServiceRole
loop:
- "ansible-test-sts-{{ resource_prefix }}-test-policy"
- "ansible-test-sts-{{ resource_prefix }}-test-policy-2"
- '{{ first_iam_role }}'
- '{{ second_iam_role }}'
register: removed
until: removed is not failed
ignore_errors: yes
Expand Down
1 change: 1 addition & 0 deletions tests/sanity/ignore-2.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ plugins/modules/ec2_vpc_subnet_info.py pylint:ansible-deprecated-no-version # W
plugins/module_utils/compat/_ipaddress.py no-assert # Vendored library
plugins/module_utils/compat/_ipaddress.py no-unicode-literals # Vendored library
plugins/module_utils/ec2.py pylint:ansible-deprecated-no-version # We use dates for deprecations, Ansible 2.9 only supports this for compatability
plugins/modules/ec2_instance_info.py pylint:ansible-deprecated-no-version # We use dates for deprecations, Ansible 2.9 only supports this for compatability

0 comments on commit 18679c7

Please sign in to comment.