Obtenir des informations sur vos Subnets

Vous pouvez obtenir des informations à propos d’un ou plusieurs de vos Subnets, comme le Net dans lequel ils sont, leur bloc CIDR ou leur Sous-région.

Des informations sur vos Subnets sont également disponibles depuis les machines virtuelles (VM) elles-mêmes. Pour en savoir plus, voir Accéder aux metadata et user data d’une VM.

Obtenir des informations sur vos Subnets avec Cockpit v2

Voir le dashboard Nets.

Obtenir des informations sur vos Subnets avec OSC CLI

À ce jour, cette section est disponible en anglais uniquement.

The ReadSubnets command lists one or more of your Subnets.
If you do not specify any Subnet ID, this action describes all of your Subnets.

Request sample
$ osc-cli api ReadSubnets --profile "default" \
    --Filters '{
        "NetIds": ["vpc-12345678"]
      }'
Request sample
$ osc-cli api ReadSubnets --profile "default" \
    --Filters '{
        "States": ["available", "pending"],
        "SubregionNames": ["eu-west-2a"]
      }'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • Filters: (optional) One or more filters.

    • AvailableIpsCounts: (optional) The number of available IPs.

    • IpRanges: (optional) The IP ranges in the Subnets, in CIDR notation (for example, 10.0.0.0/16).

    • NetIds: (optional) The IDs of the Nets in which the Subnets are.

    • States: (optional) The states of the Subnets (pending | available | deleted).

    • SubnetIds: (optional) The IDs of the Subnets.

    • SubregionNames: (optional) The names of the Subregions in which the Subnets are located.

    • TagKeys: (optional) The keys of the tags associated with the Subnets.

    • TagValues: (optional) The values of the tags associated with the Subnets.

    • Tags: (optional) The key/value combination of the tags associated with the Subnets, in the following format: "Filters":{"Tags":["TAGKEY=TAGVALUE"]}.

  • NextPageToken: (optional) The token to request the next page of results. Each token refers to a specific page.

  • ResultsPerPage: (optional) The maximum number of logs returned in a single response (between 1 and 1000, both included). By default, 100.

The ReadSubnets command returns the following elements:

  • NextPageToken: The token to request the next page of results. Each token refers to a specific page.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • Subnets: Information about one or more Subnets.

    • AvailableIpsCount: The number of available IPs in the Subnets.

    • IpRange: The IP range in the Subnet, in CIDR notation (for example, 10.0.0.0/16).

    • MapPublicIpOnLaunch: If true, a public IP is assigned to the network interface cards (NICs) created in the specified Subnet.

    • NetId: The ID of the Net in which the Subnet is.

    • State: The state of the Subnet (pending | available | deleted).

    • SubnetId: The ID of the Subnet.

    • SubregionName: The name of the Subregion in which the Subnet is located.

    • Tags: One or more tags associated with the Subnet.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

