aws-ec2-subnets
Retrieves a list of AWS EC2 subnets.
Syntax
Options
- profile=STRING
- Optional option. The identifier of AWS connect profile When omitted, every AWS connect profile the user may use is queried.
- region=STRING
- Optional option. AWS region Accepts a comma separated list. When omitted, every client region of the connect profile is queried.
Output fields
| Field | Type | Name | Description |
|---|---|---|---|
| aws_profile | string | Connect profile | The identifier of AWS connect profile |
| region | string | Region | e.g. ap-northeast-2 |
| az | string | Availability Zone | e.g. ap-northeast-2a |
| subnet_id | string | Subnet ID | |
| vpc_id | string | VPC ID | |
| default_az | bool | Default AZ | |
| cidr_block | string | CIDR block | e.g. 192.0.2.0/20 |
| state | string | State | e.g. available, pending |
| available_ip_count | int | Available IP count | e.g. 4087 |
| owner_id | string | Owner ID | |
| assign_ipv6_on_creation | bool | Assign IPv6 on creation | |
| map_public_ip_on_launch | bool | Map public IP on launch | |
| subnet_arn | string | Subnet ARN | |
| ipv6_cidr_block_associations | list | IPv6 CIDR block associations | Elements with assoc_id, ipv6_cidr_block, state, and state_msg properties. |
| tags | list | Tags | Elements with key and value properties. |
Error codes
Parse errors
| Error message | Cause | Resolution |
|---|---|---|
| aws-profile-not-found | No AWS connect profile matches the name given in the profile option. | Check the name on Settings > Connect Profiles and specify it again. |
| no-permission | The account running the query is not granted the connect profile. | Ask an administrator to grant the connect profile. |
| invalid-aws-region | The region option value is not an AWS region name. | Enter an exact AWS region name such as ap-northeast-2. |
| use-one-aws-profile | More than one connect profile was given in the profile option. | Specify a single connect profile. |
Description
Retrieves a list of AWS EC2 subnets.
The following AWS IAM permissions must be allowed to use this command.
- ec2:DescribeSubnets
Without the profile and region options the command queries every client region of every connect profile the user may use, so narrowing the scope with profile and region is recommended in large environments. Each record carries the aws_profile and region fields that tell which profile and region it came from.
Examples
Example: List AWS EC2 Subnets
Situation: A periodic review or an incident investigation needs the result of list aws ec2 subnets.
Expected result:
| aws_profile | region | az | subnet_id |
|---|---|---|---|
| aws-prod | ap-northeast-2 | ap-northeast-2a | example-id-0123 |
Interpretation: One record is one queried item. Use aws_profile and region to tell which account and region it came from, then narrow the columns with fields and either export the result or use it as the lookup stage of a detection rule.
Example: Narrowing to one account and region
Situation: Limit the scope when several connect profiles and regions exist.
Interpretation: Narrowing the scope cuts both the number of AWS API calls and the response time. Scope every scheduled query this way.