subnet#

Exec module for managing EC2 subnets.

async idem_aws.exec.aws.ec2.subnet.get(hub, ctx, name, resource_id: str = None, availability_zone: str = None, availability_zone_id: str = None, cidr_block: str = None, default_for_az: str = None, filters: List = None, ipv6_cidr_block: str = None, status: str = None, vpc_id: str = None, tags: List[Dict[str, Any]] = None) Dict[source]#

Get EC2 subnet from AWS account.

Get a single subnet from AWS. If more than one resource is found, the first resource returned from AWS will be used. The function returns None when no resource is found.

Parameters:
  • name (str) – The name of the Idem state.

  • resource_id (str, Optional) – AWS subnet id to identify the resource.

  • availability_zone (str, Optional) – The Availability Zone for the subnet.

  • availability_zone_id (str, Optional) – The ID of the Availability Zone for the subnet.

  • cidr_block (str, Optional) – The IPv4 CIDR block of the subnet. The CIDR block you specify must exactly match the subnet’s CIDR block for information to be returned for the subnet.

  • default_for_az (str, Optional) – Indicate whether the subnet is the default subnet in the Availability Zone.

  • filters (list, Optional) – One or more filters: for example, tag :<key>, tag-key. A complete list of filters can be found at https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_subnets

  • ipv6_cidr_block (str, Optional) – An IPv6 CIDR block associated with the subnet.

  • status (str, Optional) – The state of the subnet (pending | available ).

  • vpc_id (str, Optional) – The ID of the VPC for the subnet.

  • tags (list or dict, Optional) –

    The list or dict of tags to filter by. For example, to find all resources that have a tag with the key “Owner” and the value “TeamA” , specify “tag:Owner” for the Dict key and “TeamA” for the Dict value.

    • Key (str):

      The key name for the tag to be used to filter by.

    • Value(str):

      The value associated with this tag to filter by.

Returns:

Returns ami in present format

Return type:

Dict[str, Any]

Examples

Calling this exec module function from the cli with filters

idem exec aws.ec2.subnet.get name="my_resource" filters=[{'name': 'name', 'values': ['subnet-name']}]

Using in a state:

my_unmanaged_resource:
  exec.run:
    - path: aws.ec2.subnet.get
    - kwargs:
        name: my_resource
        filters:
            - name: 'name'
              values: ["subnet-name"]
async idem_aws.exec.aws.ec2.subnet.list_(hub, ctx, name: str = None, availability_zone: str = None, availability_zone_id: str = None, cidr_block: str = None, default_for_az: str = None, filters: List = None, ipv6_cidr_block: str = None, status: str = None, vpc_id: str = None, tags: List[Dict[str, Any]] = None) Dict[source]#

List EC2 ami from AWS account.

Fetch a list of subnets AWS. The function returns empty list when no resource is found.

Parameters:
  • name (str, Optional) – The name of the Idem state.

  • availability_zone (str, Optional) – The Availability Zone for the subnet.

  • availability_zone_id (str, Optional) – The ID of the Availability Zone for the subnet.

  • cidr_block (str, Optional) – The IPv4 CIDR block of the subnet. The CIDR block you specify must exactly match the subnet’s CIDR block for information to be returned for the subnet.

  • default_for_az (str, Optional) – Indicate whether the subnet is the default subnet in the Availability Zone.

  • filters (list, Optional) – One or more filters: for example, tag :<key>, tag-key. A complete list of filters can be found at https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/ec2.html#EC2.Client.describe_subnets

  • ipv6_cidr_block (str, Optional) – An IPv6 CIDR block associated with the subnet.

  • status (str, Optional) – The state of the subnet (pending | available ).

  • vpc_id (str, Optional) – The ID of the VPC for the subnet.

  • tags (list or dict, Optional) –

    The list or dict of tags to filter by. For example, to find all resources that have a tag with the key “Owner” and the value “TeamA” , specify “tag:Owner” for the Dict key and “TeamA” for the Dict value.

    • Key (str):

      The key name for the tag to be used to filter by.

    • Value(str):

      The value associated with this tag to filter by.

Returns:

Returns ami in present format

Return type:

Dict[str, Any]

Examples

Calling this exec module function from the cli with vpc_id

idem exec aws.ec2.subnet.list name="my_resources" vpc_id="vpc-a123"

Using in a state:

my_unmanaged_resources:
  exec.run:
    - path: aws.ec2.subnet.list
    - kwargs:
        name: my_resources
        vcp_id: vpc-a123