Result sample
{
  "Subnets": [
    {
      "Tags": [],
      "SubregionName": "eu-west-2a",
      "SubnetId": "subnet-12345678",
      "AvailableIpsCount": 16379,
      "IpRange": "10.0.0.0/18",
      "MapPublicIpOnLaunch": false,
      "State": "available",
      "NetId": "vpc-12345678"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Obtenir des informations sur vos Subnets avec oapi-cli

À ce jour, cette section est disponible en anglais uniquement.

The ReadSubnets command lists one or more of your Subnets.
If you do not specify any Subnet ID, this action describes all of your Subnets.

Request sample
$ oapi-cli --profile "default" ReadSubnets \
    --Filters '{
        "NetIds": ["vpc-12345678"]
      }'
Request sample
$ oapi-cli --profile "default" ReadSubnets \
    --Filters '{
        "States": ["available", "pending"],
        "SubregionNames": ["eu-west-2a"]
      }'

This command contains the following attributes that you need to specify:

  • DryRun: (optional) If true, checks whether you have the required permissions to perform the action.

  • Filters: (optional) One or more filters.

    • AvailableIpsCounts: (optional) The number of available IPs.

    • IpRanges: (optional) The IP ranges in the Subnets, in CIDR notation (for example, 10.0.0.0/16).

    • NetIds: (optional) The IDs of the Nets in which the Subnets are.

    • States: (optional) The states of the Subnets (pending | available | deleted).

    • SubnetIds: (optional) The IDs of the Subnets.

    • SubregionNames: (optional) The names of the Subregions in which the Subnets are located.

    • TagKeys: (optional) The keys of the tags associated with the Subnets.

    • TagValues: (optional) The values of the tags associated with the Subnets.

    • Tags: (optional) The key/value combination of the tags associated with the Subnets, in the following format: "Filters":{"Tags":["TAGKEY=TAGVALUE"]}.

  • NextPageToken: (optional) The token to request the next page of results. Each token refers to a specific page.

  • ResultsPerPage: (optional) The maximum number of logs returned in a single response (between 1 and 1000, both included). By default, 100.

The ReadSubnets command returns the following elements:

  • NextPageToken: The token to request the next page of results. Each token refers to a specific page.

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • Subnets: Information about one or more Subnets.

    • AvailableIpsCount: The number of available IPs in the Subnets.

    • IpRange: The IP range in the Subnet, in CIDR notation (for example, 10.0.0.0/16).

    • MapPublicIpOnLaunch: If true, a public IP is assigned to the network interface cards (NICs) created in the specified Subnet.

    • NetId: The ID of the Net in which the Subnet is.

    • State: The state of the Subnet (pending | available | deleted).

    • SubnetId: The ID of the Subnet.

    • SubregionName: The name of the Subregion in which the Subnet is located.

    • Tags: One or more tags associated with the Subnet.

      • Key: The key of the tag, with a minimum of 1 character.

      • Value: The value of the tag, between 0 and 255 characters.

Result sample
{
  "Subnets": [
    {
      "Tags": [],
      "SubregionName": "eu-west-2a",
      "SubnetId": "subnet-12345678",
      "AvailableIpsCount": 16379,
      "IpRange": "10.0.0.0/18",
      "MapPublicIpOnLaunch": false,
      "State": "available",
      "NetId": "vpc-12345678"
    }
  ],
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Obtenir des informations sur vos subnets avec AWS CLI

Avant de commencer : Installez et configurez AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

Pour obtenir des informations sur un ou plusieurs de vos subnets, utilisez la commande describe-subnets en suivant cette syntaxe :

Exemple de requête
$ aws ec2 describe-subnets \
    --profile YOUR_PROFILE \
    --subnet-ids NOT_SPECIFIED \
    --filters [
               {
                "Name": "vpc-id",
                "Values": "vpc-12345678"
               },
               {
                "Name": "state",
                "Values": "available"
               }
             ] \
    --endpoint https://fcu.eu-west-2.outscale.com

Cette commande contient les attributs suivants que vous devez spécifier :

  • (optionnel) profile : Le profil nommé que vous voulez utiliser, créé pendant la configuration d’AWS CLI. Pour en savoir plus, voir Installer et configurer AWS CLI.

  • (optionnel) subnet-ids : Un ou plusieurs ID de subnets.

    Si vous ne spécifiez aucun ID de subnet, l’ensemble de vos subnets ou tous les subnets correspondant aux filtres que vous avez spécifiés (le cas échéant) sont décrits.

  • (optionnel) filters : Un ou plusieurs filtres, au format "Name=X,Values=Y".

    Vous pouvez spécifier plusieurs valeurs pour un même filtre en utilisant le format "Name=X,Values=Y, Z".

    Les filtres suivants sont disponibles :

    • subnet-id : L’ID du subnet.

    • vpc-id : L’ID du VPC dans lequel est le subnet.

    • state : L’état du subnet. Pour en savoir plus, voir À propos des Nets.

    • cidr : Le bloc CIDR exact du subnet (similaire à cidr-block)

    • cidr-block : Le bloc CIDR exact du subnet (similaire à cidr).

    • available-ip-address-count : Le nombre d’IP disponibles dans le subnet.

    • availability-zone : L’AZ dans laquelle le subnet se trouve.

  • endpoint : Le endpoint correspondant à la Région à laquelle vous voulez envoyer la requête. Pour en savoir plus, voir Installer et configurer AWS CLI.

La commande describe-subnets renvoie les éléments suivants :

  • Subnets : Informations à propos d’un ou plusieurs subnets. Cet élément contient les informations suivantes :

    • VpcId : Le VPC dans lequel est le subnet.

    • CidrBlock : La plage d’IP pour le subnet, en notation CIDR.

    • State : L’état du VPC. Pour en savoir plus, voir À propos des Nets.

    • AvailabilityZone : L’AZ dans laquelle le subnet se trouve.

    • SubnetId : L’ID du subnet.

    • AvailableIpAddressCount : Le nombre d’IP disponibles dans le subnet.

    • MapPublicIpOnLaunch : Indique si une IP est attribuée aux instances lancées dans le subnet.

Exemple de résultat
{
    "Subnets": [
        {
            "VpcId": "vpc-12345678",
            "CidrBlock": "10.0.1.0/24",
            "State": "available",
            "AvailabilityZone": "eu-west-2a",
            "SubnetId": "subnet-1234abcd",
            "AvailableIpAddressCount": 242,
            "MapPublicIpOnLaunch": false
        },
        {
            "VpcId": "vpc-12345678",
            "CidrBlock": "10.0.2.0/24",
            "State": "available",
            "AvailabilityZone": "eu-west-2b",
            "SubnetId": "subnet-4321dcba",
            "AvailableIpAddressCount": 243,
            "MapPublicIpOnLaunch": false
        }
    ]
}

Pages connexes

Méthodes API correspondantes

AWS™ et Amazon Web Services™ sont des marques de commerce d’Amazon Technologies, Inc. ou de ses affiliées aux États-Unis et/ou dans les autres pays.