Menu
Amazon Elastic Compute Cloud
API Reference (API Version 2016-11-15)

ModifySubnetAttribute

Modifies a subnet attribute. You can only modify one attribute at a time.

Request Parameters

The following parameters are for this specific action. For more information about required and optional parameters that are common to all actions, see Common Query Parameters.

AssignIpv6AddressOnCreation

Specify true to indicate that network interfaces created in the specified subnet should be assigned an IPv6 address. This includes a network interface that's created when launching an instance into the subnet (the instance therefore receives an IPv6 address).

If you enable the IPv6 addressing feature for your subnet, your network interface or instance only receives an IPv6 address if it's created using version 2016-11-15 or later of the Amazon EC2 API.

Type: AttributeBooleanValue object

Required: No

MapPublicIpOnLaunch

Specify true to indicate that network interfaces created in the specified subnet should be assigned a public IPv4 address. This includes a network interface that's created when launching an instance into the subnet (the instance therefore receives a public IPv4 address).

Type: AttributeBooleanValue object

Required: No

SubnetId

The ID of the subnet.

Type: String

Required: Yes

Response Elements

The following elements are returned by the service.

requestId

The ID of the request.

Type: String

return

Is true if the request succeeds, and an error otherwise.

Type: Boolean

Errors

For information about the errors that are common to all actions, see Common Client Errors.

Examples

Example 1

This example modifies the attribute for subnet-1a2b3c4d to specify that all instances launched into this subnet are assigned a public IPv4 address.

Sample Request

https://ec2.amazonaws.com/?Action=ModifySubnetAttribute
&SubnetId=subnet-1a2b3c4d
&MapPublicIpOnLaunch.Value=true
&AUTHPARAMS

Sample Response

<ModifySubnetAttributeResponse xmlns="http://ec2.amazonaws.com/doc/2016-11-15/">
    <requestId>c500a0bc-ad14-46c2-b9c5-e24aexample</requestId>
    <return>true</return>
</ModifySubnetAttributeResponse>

Example 2

This example modifies the attribute for subnet-1a2b3c4d to specify that all network interfaces created in this subnet (and therefore all instances launched into this subnet with a new network interface) are assigned an IPv6 address.

Sample Request

https://ec2.amazonaws.com/?Action=ModifySubnetAttribute
&SubnetId=subnet-1a2b3c4d
&AssignIpv6AddressOnCreation.Value=true
&AUTHPARAMS

See Also

For more information about using this API in one of the language-specific AWS SDKs, see the following: