There are more AWS SDK examples available in the AWS Doc SDK Examples
Use ModifyVpcAttribute with a CLI
The following code examples show how to use ModifyVpcAttribute.
Action examples are code excerpts from larger programs and must be run in context. You can see this action in context in the following code examples:
- CLI
-
- AWS CLI
-
Example 1: To modify the enableDnsSupport attribute
The following
modify-vpc-attributeexample modifies theenableDnsSupportattribute. This attribute indicates whether DNS resolution is enabled for the VPC. If this attribute istrue, the Amazon DNS server resolves DNS hostnames for your instances to their corresponding IP addresses; otherwise, it does not.aws ec2 modify-vpc-attribute \ --vpc-idvpc-a01106c2\ --enable-dns-support "{\"Value\":false}"This command produces no output.
For more information, see View and update DNS attributes for your VPC in the Amazon VPC User Guide.
Example 2: To modify the enableDnsHostnames attribute
The following
modify-vpc-attributeexample modifies theenableDnsHostnamesattribute. This attribute indicates whether instances launched in the VPC get DNS hostnames. If this attribute istrue, instances in the VPC get DNS hostnames; otherwise, they do not.aws ec2 modify-vpc-attribute \ --vpc-idvpc-a01106c2\ --enable-dns-hostnames "{\"Value\":false}"This command produces no output.
For more information, see View and update DNS attributes for your VPC in the Amazon VPC User Guide.
-
For API details, see ModifyVpcAttribute
in AWS CLI Command Reference.
-
- PowerShell
-
- Tools for PowerShell V4
-
Example 1: This example enables support for DNS hostnames for the specified VPC.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $trueExample 2: This example disables support for DNS hostnames for the specified VPC.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $falseExample 3: This example enables support for DNS resolution for the specified VPC.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $trueExample 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 AWS Tools for PowerShell Cmdlet Reference (V4).
-
- Tools for PowerShell V5
-
Example 1: This example enables support for DNS hostnames for the specified VPC.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $trueExample 2: This example disables support for DNS hostnames for the specified VPC.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsHostnames $falseExample 3: This example enables support for DNS resolution for the specified VPC.
Edit-EC2VpcAttribute -VpcId vpc-12345678 -EnableDnsSupport $trueExample 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 AWS Tools for PowerShell Cmdlet Reference (V5).
-