Use ModifyVpcAttribute with an Amazon SDK or CLI - Amazon Elastic Compute Cloud
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China (PDF).

Use ModifyVpcAttribute with an Amazon SDK or CLI

The following code examples show how to use ModifyVpcAttribute.

CLI
Amazon CLI

To modify the enableDnsSupport attribute

This example modifies the enableDnsSupport attribute. This attribute indicates whether DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS server resolves DNS hostnames for your instances to their corresponding IP addresses; otherwise, it does not. If the command succeeds, no output is returned.

Command:

aws ec2 modify-vpc-attribute --vpc-id vpc-a01106c2 --enable-dns-support "{\"Value\":false}"

To modify the enableDnsHostnames attribute

This example modifies the enableDnsHostnames attribute. This attribute indicates whether instances launched in the VPC get DNS hostnames. If this attribute is true, instances in the VPC get DNS hostnames; otherwise, they do not. If the command succeeds, no output is returned.

Command:

aws ec2 modify-vpc-attribute --vpc-id vpc-a01106c2 --enable-dns-hostnames "{\"Value\":false}"
PowerShell
Tools for PowerShell

Example 1: This example enables support for DNS hostnames for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $true

Example 2: This example disables support for DNS hostnames for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $false

Example 3: This example enables support for DNS resolution for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $true

Example 4: This example disables support for DNS resolution for the specified VPC.

Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $false
  • For API details, see ModifyVpcAttribute in Amazon Tools for PowerShell Cmdlet Reference.

For a complete list of Amazon SDK developer guides and code examples, see Create Amazon EC2 resources using an Amazon SDK. This topic also includes information about getting started and details about previous SDK versions.