ec2_instance metadata_options are not updated
adpavlov opened this issue · comments
adpavlov commented
Summary
Trying to update metadata_options. on existing instances
Issue Type
Bug Report
Component Name
ec2_instance
Ansible Version
$ ansible --version
ansible [core 2.15.2]
Collection Versions
$ ansible-galaxy collection list
amazon.aws 7.0.0
AWS SDK versions
$ pip show boto boto3 botocore
Name: boto3
Version: 1.28.15
Summary: The AWS SDK for Python
Home-page: https://github.com/boto/boto3
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /home/devops/.local/lib/python3.9/site-packages
Requires: botocore, jmespath, s3transfer
Required-by:
---
Name: botocore
Version: 1.31.15
Summary: Low-level, data-driven core of boto 3.
Home-page: https://github.com/boto/botocore
Author: Amazon Web Services
Author-email:
License: Apache License 2.0
Location: /home/devops/.local/lib/python3.9/site-packages
Requires: jmespath, python-dateutil, urllib3
Required-by: awscli, boto3, s3transfer
Configuration
$ ansible-config dump --only-changed
OS / Environment
No response
Steps to Reproduce
- name: Get EC2 instance info
amazon.aws.ec2_instance_info:
access_key: "{{ aws_config.access_key }}"
secret_key: "{{ aws_config.secret_key }}"
session_token: "{{ aws_config.session_token }}"
region: "{{ aws_config.region }}"
register: ec2_instances
- name: Set http_tokens required for AWS instance
amazon.aws.ec2_instance:
access_key: "{{ aws_config.access_key }}"
secret_key: "{{ aws_config.secret_key }}"
session_token: "{{ aws_config.session_token }}"
region: "{{ aws_config.region }}"
instance_ids: "{{ ec2_instances.instances | selectattr('metadata_options.http_tokens', 'search', 'optional') | map(attribute='instance_id') | list }}"
metadata_options:
http_endpoint: enabled
http_tokens: required
http_put_response_hop_limit: 2
Expected Results
metadata_options to be updated, but hop count is still 1 and IMDSv2 still optional
Actual Results
Code of Conduct
- I agree to follow the Ansible Code of Conduct