steampunk / steampunk.aws / 0.9.0 / module / ec2_network_interface Manage EC2 Elastic Network Interfaces Authors: Manca Bizjak (@mancabizjak), Aljaz Kosir (@aljazkosir), Saso Stanovnik (@sstanovnik), Miha Dolinar (@mdolinar), Tadej Borovsak (@tadeboro) preview | supported by XLAB Steampunksteampunk.aws.ec2_network_interface (0.9.0) — module
Install with ansible-galaxy collection install steampunk.aws:==0.9.0
collections: - name: steampunk.aws version: 0.9.0
Create, update or delete an AWS EC2 Elastic Network Interface.
- name: Create a network interface in the default security group with an IP chosen by AWS ec2_network_interface: name: my-first-eni subnet: subnet-de593ab state: detached
- name: Create another network interface with custom settings and security groups ec2_network_interface: name: my-complicated-eni subnet: subnet-5ace7221 ip: 192.0.2.158 source_dest_check: false security_groups: - sg-06aa1300c4efeb57 - sg-0b6f07cf42aasbde state: detached
- name: Create a network interface and attach it to an instance ec2_network_interface: name: my-attached-eni subnet: subnet-5afe1227 ip: 198.51.100.85 attachment: instance: i-18fg46a2dsd device_index: 5 keep_on_termination: false register: attached_interface
- name: Detach a network interface from the instance ec2_network_interface: id: "{{ attached_interface.object.id }}" state: detached
- name: Modify a network interface's security groups ec2_network_interface: id: "{{ attached_interface.object.id }}" clear_security_groups: true security_groups: - sg-293474das3 state: detached
- name: Remove a network interface ec2_network_interface: id: "{{ attached_interface.object.id }}" state: absent
id: description: - ID of the resource to perform the task on. - If specified, this parameter is used to identify the resource. - If omitted, a combination of I(subnet), I(ip), I(name), I(attachment.instance), I(attachment.device_index) is used to identify an existing instance, if possible. type: str ip: description: - The primary private IPv4 addresses for the network interface. - If provided, must be within the IP range of I(subnet). - When I(id) is not present, it is used in combination with I(subnet) to attempt to identify the network interface. - If this parameter is omitted, the private IPv4 address will be selected by AWS from the pool of available private IPv4 addresses from the subnet specified by the I(subnet) parameter. type: str auth: description: - Parameters for authenticating with the AWS service. Each of them may be defined via environment variables. suboptions: access_key: description: - The AWS access key ID. If not set, the value of the AWS_ACCESS_KEY environment variable will be checked. - Mutually exclusive with I(profile). required: false type: str profile: description: - The name of the AWS profile configured with C(aws configure). - Can be used instead of explicitly specifying your access credentials and region. - Use C(default) to use the default profile. - Mutually exclusive with I(access_key) and I(secret_key). required: false type: str region: description: - The name of the AWS region. - If not set, the value of the AWS_REGION environment variable will be checked. - If you set a I(profile) that specifies a default region, that region is used and you can omit this parameter. Use this parameter to override the profile's default region. type: str secret_key: description: - The AWS secret access key. If not set, the value of the AWS_SECRET_KEY environment variable will be checked. - Mutually exclusive with I(profile). required: false type: str url: description: - The URL to the AWS service related to the resource. By default, this is automatically determined through the region parameter. - If not set explicitly, the value of the AWS_<SERVICE>_URL environment variable will be used. - The services currently supported are EC2 and S3. required: false type: str type: dict name: description: - The name tag of the network interface. - Required for the creation of the network interface. type: str tags: description: - Metadata for the AWS resource as key/value pairs. - Keys and values are case-sensitive. type: dict type: choices: - normal - efa default: normal description: - Type of the network interface. - Set this parameter to C(efa) to create an Elastic Fabric Adapter instead of a regular network interface. type: str state: choices: - attached - detached - absent default: attached description: - The desired state of the network interface. type: str subnet: description: - The ID of the subnet in which to create the network interface. - Required when creating the network interface. - When I(id) is not present, it is used in combination with I(ip) to attempt to identify the network interface. type: str attachment: description: - The configuration for an attachment of the network interface to an instance. - Required if I(state) is C(attached) and we're creating the network interface or attaching a previously detached one. suboptions: device_index: description: - Attach the network interface to the instance at this index. - If this parameter is omitted, the first available device index is used. type: int instance: description: - The ID of the instance to attach the network interface to. required: true type: str keep_on_termination: description: - Whether the network interface should be present after the instance it is attached to is terminated. type: bool type: dict clear_tags: default: false description: - Whether to clear any existing tags on the resource that are not explicitly stated in I(tags). - By default, existing tags are kept on the resource. - When this parameter is set to C(true), any pre-existing tags on the resource (including the name tag) are removed. To clear all tags except the name tag, make sure to provide the I(name) parameter. type: bool description: description: - An optional description of the network interface. type: str security_groups: description: - List of security group IDs to attach the network interface to. - Security groups must reside in the same VPC as I(subnet). - If the parameter is provided, at least one security group must be specified. - Required if I(clear_security_groups) is C(true). - If this parameter is omitted, the module will assume the default security group of the VPC in which the network interface exists. elements: str type: list source_dest_check: description: - Whether to enable or disable source/destination checking for the network interface. - This must be set to C(false) for interfaces used for NAT. type: bool clear_security_groups: default: false description: - Whether security groups not listed in I(security_groups) should be removed from the network interface. - This parameter requires I(security_groups). type: bool
object: contains: attachment: contains: device_index: description: The hardware device index the network interface is attached to. returned: always type: str instance: description: The ID of the instance the network interface is attached to. returned: always type: str keep_on_termination: description: Whether the network interface is preserved when terminating the instance. returned: always type: str description: The attachment to an instance, if any. returned: when I(state=attached) type: dict description: description: The description of the network interface, if any. returned: always type: str id: description: The ID of the network interface returned: always type: str ip: description: The primary private IPv4 address assigned to this network interface. returned: always type: str mac_address: description: The MAC address of this network interface. returned: always type: str public_ip: description: The public IPv4 address or the VPC address (Elastic IP) associated with this network interface, if any. returned: always type: str security_groups: description: The IDs of security groups assigned to this network interface. At least one. elements: str returned: always type: list source_dest_check: description: Whether source-destination checking is enabled for this network interface. returned: always type: bool subnet: description: The ID of the subnet this network interface is assigned to. returned: always type: str tags: description: The tags assigned to this network interface. returned: always type: dict type: description: The type of this network interface. returned: always type: str description: - A representation of the EC2 network interface. returned: success sample: object: attachment: device_index: 0 instance: i-b856a2857fadfa keep_on_termination: false description: My First Elastic Network Interface. id: eni-ba546d69 ip: 192.0.2.58 mac_address: 00:05:B0:E9:E7:D0 public_ip: null security_groups: - sg-1 source_dest_check: true subnet: subnet-faff387 tags: Name: myfirsteni type: normal type: dict