Modifying a Subnet Attribute

You can modify an attribute of a Subnet.

You can specify whether a public IP is assigned to the network interfaces created in the Subnet, including the network interfaces created with a virtual machine (VM) in a Subnet.

Updating a Subnet Using OSC CLI

The UpdateSubnet command modifies the specified attribute of a Subnet.

Request sample
$ osc-cli api UpdateSubnet --profile "default" \
    --SubnetId "subnet-12345678" \
    --MapPublicIpOnLaunch True

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.

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

  • SubnetId: The ID of the Subnet.

The UpdateSubnet command returns the following elements:

  • ResponseContext: Information about the context of the response.

    • RequestId: The ID of the request.

  • Subnet: Information about the Subnet.

    • 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
{
  "Subnet": {
    "Tags": [],
    "SubregionName": "eu-west-2a",
    "SubnetId": "subnet-12345678",
    "AvailableIpsCount": 16379,
    "IpRange": "10.0.0.0/18",
    "MapPublicIpOnLaunch": true,
    "State": "available",
    "NetId": "vpc-12345678"
  },
  "ResponseContext": {
    "RequestId": "0475ca1e-d0c5-441d-712a-da55a4175157"
  }
}

Modifying a Subnet Attribute Using AWS CLI

To modify a subnet attribute, use the modify-subnet-attribute command following this syntax:

Request sample
$ aws ec2 modify-subnet-attribute \
    --profile YOUR_PROFILE \
    --subnet-id subnet-12ab34cd \
    --map-public-ip-on-launch \
    --endpoint https://fcu.eu-west-2.outscale.com

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

  • (optional) profile: The named profile you want to use, created when configuring AWS CLI. For more information, see Installing and Configuring AWS CLI.

  • subnet-id: The ID of the subnet whose attribute you want to modify.

  • (optional) map-public-ip-on-launch | no-map-public-ip-on-launch: If set to map-public-ip-on-launch, a public IP is automatically assigned to the instance launched with this subnet. The public IP remains assigned to the instance, even when it is stopped, and is released when the instance is terminated.
    If set to no-map-public-ip-on-launch, no public IP is assigned.

  • endpoint: The endpoint corresponding to the Region you want to send the request to.

The specified attribute is modified.

Related Pages

Corresponding API Methods

AWS™ and Amazon Web Services™ are trademarks of Amazon Technologies, Inc or its affiliates in the United States and/or other countries.