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

use TagSpecifications to add EC2 instance tags #462

Closed
mszabo opened this issue Feb 22, 2021 · 3 comments
Closed

use TagSpecifications to add EC2 instance tags #462

mszabo opened this issue Feb 22, 2021 · 3 comments
Labels
feature This issue/PR relates to a feature request waiting_on_contributor Needs help. Feel free to engage to get things unblocked

Comments

@mszabo
Copy link

mszabo commented Feb 22, 2021

SUMMARY

The EC2 module currently using ec2.create_tags to add tags to the instance. There is a delay between instance creation and adding of the tags.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

amazon.aws.ec2

ADDITIONAL INFORMATION

It is not uncommon to have a policy in place within an AWS account that you cannot launch instances without certain tags.
Using the TagSpecifications parameter of ec2.run_instances would make sure the tags are applied during the creation of the instance without delay.

https://docs.aws.amazon.com/AWSEC2/latest/APIReference/API_TagSpecification.html

@ansibullbot
Copy link

Files identified in the description:
None

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@gravesm
Copy link
Member

gravesm commented Mar 5, 2021

@mszabo Thank you for the suggestion. We are not adding new features to the ec2 module in this collection because it is a boto2 module. If this were to be added it should be added to the ec2_instance module in the community.aws collection.

@gravesm gravesm transferred this issue from ansible-collections/amazon.aws Mar 5, 2021
@ansibullbot ansibullbot added feature This issue/PR relates to a feature request needs_triage labels Mar 5, 2021
@gravesm gravesm added waiting_on_contributor Needs help. Feel free to engage to get things unblocked and removed needs_triage labels Apr 14, 2021
@tremble
Copy link
Contributor

tremble commented Aug 18, 2021

ec2_instance already uses TagSpecifications when calling run_instances. Since we're deprecating the original ec2 module (ansible-collections/amazon.aws#424) I'm going to close this issue.

@tremble tremble closed this as completed Aug 18, 2021
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this issue May 25, 2022
… default value for instance_type (ansible-collections#587)

ec2_instance: Fix launch template condition, handle launch template - default value for instance_type

SUMMARY

The launch_template option in ec2_instance has a broken condition.
Also the launch_template option defaults the instance_type to t2.micro if not specified and ignores the instance_type specified in the launch_template as said in the issue ansible-collections#451.

Fixes

ansible-collections#451
ansible-collections#462

ISSUE TYPE


Bugfix Pull Request

COMPONENT NAME

ec2_instance
ADDITIONAL INFORMATION

The change does not break existing functionality as tested by the integration test run locally.
Related to the condition fix in community.aws: ansible-collections#111


Ran the following playbook to verify the change.
# create a launch template called "test-launch-template" 
    - name: create test launch template
      community.aws.ec2_launch_template:
        template_name: test-launch-template
        image_id: ami-002068ed284xxxxxx
        instance_type: t3a.small
        network_interfaces:
          - associate_public_ip_address: no
            delete_on_termination: yes
            device_index: 0
            groups:
              - sg-xxxxxxxxxxxxxxxxxx
            subnet_id: subnet-xxxxxxxxxxxxxxxxxx
        region: us-east-2
        block_device_mappings:
          - device_name: /dev/sdb
            ebs:
              volume_size: 5
              volume_type: gp3
              delete_on_termination: true
              encrypted: yes
          - device_name: /dev/sdc
            ebs:
              volume_size: 2
              volume_type: gp2
              delete_on_termination: true
              encrypted: no
        tags:
          ssome: tags

# launch a ec2 instance using launch template created earlier - launches t3a.small instance as expected
    - name: test launch template usage
      ec2_instance:
        wait: yes
        name: "test-instance-mk-t3a.small"
        launch_template:
          name: test-launch-template
        vpc_subnet_id: subnet-xxxxxxxxxxxxxxxxxx

# launch ec2 instance using launch template created earlier - override instance type to be launch to t3.xlarge
    - name: test launch template usage - override instance type
      ec2_instance:
        wait: yes
        name: "test-instance-mk-t3.xlarge"
        instance_type: t3.xlarge
        launch_template:
          name: test-launch-template
        vpc_subnet_id: subnet-xxxxxxxxxxxxxxxxxx

Reviewed-by: Jill R <None>
Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Emanuele Leopardi <None>
Reviewed-by: Alina Buzachis <None>
Reviewed-by: None <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature This issue/PR relates to a feature request waiting_on_contributor Needs help. Feel free to engage to get things unblocked
Projects
None yet
Development

No branches or pull requests

4 participants