github.com/aavshr/aws-sdk-go@v1.41.3/service/ec2/examples_test.go (about)

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package ec2_test
     4  
     5  import (
     6  	"fmt"
     7  	"strings"
     8  	"time"
     9  
    10  	"github.com/aavshr/aws-sdk-go/aws"
    11  	"github.com/aavshr/aws-sdk-go/aws/awserr"
    12  	"github.com/aavshr/aws-sdk-go/aws/session"
    13  	"github.com/aavshr/aws-sdk-go/service/ec2"
    14  )
    15  
    16  var _ time.Duration
    17  var _ strings.Reader
    18  var _ aws.Config
    19  
    20  func parseTime(layout, value string) *time.Time {
    21  	t, err := time.Parse(layout, value)
    22  	if err != nil {
    23  		panic(err)
    24  	}
    25  	return &t
    26  }
    27  
    28  // To allocate an Elastic IP address for EC2-VPC
    29  //
    30  // This example allocates an Elastic IP address to use with an instance in a VPC.
    31  func ExampleEC2_AllocateAddress_shared00() {
    32  	svc := ec2.New(session.New())
    33  	input := &ec2.AllocateAddressInput{
    34  		Domain: aws.String("vpc"),
    35  	}
    36  
    37  	result, err := svc.AllocateAddress(input)
    38  	if err != nil {
    39  		if aerr, ok := err.(awserr.Error); ok {
    40  			switch aerr.Code() {
    41  			default:
    42  				fmt.Println(aerr.Error())
    43  			}
    44  		} else {
    45  			// Print the error, cast err to awserr.Error to get the Code and
    46  			// Message from an error.
    47  			fmt.Println(err.Error())
    48  		}
    49  		return
    50  	}
    51  
    52  	fmt.Println(result)
    53  }
    54  
    55  // To allocate an Elastic IP address for EC2-Classic
    56  //
    57  // This example allocates an Elastic IP address to use with an instance in EC2-Classic.
    58  func ExampleEC2_AllocateAddress_shared01() {
    59  	svc := ec2.New(session.New())
    60  	input := &ec2.AllocateAddressInput{}
    61  
    62  	result, err := svc.AllocateAddress(input)
    63  	if err != nil {
    64  		if aerr, ok := err.(awserr.Error); ok {
    65  			switch aerr.Code() {
    66  			default:
    67  				fmt.Println(aerr.Error())
    68  			}
    69  		} else {
    70  			// Print the error, cast err to awserr.Error to get the Code and
    71  			// Message from an error.
    72  			fmt.Println(err.Error())
    73  		}
    74  		return
    75  	}
    76  
    77  	fmt.Println(result)
    78  }
    79  
    80  // To assign a specific secondary private IP address to an interface
    81  //
    82  // This example assigns the specified secondary private IP address to the specified
    83  // network interface.
    84  func ExampleEC2_AssignPrivateIpAddresses_shared00() {
    85  	svc := ec2.New(session.New())
    86  	input := &ec2.AssignPrivateIpAddressesInput{
    87  		NetworkInterfaceId: aws.String("eni-e5aa89a3"),
    88  		PrivateIpAddresses: []*string{
    89  			aws.String("10.0.0.82"),
    90  		},
    91  	}
    92  
    93  	result, err := svc.AssignPrivateIpAddresses(input)
    94  	if err != nil {
    95  		if aerr, ok := err.(awserr.Error); ok {
    96  			switch aerr.Code() {
    97  			default:
    98  				fmt.Println(aerr.Error())
    99  			}
   100  		} else {
   101  			// Print the error, cast err to awserr.Error to get the Code and
   102  			// Message from an error.
   103  			fmt.Println(err.Error())
   104  		}
   105  		return
   106  	}
   107  
   108  	fmt.Println(result)
   109  }
   110  
   111  // To assign secondary private IP addresses that Amazon EC2 selects to an interface
   112  //
   113  // This example assigns two secondary private IP addresses to the specified network
   114  // interface. Amazon EC2 automatically assigns these IP addresses from the available
   115  // IP addresses in the CIDR block range of the subnet the network interface is associated
   116  // with.
   117  func ExampleEC2_AssignPrivateIpAddresses_shared01() {
   118  	svc := ec2.New(session.New())
   119  	input := &ec2.AssignPrivateIpAddressesInput{
   120  		NetworkInterfaceId:             aws.String("eni-e5aa89a3"),
   121  		SecondaryPrivateIpAddressCount: aws.Int64(2),
   122  	}
   123  
   124  	result, err := svc.AssignPrivateIpAddresses(input)
   125  	if err != nil {
   126  		if aerr, ok := err.(awserr.Error); ok {
   127  			switch aerr.Code() {
   128  			default:
   129  				fmt.Println(aerr.Error())
   130  			}
   131  		} else {
   132  			// Print the error, cast err to awserr.Error to get the Code and
   133  			// Message from an error.
   134  			fmt.Println(err.Error())
   135  		}
   136  		return
   137  	}
   138  
   139  	fmt.Println(result)
   140  }
   141  
   142  // To associate an Elastic IP address in EC2-VPC
   143  //
   144  // This example associates the specified Elastic IP address with the specified instance
   145  // in a VPC.
   146  func ExampleEC2_AssociateAddress_shared00() {
   147  	svc := ec2.New(session.New())
   148  	input := &ec2.AssociateAddressInput{
   149  		AllocationId: aws.String("eipalloc-64d5890a"),
   150  		InstanceId:   aws.String("i-0b263919b6498b123"),
   151  	}
   152  
   153  	result, err := svc.AssociateAddress(input)
   154  	if err != nil {
   155  		if aerr, ok := err.(awserr.Error); ok {
   156  			switch aerr.Code() {
   157  			default:
   158  				fmt.Println(aerr.Error())
   159  			}
   160  		} else {
   161  			// Print the error, cast err to awserr.Error to get the Code and
   162  			// Message from an error.
   163  			fmt.Println(err.Error())
   164  		}
   165  		return
   166  	}
   167  
   168  	fmt.Println(result)
   169  }
   170  
   171  // To associate an Elastic IP address with a network interface
   172  //
   173  // This example associates the specified Elastic IP address with the specified network
   174  // interface.
   175  func ExampleEC2_AssociateAddress_shared01() {
   176  	svc := ec2.New(session.New())
   177  	input := &ec2.AssociateAddressInput{
   178  		AllocationId:       aws.String("eipalloc-64d5890a"),
   179  		NetworkInterfaceId: aws.String("eni-1a2b3c4d"),
   180  	}
   181  
   182  	result, err := svc.AssociateAddress(input)
   183  	if err != nil {
   184  		if aerr, ok := err.(awserr.Error); ok {
   185  			switch aerr.Code() {
   186  			default:
   187  				fmt.Println(aerr.Error())
   188  			}
   189  		} else {
   190  			// Print the error, cast err to awserr.Error to get the Code and
   191  			// Message from an error.
   192  			fmt.Println(err.Error())
   193  		}
   194  		return
   195  	}
   196  
   197  	fmt.Println(result)
   198  }
   199  
   200  // To associate an Elastic IP address in EC2-Classic
   201  //
   202  // This example associates an Elastic IP address with an instance in EC2-Classic.
   203  func ExampleEC2_AssociateAddress_shared02() {
   204  	svc := ec2.New(session.New())
   205  	input := &ec2.AssociateAddressInput{
   206  		InstanceId: aws.String("i-07ffe74c7330ebf53"),
   207  		PublicIp:   aws.String("198.51.100.0"),
   208  	}
   209  
   210  	result, err := svc.AssociateAddress(input)
   211  	if err != nil {
   212  		if aerr, ok := err.(awserr.Error); ok {
   213  			switch aerr.Code() {
   214  			default:
   215  				fmt.Println(aerr.Error())
   216  			}
   217  		} else {
   218  			// Print the error, cast err to awserr.Error to get the Code and
   219  			// Message from an error.
   220  			fmt.Println(err.Error())
   221  		}
   222  		return
   223  	}
   224  
   225  	fmt.Println(result)
   226  }
   227  
   228  // To associate a DHCP options set with a VPC
   229  //
   230  // This example associates the specified DHCP options set with the specified VPC.
   231  func ExampleEC2_AssociateDhcpOptions_shared00() {
   232  	svc := ec2.New(session.New())
   233  	input := &ec2.AssociateDhcpOptionsInput{
   234  		DhcpOptionsId: aws.String("dopt-d9070ebb"),
   235  		VpcId:         aws.String("vpc-a01106c2"),
   236  	}
   237  
   238  	result, err := svc.AssociateDhcpOptions(input)
   239  	if err != nil {
   240  		if aerr, ok := err.(awserr.Error); ok {
   241  			switch aerr.Code() {
   242  			default:
   243  				fmt.Println(aerr.Error())
   244  			}
   245  		} else {
   246  			// Print the error, cast err to awserr.Error to get the Code and
   247  			// Message from an error.
   248  			fmt.Println(err.Error())
   249  		}
   250  		return
   251  	}
   252  
   253  	fmt.Println(result)
   254  }
   255  
   256  // To associate the default DHCP options set with a VPC
   257  //
   258  // This example associates the default DHCP options set with the specified VPC.
   259  func ExampleEC2_AssociateDhcpOptions_shared01() {
   260  	svc := ec2.New(session.New())
   261  	input := &ec2.AssociateDhcpOptionsInput{
   262  		DhcpOptionsId: aws.String("default"),
   263  		VpcId:         aws.String("vpc-a01106c2"),
   264  	}
   265  
   266  	result, err := svc.AssociateDhcpOptions(input)
   267  	if err != nil {
   268  		if aerr, ok := err.(awserr.Error); ok {
   269  			switch aerr.Code() {
   270  			default:
   271  				fmt.Println(aerr.Error())
   272  			}
   273  		} else {
   274  			// Print the error, cast err to awserr.Error to get the Code and
   275  			// Message from an error.
   276  			fmt.Println(err.Error())
   277  		}
   278  		return
   279  	}
   280  
   281  	fmt.Println(result)
   282  }
   283  
   284  // To associate an IAM instance profile with an instance
   285  //
   286  // This example associates an IAM instance profile named admin-role with the specified
   287  // instance.
   288  func ExampleEC2_AssociateIamInstanceProfile_shared00() {
   289  	svc := ec2.New(session.New())
   290  	input := &ec2.AssociateIamInstanceProfileInput{
   291  		IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
   292  			Name: aws.String("admin-role"),
   293  		},
   294  		InstanceId: aws.String("i-123456789abcde123"),
   295  	}
   296  
   297  	result, err := svc.AssociateIamInstanceProfile(input)
   298  	if err != nil {
   299  		if aerr, ok := err.(awserr.Error); ok {
   300  			switch aerr.Code() {
   301  			default:
   302  				fmt.Println(aerr.Error())
   303  			}
   304  		} else {
   305  			// Print the error, cast err to awserr.Error to get the Code and
   306  			// Message from an error.
   307  			fmt.Println(err.Error())
   308  		}
   309  		return
   310  	}
   311  
   312  	fmt.Println(result)
   313  }
   314  
   315  // To associate a route table with a subnet
   316  //
   317  // This example associates the specified route table with the specified subnet.
   318  func ExampleEC2_AssociateRouteTable_shared00() {
   319  	svc := ec2.New(session.New())
   320  	input := &ec2.AssociateRouteTableInput{
   321  		RouteTableId: aws.String("rtb-22574640"),
   322  		SubnetId:     aws.String("subnet-9d4a7b6"),
   323  	}
   324  
   325  	result, err := svc.AssociateRouteTable(input)
   326  	if err != nil {
   327  		if aerr, ok := err.(awserr.Error); ok {
   328  			switch aerr.Code() {
   329  			default:
   330  				fmt.Println(aerr.Error())
   331  			}
   332  		} else {
   333  			// Print the error, cast err to awserr.Error to get the Code and
   334  			// Message from an error.
   335  			fmt.Println(err.Error())
   336  		}
   337  		return
   338  	}
   339  
   340  	fmt.Println(result)
   341  }
   342  
   343  // To attach an Internet gateway to a VPC
   344  //
   345  // This example attaches the specified Internet gateway to the specified VPC.
   346  func ExampleEC2_AttachInternetGateway_shared00() {
   347  	svc := ec2.New(session.New())
   348  	input := &ec2.AttachInternetGatewayInput{
   349  		InternetGatewayId: aws.String("igw-c0a643a9"),
   350  		VpcId:             aws.String("vpc-a01106c2"),
   351  	}
   352  
   353  	result, err := svc.AttachInternetGateway(input)
   354  	if err != nil {
   355  		if aerr, ok := err.(awserr.Error); ok {
   356  			switch aerr.Code() {
   357  			default:
   358  				fmt.Println(aerr.Error())
   359  			}
   360  		} else {
   361  			// Print the error, cast err to awserr.Error to get the Code and
   362  			// Message from an error.
   363  			fmt.Println(err.Error())
   364  		}
   365  		return
   366  	}
   367  
   368  	fmt.Println(result)
   369  }
   370  
   371  // To attach a network interface to an instance
   372  //
   373  // This example attaches the specified network interface to the specified instance.
   374  func ExampleEC2_AttachNetworkInterface_shared00() {
   375  	svc := ec2.New(session.New())
   376  	input := &ec2.AttachNetworkInterfaceInput{
   377  		DeviceIndex:        aws.Int64(1),
   378  		InstanceId:         aws.String("i-1234567890abcdef0"),
   379  		NetworkInterfaceId: aws.String("eni-e5aa89a3"),
   380  	}
   381  
   382  	result, err := svc.AttachNetworkInterface(input)
   383  	if err != nil {
   384  		if aerr, ok := err.(awserr.Error); ok {
   385  			switch aerr.Code() {
   386  			default:
   387  				fmt.Println(aerr.Error())
   388  			}
   389  		} else {
   390  			// Print the error, cast err to awserr.Error to get the Code and
   391  			// Message from an error.
   392  			fmt.Println(err.Error())
   393  		}
   394  		return
   395  	}
   396  
   397  	fmt.Println(result)
   398  }
   399  
   400  // To attach a volume to an instance
   401  //
   402  // This example attaches a volume (``vol-1234567890abcdef0``) to an instance (``i-01474ef662b89480``)
   403  // as ``/dev/sdf``.
   404  func ExampleEC2_AttachVolume_shared00() {
   405  	svc := ec2.New(session.New())
   406  	input := &ec2.AttachVolumeInput{
   407  		Device:     aws.String("/dev/sdf"),
   408  		InstanceId: aws.String("i-01474ef662b89480"),
   409  		VolumeId:   aws.String("vol-1234567890abcdef0"),
   410  	}
   411  
   412  	result, err := svc.AttachVolume(input)
   413  	if err != nil {
   414  		if aerr, ok := err.(awserr.Error); ok {
   415  			switch aerr.Code() {
   416  			default:
   417  				fmt.Println(aerr.Error())
   418  			}
   419  		} else {
   420  			// Print the error, cast err to awserr.Error to get the Code and
   421  			// Message from an error.
   422  			fmt.Println(err.Error())
   423  		}
   424  		return
   425  	}
   426  
   427  	fmt.Println(result)
   428  }
   429  
   430  // To add a rule that allows outbound traffic to a specific address range
   431  //
   432  // This example adds a rule that grants access to the specified address ranges on TCP
   433  // port 80.
   434  func ExampleEC2_AuthorizeSecurityGroupEgress_shared00() {
   435  	svc := ec2.New(session.New())
   436  	input := &ec2.AuthorizeSecurityGroupEgressInput{
   437  		GroupId: aws.String("sg-1a2b3c4d"),
   438  		IpPermissions: []*ec2.IpPermission{
   439  			{
   440  				FromPort:   aws.Int64(80),
   441  				IpProtocol: aws.String("tcp"),
   442  				IpRanges: []*ec2.IpRange{
   443  					{
   444  						CidrIp: aws.String("10.0.0.0/16"),
   445  					},
   446  				},
   447  				ToPort: aws.Int64(80),
   448  			},
   449  		},
   450  	}
   451  
   452  	result, err := svc.AuthorizeSecurityGroupEgress(input)
   453  	if err != nil {
   454  		if aerr, ok := err.(awserr.Error); ok {
   455  			switch aerr.Code() {
   456  			default:
   457  				fmt.Println(aerr.Error())
   458  			}
   459  		} else {
   460  			// Print the error, cast err to awserr.Error to get the Code and
   461  			// Message from an error.
   462  			fmt.Println(err.Error())
   463  		}
   464  		return
   465  	}
   466  
   467  	fmt.Println(result)
   468  }
   469  
   470  // To add a rule that allows outbound traffic to a specific security group
   471  //
   472  // This example adds a rule that grants access to the specified security group on TCP
   473  // port 80.
   474  func ExampleEC2_AuthorizeSecurityGroupEgress_shared01() {
   475  	svc := ec2.New(session.New())
   476  	input := &ec2.AuthorizeSecurityGroupEgressInput{
   477  		GroupId: aws.String("sg-1a2b3c4d"),
   478  		IpPermissions: []*ec2.IpPermission{
   479  			{
   480  				FromPort:   aws.Int64(80),
   481  				IpProtocol: aws.String("tcp"),
   482  				ToPort:     aws.Int64(80),
   483  				UserIdGroupPairs: []*ec2.UserIdGroupPair{
   484  					{
   485  						GroupId: aws.String("sg-4b51a32f"),
   486  					},
   487  				},
   488  			},
   489  		},
   490  	}
   491  
   492  	result, err := svc.AuthorizeSecurityGroupEgress(input)
   493  	if err != nil {
   494  		if aerr, ok := err.(awserr.Error); ok {
   495  			switch aerr.Code() {
   496  			default:
   497  				fmt.Println(aerr.Error())
   498  			}
   499  		} else {
   500  			// Print the error, cast err to awserr.Error to get the Code and
   501  			// Message from an error.
   502  			fmt.Println(err.Error())
   503  		}
   504  		return
   505  	}
   506  
   507  	fmt.Println(result)
   508  }
   509  
   510  // To add a rule that allows inbound SSH traffic from an IPv4 address range
   511  //
   512  // This example enables inbound traffic on TCP port 22 (SSH). The rule includes a description
   513  // to help you identify it later.
   514  func ExampleEC2_AuthorizeSecurityGroupIngress_shared00() {
   515  	svc := ec2.New(session.New())
   516  	input := &ec2.AuthorizeSecurityGroupIngressInput{
   517  		GroupId: aws.String("sg-903004f8"),
   518  		IpPermissions: []*ec2.IpPermission{
   519  			{
   520  				FromPort:   aws.Int64(22),
   521  				IpProtocol: aws.String("tcp"),
   522  				IpRanges: []*ec2.IpRange{
   523  					{
   524  						CidrIp:      aws.String("203.0.113.0/24"),
   525  						Description: aws.String("SSH access from the LA office"),
   526  					},
   527  				},
   528  				ToPort: aws.Int64(22),
   529  			},
   530  		},
   531  	}
   532  
   533  	result, err := svc.AuthorizeSecurityGroupIngress(input)
   534  	if err != nil {
   535  		if aerr, ok := err.(awserr.Error); ok {
   536  			switch aerr.Code() {
   537  			default:
   538  				fmt.Println(aerr.Error())
   539  			}
   540  		} else {
   541  			// Print the error, cast err to awserr.Error to get the Code and
   542  			// Message from an error.
   543  			fmt.Println(err.Error())
   544  		}
   545  		return
   546  	}
   547  
   548  	fmt.Println(result)
   549  }
   550  
   551  // To add a rule that allows inbound HTTP traffic from another security group
   552  //
   553  // This example enables inbound traffic on TCP port 80 from the specified security group.
   554  // The group must be in the same VPC or a peer VPC. Incoming traffic is allowed based
   555  // on the private IP addresses of instances that are associated with the specified security
   556  // group.
   557  func ExampleEC2_AuthorizeSecurityGroupIngress_shared01() {
   558  	svc := ec2.New(session.New())
   559  	input := &ec2.AuthorizeSecurityGroupIngressInput{
   560  		GroupId: aws.String("sg-111aaa22"),
   561  		IpPermissions: []*ec2.IpPermission{
   562  			{
   563  				FromPort:   aws.Int64(80),
   564  				IpProtocol: aws.String("tcp"),
   565  				ToPort:     aws.Int64(80),
   566  				UserIdGroupPairs: []*ec2.UserIdGroupPair{
   567  					{
   568  						Description: aws.String("HTTP access from other instances"),
   569  						GroupId:     aws.String("sg-1a2b3c4d"),
   570  					},
   571  				},
   572  			},
   573  		},
   574  	}
   575  
   576  	result, err := svc.AuthorizeSecurityGroupIngress(input)
   577  	if err != nil {
   578  		if aerr, ok := err.(awserr.Error); ok {
   579  			switch aerr.Code() {
   580  			default:
   581  				fmt.Println(aerr.Error())
   582  			}
   583  		} else {
   584  			// Print the error, cast err to awserr.Error to get the Code and
   585  			// Message from an error.
   586  			fmt.Println(err.Error())
   587  		}
   588  		return
   589  	}
   590  
   591  	fmt.Println(result)
   592  }
   593  
   594  // To add a rule that allows inbound RDP traffic from an IPv6 address range
   595  //
   596  // This example adds an inbound rule that allows RDP traffic from the specified IPv6
   597  // address range. The rule includes a description to help you identify it later.
   598  func ExampleEC2_AuthorizeSecurityGroupIngress_shared02() {
   599  	svc := ec2.New(session.New())
   600  	input := &ec2.AuthorizeSecurityGroupIngressInput{
   601  		GroupId: aws.String("sg-123abc12 "),
   602  		IpPermissions: []*ec2.IpPermission{
   603  			{
   604  				FromPort:   aws.Int64(3389),
   605  				IpProtocol: aws.String("tcp"),
   606  				Ipv6Ranges: []*ec2.Ipv6Range{
   607  					{
   608  						CidrIpv6:    aws.String("2001:db8:1234:1a00::/64"),
   609  						Description: aws.String("RDP access from the NY office"),
   610  					},
   611  				},
   612  				ToPort: aws.Int64(3389),
   613  			},
   614  		},
   615  	}
   616  
   617  	result, err := svc.AuthorizeSecurityGroupIngress(input)
   618  	if err != nil {
   619  		if aerr, ok := err.(awserr.Error); ok {
   620  			switch aerr.Code() {
   621  			default:
   622  				fmt.Println(aerr.Error())
   623  			}
   624  		} else {
   625  			// Print the error, cast err to awserr.Error to get the Code and
   626  			// Message from an error.
   627  			fmt.Println(err.Error())
   628  		}
   629  		return
   630  	}
   631  
   632  	fmt.Println(result)
   633  }
   634  
   635  // To cancel a Spot fleet request
   636  //
   637  // This example cancels the specified Spot fleet request and terminates its associated
   638  // Spot Instances.
   639  func ExampleEC2_CancelSpotFleetRequests_shared00() {
   640  	svc := ec2.New(session.New())
   641  	input := &ec2.CancelSpotFleetRequestsInput{
   642  		SpotFleetRequestIds: []*string{
   643  			aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
   644  		},
   645  		TerminateInstances: aws.Bool(true),
   646  	}
   647  
   648  	result, err := svc.CancelSpotFleetRequests(input)
   649  	if err != nil {
   650  		if aerr, ok := err.(awserr.Error); ok {
   651  			switch aerr.Code() {
   652  			default:
   653  				fmt.Println(aerr.Error())
   654  			}
   655  		} else {
   656  			// Print the error, cast err to awserr.Error to get the Code and
   657  			// Message from an error.
   658  			fmt.Println(err.Error())
   659  		}
   660  		return
   661  	}
   662  
   663  	fmt.Println(result)
   664  }
   665  
   666  // To cancel a Spot fleet request without terminating its Spot Instances
   667  //
   668  // This example cancels the specified Spot fleet request without terminating its associated
   669  // Spot Instances.
   670  func ExampleEC2_CancelSpotFleetRequests_shared01() {
   671  	svc := ec2.New(session.New())
   672  	input := &ec2.CancelSpotFleetRequestsInput{
   673  		SpotFleetRequestIds: []*string{
   674  			aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
   675  		},
   676  		TerminateInstances: aws.Bool(false),
   677  	}
   678  
   679  	result, err := svc.CancelSpotFleetRequests(input)
   680  	if err != nil {
   681  		if aerr, ok := err.(awserr.Error); ok {
   682  			switch aerr.Code() {
   683  			default:
   684  				fmt.Println(aerr.Error())
   685  			}
   686  		} else {
   687  			// Print the error, cast err to awserr.Error to get the Code and
   688  			// Message from an error.
   689  			fmt.Println(err.Error())
   690  		}
   691  		return
   692  	}
   693  
   694  	fmt.Println(result)
   695  }
   696  
   697  // To cancel Spot Instance requests
   698  //
   699  // This example cancels a Spot Instance request.
   700  func ExampleEC2_CancelSpotInstanceRequests_shared00() {
   701  	svc := ec2.New(session.New())
   702  	input := &ec2.CancelSpotInstanceRequestsInput{
   703  		SpotInstanceRequestIds: []*string{
   704  			aws.String("sir-08b93456"),
   705  		},
   706  	}
   707  
   708  	result, err := svc.CancelSpotInstanceRequests(input)
   709  	if err != nil {
   710  		if aerr, ok := err.(awserr.Error); ok {
   711  			switch aerr.Code() {
   712  			default:
   713  				fmt.Println(aerr.Error())
   714  			}
   715  		} else {
   716  			// Print the error, cast err to awserr.Error to get the Code and
   717  			// Message from an error.
   718  			fmt.Println(err.Error())
   719  		}
   720  		return
   721  	}
   722  
   723  	fmt.Println(result)
   724  }
   725  
   726  // To confirm the product instance
   727  //
   728  // This example determines whether the specified product code is associated with the
   729  // specified instance.
   730  func ExampleEC2_ConfirmProductInstance_shared00() {
   731  	svc := ec2.New(session.New())
   732  	input := &ec2.ConfirmProductInstanceInput{
   733  		InstanceId:  aws.String("i-1234567890abcdef0"),
   734  		ProductCode: aws.String("774F4FF8"),
   735  	}
   736  
   737  	result, err := svc.ConfirmProductInstance(input)
   738  	if err != nil {
   739  		if aerr, ok := err.(awserr.Error); ok {
   740  			switch aerr.Code() {
   741  			default:
   742  				fmt.Println(aerr.Error())
   743  			}
   744  		} else {
   745  			// Print the error, cast err to awserr.Error to get the Code and
   746  			// Message from an error.
   747  			fmt.Println(err.Error())
   748  		}
   749  		return
   750  	}
   751  
   752  	fmt.Println(result)
   753  }
   754  
   755  // To copy an AMI to another region
   756  //
   757  // This example copies the specified AMI from the us-east-1 region to the current region.
   758  func ExampleEC2_CopyImage_shared00() {
   759  	svc := ec2.New(session.New())
   760  	input := &ec2.CopyImageInput{
   761  		Description:   aws.String(""),
   762  		Name:          aws.String("My server"),
   763  		SourceImageId: aws.String("ami-5731123e"),
   764  		SourceRegion:  aws.String("us-east-1"),
   765  	}
   766  
   767  	result, err := svc.CopyImage(input)
   768  	if err != nil {
   769  		if aerr, ok := err.(awserr.Error); ok {
   770  			switch aerr.Code() {
   771  			default:
   772  				fmt.Println(aerr.Error())
   773  			}
   774  		} else {
   775  			// Print the error, cast err to awserr.Error to get the Code and
   776  			// Message from an error.
   777  			fmt.Println(err.Error())
   778  		}
   779  		return
   780  	}
   781  
   782  	fmt.Println(result)
   783  }
   784  
   785  // To copy a snapshot
   786  //
   787  // This example copies a snapshot with the snapshot ID of ``snap-066877671789bd71b``
   788  // from the ``us-west-2`` region to the ``us-east-1`` region and adds a short description
   789  // to identify the snapshot.
   790  func ExampleEC2_CopySnapshot_shared00() {
   791  	svc := ec2.New(session.New())
   792  	input := &ec2.CopySnapshotInput{
   793  		Description:       aws.String("This is my copied snapshot."),
   794  		DestinationRegion: aws.String("us-east-1"),
   795  		SourceRegion:      aws.String("us-west-2"),
   796  		SourceSnapshotId:  aws.String("snap-066877671789bd71b"),
   797  	}
   798  
   799  	result, err := svc.CopySnapshot(input)
   800  	if err != nil {
   801  		if aerr, ok := err.(awserr.Error); ok {
   802  			switch aerr.Code() {
   803  			default:
   804  				fmt.Println(aerr.Error())
   805  			}
   806  		} else {
   807  			// Print the error, cast err to awserr.Error to get the Code and
   808  			// Message from an error.
   809  			fmt.Println(err.Error())
   810  		}
   811  		return
   812  	}
   813  
   814  	fmt.Println(result)
   815  }
   816  
   817  // To create a customer gateway
   818  //
   819  // This example creates a customer gateway with the specified IP address for its outside
   820  // interface.
   821  func ExampleEC2_CreateCustomerGateway_shared00() {
   822  	svc := ec2.New(session.New())
   823  	input := &ec2.CreateCustomerGatewayInput{
   824  		BgpAsn:   aws.Int64(65534),
   825  		PublicIp: aws.String("12.1.2.3"),
   826  		Type:     aws.String("ipsec.1"),
   827  	}
   828  
   829  	result, err := svc.CreateCustomerGateway(input)
   830  	if err != nil {
   831  		if aerr, ok := err.(awserr.Error); ok {
   832  			switch aerr.Code() {
   833  			default:
   834  				fmt.Println(aerr.Error())
   835  			}
   836  		} else {
   837  			// Print the error, cast err to awserr.Error to get the Code and
   838  			// Message from an error.
   839  			fmt.Println(err.Error())
   840  		}
   841  		return
   842  	}
   843  
   844  	fmt.Println(result)
   845  }
   846  
   847  // To create a DHCP options set
   848  //
   849  // This example creates a DHCP options set.
   850  func ExampleEC2_CreateDhcpOptions_shared00() {
   851  	svc := ec2.New(session.New())
   852  	input := &ec2.CreateDhcpOptionsInput{
   853  		DhcpConfigurations: []*ec2.NewDhcpConfiguration{
   854  			{
   855  				Key: aws.String("domain-name-servers"),
   856  				Values: []*string{
   857  					aws.String("10.2.5.1"),
   858  					aws.String("10.2.5.2"),
   859  				},
   860  			},
   861  		},
   862  	}
   863  
   864  	result, err := svc.CreateDhcpOptions(input)
   865  	if err != nil {
   866  		if aerr, ok := err.(awserr.Error); ok {
   867  			switch aerr.Code() {
   868  			default:
   869  				fmt.Println(aerr.Error())
   870  			}
   871  		} else {
   872  			// Print the error, cast err to awserr.Error to get the Code and
   873  			// Message from an error.
   874  			fmt.Println(err.Error())
   875  		}
   876  		return
   877  	}
   878  
   879  	fmt.Println(result)
   880  }
   881  
   882  // To create an AMI from an Amazon EBS-backed instance
   883  //
   884  // This example creates an AMI from the specified instance and adds an EBS volume with
   885  // the device name /dev/sdh and an instance store volume with the device name /dev/sdc.
   886  func ExampleEC2_CreateImage_shared00() {
   887  	svc := ec2.New(session.New())
   888  	input := &ec2.CreateImageInput{
   889  		BlockDeviceMappings: []*ec2.BlockDeviceMapping{
   890  			{
   891  				DeviceName: aws.String("/dev/sdh"),
   892  				Ebs: &ec2.EbsBlockDevice{
   893  					VolumeSize: aws.Int64(100),
   894  				},
   895  			},
   896  			{
   897  				DeviceName:  aws.String("/dev/sdc"),
   898  				VirtualName: aws.String("ephemeral1"),
   899  			},
   900  		},
   901  		Description: aws.String("An AMI for my server"),
   902  		InstanceId:  aws.String("i-1234567890abcdef0"),
   903  		Name:        aws.String("My server"),
   904  		NoReboot:    aws.Bool(true),
   905  	}
   906  
   907  	result, err := svc.CreateImage(input)
   908  	if err != nil {
   909  		if aerr, ok := err.(awserr.Error); ok {
   910  			switch aerr.Code() {
   911  			default:
   912  				fmt.Println(aerr.Error())
   913  			}
   914  		} else {
   915  			// Print the error, cast err to awserr.Error to get the Code and
   916  			// Message from an error.
   917  			fmt.Println(err.Error())
   918  		}
   919  		return
   920  	}
   921  
   922  	fmt.Println(result)
   923  }
   924  
   925  // To create an Internet gateway
   926  //
   927  // This example creates an Internet gateway.
   928  func ExampleEC2_CreateInternetGateway_shared00() {
   929  	svc := ec2.New(session.New())
   930  	input := &ec2.CreateInternetGatewayInput{}
   931  
   932  	result, err := svc.CreateInternetGateway(input)
   933  	if err != nil {
   934  		if aerr, ok := err.(awserr.Error); ok {
   935  			switch aerr.Code() {
   936  			default:
   937  				fmt.Println(aerr.Error())
   938  			}
   939  		} else {
   940  			// Print the error, cast err to awserr.Error to get the Code and
   941  			// Message from an error.
   942  			fmt.Println(err.Error())
   943  		}
   944  		return
   945  	}
   946  
   947  	fmt.Println(result)
   948  }
   949  
   950  // To create a key pair
   951  //
   952  // This example creates a key pair named my-key-pair.
   953  func ExampleEC2_CreateKeyPair_shared00() {
   954  	svc := ec2.New(session.New())
   955  	input := &ec2.CreateKeyPairInput{
   956  		KeyName: aws.String("my-key-pair"),
   957  	}
   958  
   959  	result, err := svc.CreateKeyPair(input)
   960  	if err != nil {
   961  		if aerr, ok := err.(awserr.Error); ok {
   962  			switch aerr.Code() {
   963  			default:
   964  				fmt.Println(aerr.Error())
   965  			}
   966  		} else {
   967  			// Print the error, cast err to awserr.Error to get the Code and
   968  			// Message from an error.
   969  			fmt.Println(err.Error())
   970  		}
   971  		return
   972  	}
   973  
   974  	fmt.Println(result)
   975  }
   976  
   977  // To create a launch template
   978  //
   979  // This example creates a launch template that specifies the subnet in which to launch
   980  // the instance, assigns a public IP address and an IPv6 address to the instance, and
   981  // creates a tag for the instance.
   982  func ExampleEC2_CreateLaunchTemplate_shared00() {
   983  	svc := ec2.New(session.New())
   984  	input := &ec2.CreateLaunchTemplateInput{
   985  		LaunchTemplateData: &ec2.RequestLaunchTemplateData{
   986  			ImageId:      aws.String("ami-8c1be5f6"),
   987  			InstanceType: aws.String("t2.small"),
   988  			NetworkInterfaces: []*ec2.LaunchTemplateInstanceNetworkInterfaceSpecificationRequest{
   989  				{
   990  					AssociatePublicIpAddress: aws.Bool(true),
   991  					DeviceIndex:              aws.Int64(0),
   992  					Ipv6AddressCount:         aws.Int64(1),
   993  					SubnetId:                 aws.String("subnet-7b16de0c"),
   994  				},
   995  			},
   996  			TagSpecifications: []*ec2.LaunchTemplateTagSpecificationRequest{
   997  				{
   998  					ResourceType: aws.String("instance"),
   999  					Tags: []*ec2.Tag{
  1000  						{
  1001  							Key:   aws.String("Name"),
  1002  							Value: aws.String("webserver"),
  1003  						},
  1004  					},
  1005  				},
  1006  			},
  1007  		},
  1008  		LaunchTemplateName: aws.String("my-template"),
  1009  		VersionDescription: aws.String("WebVersion1"),
  1010  	}
  1011  
  1012  	result, err := svc.CreateLaunchTemplate(input)
  1013  	if err != nil {
  1014  		if aerr, ok := err.(awserr.Error); ok {
  1015  			switch aerr.Code() {
  1016  			default:
  1017  				fmt.Println(aerr.Error())
  1018  			}
  1019  		} else {
  1020  			// Print the error, cast err to awserr.Error to get the Code and
  1021  			// Message from an error.
  1022  			fmt.Println(err.Error())
  1023  		}
  1024  		return
  1025  	}
  1026  
  1027  	fmt.Println(result)
  1028  }
  1029  
  1030  // To create a launch template version
  1031  //
  1032  // This example creates a new launch template version based on version 1 of the specified
  1033  // launch template and specifies a different AMI ID.
  1034  func ExampleEC2_CreateLaunchTemplateVersion_shared00() {
  1035  	svc := ec2.New(session.New())
  1036  	input := &ec2.CreateLaunchTemplateVersionInput{
  1037  		LaunchTemplateData: &ec2.RequestLaunchTemplateData{
  1038  			ImageId: aws.String("ami-c998b6b2"),
  1039  		},
  1040  		LaunchTemplateId:   aws.String("lt-0abcd290751193123"),
  1041  		SourceVersion:      aws.String("1"),
  1042  		VersionDescription: aws.String("WebVersion2"),
  1043  	}
  1044  
  1045  	result, err := svc.CreateLaunchTemplateVersion(input)
  1046  	if err != nil {
  1047  		if aerr, ok := err.(awserr.Error); ok {
  1048  			switch aerr.Code() {
  1049  			default:
  1050  				fmt.Println(aerr.Error())
  1051  			}
  1052  		} else {
  1053  			// Print the error, cast err to awserr.Error to get the Code and
  1054  			// Message from an error.
  1055  			fmt.Println(err.Error())
  1056  		}
  1057  		return
  1058  	}
  1059  
  1060  	fmt.Println(result)
  1061  }
  1062  
  1063  // To create a NAT gateway
  1064  //
  1065  // This example creates a NAT gateway in subnet subnet-1a2b3c4d and associates an Elastic
  1066  // IP address with the allocation ID eipalloc-37fc1a52 with the NAT gateway.
  1067  func ExampleEC2_CreateNatGateway_shared00() {
  1068  	svc := ec2.New(session.New())
  1069  	input := &ec2.CreateNatGatewayInput{
  1070  		AllocationId: aws.String("eipalloc-37fc1a52"),
  1071  		SubnetId:     aws.String("subnet-1a2b3c4d"),
  1072  	}
  1073  
  1074  	result, err := svc.CreateNatGateway(input)
  1075  	if err != nil {
  1076  		if aerr, ok := err.(awserr.Error); ok {
  1077  			switch aerr.Code() {
  1078  			default:
  1079  				fmt.Println(aerr.Error())
  1080  			}
  1081  		} else {
  1082  			// Print the error, cast err to awserr.Error to get the Code and
  1083  			// Message from an error.
  1084  			fmt.Println(err.Error())
  1085  		}
  1086  		return
  1087  	}
  1088  
  1089  	fmt.Println(result)
  1090  }
  1091  
  1092  // To create a network ACL
  1093  //
  1094  // This example creates a network ACL for the specified VPC.
  1095  func ExampleEC2_CreateNetworkAcl_shared00() {
  1096  	svc := ec2.New(session.New())
  1097  	input := &ec2.CreateNetworkAclInput{
  1098  		VpcId: aws.String("vpc-a01106c2"),
  1099  	}
  1100  
  1101  	result, err := svc.CreateNetworkAcl(input)
  1102  	if err != nil {
  1103  		if aerr, ok := err.(awserr.Error); ok {
  1104  			switch aerr.Code() {
  1105  			default:
  1106  				fmt.Println(aerr.Error())
  1107  			}
  1108  		} else {
  1109  			// Print the error, cast err to awserr.Error to get the Code and
  1110  			// Message from an error.
  1111  			fmt.Println(err.Error())
  1112  		}
  1113  		return
  1114  	}
  1115  
  1116  	fmt.Println(result)
  1117  }
  1118  
  1119  // To create a network ACL entry
  1120  //
  1121  // This example creates an entry for the specified network ACL. The rule allows ingress
  1122  // traffic from anywhere (0.0.0.0/0) on UDP port 53 (DNS) into any associated subnet.
  1123  func ExampleEC2_CreateNetworkAclEntry_shared00() {
  1124  	svc := ec2.New(session.New())
  1125  	input := &ec2.CreateNetworkAclEntryInput{
  1126  		CidrBlock:    aws.String("0.0.0.0/0"),
  1127  		Egress:       aws.Bool(false),
  1128  		NetworkAclId: aws.String("acl-5fb85d36"),
  1129  		PortRange: &ec2.PortRange{
  1130  			From: aws.Int64(53),
  1131  			To:   aws.Int64(53),
  1132  		},
  1133  		Protocol:   aws.String("17"),
  1134  		RuleAction: aws.String("allow"),
  1135  		RuleNumber: aws.Int64(100),
  1136  	}
  1137  
  1138  	result, err := svc.CreateNetworkAclEntry(input)
  1139  	if err != nil {
  1140  		if aerr, ok := err.(awserr.Error); ok {
  1141  			switch aerr.Code() {
  1142  			default:
  1143  				fmt.Println(aerr.Error())
  1144  			}
  1145  		} else {
  1146  			// Print the error, cast err to awserr.Error to get the Code and
  1147  			// Message from an error.
  1148  			fmt.Println(err.Error())
  1149  		}
  1150  		return
  1151  	}
  1152  
  1153  	fmt.Println(result)
  1154  }
  1155  
  1156  // To create a network interface
  1157  //
  1158  // This example creates a network interface for the specified subnet.
  1159  func ExampleEC2_CreateNetworkInterface_shared00() {
  1160  	svc := ec2.New(session.New())
  1161  	input := &ec2.CreateNetworkInterfaceInput{
  1162  		Description: aws.String("my network interface"),
  1163  		Groups: []*string{
  1164  			aws.String("sg-903004f8"),
  1165  		},
  1166  		PrivateIpAddress: aws.String("10.0.2.17"),
  1167  		SubnetId:         aws.String("subnet-9d4a7b6c"),
  1168  	}
  1169  
  1170  	result, err := svc.CreateNetworkInterface(input)
  1171  	if err != nil {
  1172  		if aerr, ok := err.(awserr.Error); ok {
  1173  			switch aerr.Code() {
  1174  			default:
  1175  				fmt.Println(aerr.Error())
  1176  			}
  1177  		} else {
  1178  			// Print the error, cast err to awserr.Error to get the Code and
  1179  			// Message from an error.
  1180  			fmt.Println(err.Error())
  1181  		}
  1182  		return
  1183  	}
  1184  
  1185  	fmt.Println(result)
  1186  }
  1187  
  1188  // To create a placement group
  1189  //
  1190  // This example creates a placement group with the specified name.
  1191  func ExampleEC2_CreatePlacementGroup_shared00() {
  1192  	svc := ec2.New(session.New())
  1193  	input := &ec2.CreatePlacementGroupInput{
  1194  		GroupName: aws.String("my-cluster"),
  1195  		Strategy:  aws.String("cluster"),
  1196  	}
  1197  
  1198  	result, err := svc.CreatePlacementGroup(input)
  1199  	if err != nil {
  1200  		if aerr, ok := err.(awserr.Error); ok {
  1201  			switch aerr.Code() {
  1202  			default:
  1203  				fmt.Println(aerr.Error())
  1204  			}
  1205  		} else {
  1206  			// Print the error, cast err to awserr.Error to get the Code and
  1207  			// Message from an error.
  1208  			fmt.Println(err.Error())
  1209  		}
  1210  		return
  1211  	}
  1212  
  1213  	fmt.Println(result)
  1214  }
  1215  
  1216  // To create a route
  1217  //
  1218  // This example creates a route for the specified route table. The route matches all
  1219  // traffic (0.0.0.0/0) and routes it to the specified Internet gateway.
  1220  func ExampleEC2_CreateRoute_shared00() {
  1221  	svc := ec2.New(session.New())
  1222  	input := &ec2.CreateRouteInput{
  1223  		DestinationCidrBlock: aws.String("0.0.0.0/0"),
  1224  		GatewayId:            aws.String("igw-c0a643a9"),
  1225  		RouteTableId:         aws.String("rtb-22574640"),
  1226  	}
  1227  
  1228  	result, err := svc.CreateRoute(input)
  1229  	if err != nil {
  1230  		if aerr, ok := err.(awserr.Error); ok {
  1231  			switch aerr.Code() {
  1232  			default:
  1233  				fmt.Println(aerr.Error())
  1234  			}
  1235  		} else {
  1236  			// Print the error, cast err to awserr.Error to get the Code and
  1237  			// Message from an error.
  1238  			fmt.Println(err.Error())
  1239  		}
  1240  		return
  1241  	}
  1242  
  1243  	fmt.Println(result)
  1244  }
  1245  
  1246  // To create a route table
  1247  //
  1248  // This example creates a route table for the specified VPC.
  1249  func ExampleEC2_CreateRouteTable_shared00() {
  1250  	svc := ec2.New(session.New())
  1251  	input := &ec2.CreateRouteTableInput{
  1252  		VpcId: aws.String("vpc-a01106c2"),
  1253  	}
  1254  
  1255  	result, err := svc.CreateRouteTable(input)
  1256  	if err != nil {
  1257  		if aerr, ok := err.(awserr.Error); ok {
  1258  			switch aerr.Code() {
  1259  			default:
  1260  				fmt.Println(aerr.Error())
  1261  			}
  1262  		} else {
  1263  			// Print the error, cast err to awserr.Error to get the Code and
  1264  			// Message from an error.
  1265  			fmt.Println(err.Error())
  1266  		}
  1267  		return
  1268  	}
  1269  
  1270  	fmt.Println(result)
  1271  }
  1272  
  1273  // To create a security group for a VPC
  1274  //
  1275  // This example creates a security group for the specified VPC.
  1276  func ExampleEC2_CreateSecurityGroup_shared00() {
  1277  	svc := ec2.New(session.New())
  1278  	input := &ec2.CreateSecurityGroupInput{
  1279  		Description: aws.String("My security group"),
  1280  		GroupName:   aws.String("my-security-group"),
  1281  		VpcId:       aws.String("vpc-1a2b3c4d"),
  1282  	}
  1283  
  1284  	result, err := svc.CreateSecurityGroup(input)
  1285  	if err != nil {
  1286  		if aerr, ok := err.(awserr.Error); ok {
  1287  			switch aerr.Code() {
  1288  			default:
  1289  				fmt.Println(aerr.Error())
  1290  			}
  1291  		} else {
  1292  			// Print the error, cast err to awserr.Error to get the Code and
  1293  			// Message from an error.
  1294  			fmt.Println(err.Error())
  1295  		}
  1296  		return
  1297  	}
  1298  
  1299  	fmt.Println(result)
  1300  }
  1301  
  1302  // To create a snapshot
  1303  //
  1304  // This example creates a snapshot of the volume with a volume ID of ``vol-1234567890abcdef0``
  1305  // and a short description to identify the snapshot.
  1306  func ExampleEC2_CreateSnapshot_shared00() {
  1307  	svc := ec2.New(session.New())
  1308  	input := &ec2.CreateSnapshotInput{
  1309  		Description: aws.String("This is my root volume snapshot."),
  1310  		VolumeId:    aws.String("vol-1234567890abcdef0"),
  1311  	}
  1312  
  1313  	result, err := svc.CreateSnapshot(input)
  1314  	if err != nil {
  1315  		if aerr, ok := err.(awserr.Error); ok {
  1316  			switch aerr.Code() {
  1317  			default:
  1318  				fmt.Println(aerr.Error())
  1319  			}
  1320  		} else {
  1321  			// Print the error, cast err to awserr.Error to get the Code and
  1322  			// Message from an error.
  1323  			fmt.Println(err.Error())
  1324  		}
  1325  		return
  1326  	}
  1327  
  1328  	fmt.Println(result)
  1329  }
  1330  
  1331  // To create a Spot Instance datafeed
  1332  //
  1333  // This example creates a Spot Instance data feed for your AWS account.
  1334  func ExampleEC2_CreateSpotDatafeedSubscription_shared00() {
  1335  	svc := ec2.New(session.New())
  1336  	input := &ec2.CreateSpotDatafeedSubscriptionInput{
  1337  		Bucket: aws.String("my-s3-bucket"),
  1338  		Prefix: aws.String("spotdata"),
  1339  	}
  1340  
  1341  	result, err := svc.CreateSpotDatafeedSubscription(input)
  1342  	if err != nil {
  1343  		if aerr, ok := err.(awserr.Error); ok {
  1344  			switch aerr.Code() {
  1345  			default:
  1346  				fmt.Println(aerr.Error())
  1347  			}
  1348  		} else {
  1349  			// Print the error, cast err to awserr.Error to get the Code and
  1350  			// Message from an error.
  1351  			fmt.Println(err.Error())
  1352  		}
  1353  		return
  1354  	}
  1355  
  1356  	fmt.Println(result)
  1357  }
  1358  
  1359  // To create a subnet
  1360  //
  1361  // This example creates a subnet in the specified VPC with the specified CIDR block.
  1362  // We recommend that you let us select an Availability Zone for you.
  1363  func ExampleEC2_CreateSubnet_shared00() {
  1364  	svc := ec2.New(session.New())
  1365  	input := &ec2.CreateSubnetInput{
  1366  		CidrBlock: aws.String("10.0.1.0/24"),
  1367  		VpcId:     aws.String("vpc-a01106c2"),
  1368  	}
  1369  
  1370  	result, err := svc.CreateSubnet(input)
  1371  	if err != nil {
  1372  		if aerr, ok := err.(awserr.Error); ok {
  1373  			switch aerr.Code() {
  1374  			default:
  1375  				fmt.Println(aerr.Error())
  1376  			}
  1377  		} else {
  1378  			// Print the error, cast err to awserr.Error to get the Code and
  1379  			// Message from an error.
  1380  			fmt.Println(err.Error())
  1381  		}
  1382  		return
  1383  	}
  1384  
  1385  	fmt.Println(result)
  1386  }
  1387  
  1388  // To add a tag to a resource
  1389  //
  1390  // This example adds the tag Stack=production to the specified image, or overwrites
  1391  // an existing tag for the AMI where the tag key is Stack.
  1392  func ExampleEC2_CreateTags_shared00() {
  1393  	svc := ec2.New(session.New())
  1394  	input := &ec2.CreateTagsInput{
  1395  		Resources: []*string{
  1396  			aws.String("ami-78a54011"),
  1397  		},
  1398  		Tags: []*ec2.Tag{
  1399  			{
  1400  				Key:   aws.String("Stack"),
  1401  				Value: aws.String("production"),
  1402  			},
  1403  		},
  1404  	}
  1405  
  1406  	result, err := svc.CreateTags(input)
  1407  	if err != nil {
  1408  		if aerr, ok := err.(awserr.Error); ok {
  1409  			switch aerr.Code() {
  1410  			default:
  1411  				fmt.Println(aerr.Error())
  1412  			}
  1413  		} else {
  1414  			// Print the error, cast err to awserr.Error to get the Code and
  1415  			// Message from an error.
  1416  			fmt.Println(err.Error())
  1417  		}
  1418  		return
  1419  	}
  1420  
  1421  	fmt.Println(result)
  1422  }
  1423  
  1424  // To create a new volume
  1425  //
  1426  // This example creates an 80 GiB General Purpose (SSD) volume in the Availability Zone
  1427  // ``us-east-1a``.
  1428  func ExampleEC2_CreateVolume_shared00() {
  1429  	svc := ec2.New(session.New())
  1430  	input := &ec2.CreateVolumeInput{
  1431  		AvailabilityZone: aws.String("us-east-1a"),
  1432  		Size:             aws.Int64(80),
  1433  		VolumeType:       aws.String("gp2"),
  1434  	}
  1435  
  1436  	result, err := svc.CreateVolume(input)
  1437  	if err != nil {
  1438  		if aerr, ok := err.(awserr.Error); ok {
  1439  			switch aerr.Code() {
  1440  			default:
  1441  				fmt.Println(aerr.Error())
  1442  			}
  1443  		} else {
  1444  			// Print the error, cast err to awserr.Error to get the Code and
  1445  			// Message from an error.
  1446  			fmt.Println(err.Error())
  1447  		}
  1448  		return
  1449  	}
  1450  
  1451  	fmt.Println(result)
  1452  }
  1453  
  1454  // To create a new Provisioned IOPS (SSD) volume from a snapshot
  1455  //
  1456  // This example creates a new Provisioned IOPS (SSD) volume with 1000 provisioned IOPS
  1457  // from a snapshot in the Availability Zone ``us-east-1a``.
  1458  func ExampleEC2_CreateVolume_shared01() {
  1459  	svc := ec2.New(session.New())
  1460  	input := &ec2.CreateVolumeInput{
  1461  		AvailabilityZone: aws.String("us-east-1a"),
  1462  		Iops:             aws.Int64(1000),
  1463  		SnapshotId:       aws.String("snap-066877671789bd71b"),
  1464  		VolumeType:       aws.String("io1"),
  1465  	}
  1466  
  1467  	result, err := svc.CreateVolume(input)
  1468  	if err != nil {
  1469  		if aerr, ok := err.(awserr.Error); ok {
  1470  			switch aerr.Code() {
  1471  			default:
  1472  				fmt.Println(aerr.Error())
  1473  			}
  1474  		} else {
  1475  			// Print the error, cast err to awserr.Error to get the Code and
  1476  			// Message from an error.
  1477  			fmt.Println(err.Error())
  1478  		}
  1479  		return
  1480  	}
  1481  
  1482  	fmt.Println(result)
  1483  }
  1484  
  1485  // To create a VPC
  1486  //
  1487  // This example creates a VPC with the specified CIDR block.
  1488  func ExampleEC2_CreateVpc_shared00() {
  1489  	svc := ec2.New(session.New())
  1490  	input := &ec2.CreateVpcInput{
  1491  		CidrBlock: aws.String("10.0.0.0/16"),
  1492  	}
  1493  
  1494  	result, err := svc.CreateVpc(input)
  1495  	if err != nil {
  1496  		if aerr, ok := err.(awserr.Error); ok {
  1497  			switch aerr.Code() {
  1498  			default:
  1499  				fmt.Println(aerr.Error())
  1500  			}
  1501  		} else {
  1502  			// Print the error, cast err to awserr.Error to get the Code and
  1503  			// Message from an error.
  1504  			fmt.Println(err.Error())
  1505  		}
  1506  		return
  1507  	}
  1508  
  1509  	fmt.Println(result)
  1510  }
  1511  
  1512  // To delete a customer gateway
  1513  //
  1514  // This example deletes the specified customer gateway.
  1515  func ExampleEC2_DeleteCustomerGateway_shared00() {
  1516  	svc := ec2.New(session.New())
  1517  	input := &ec2.DeleteCustomerGatewayInput{
  1518  		CustomerGatewayId: aws.String("cgw-0e11f167"),
  1519  	}
  1520  
  1521  	result, err := svc.DeleteCustomerGateway(input)
  1522  	if err != nil {
  1523  		if aerr, ok := err.(awserr.Error); ok {
  1524  			switch aerr.Code() {
  1525  			default:
  1526  				fmt.Println(aerr.Error())
  1527  			}
  1528  		} else {
  1529  			// Print the error, cast err to awserr.Error to get the Code and
  1530  			// Message from an error.
  1531  			fmt.Println(err.Error())
  1532  		}
  1533  		return
  1534  	}
  1535  
  1536  	fmt.Println(result)
  1537  }
  1538  
  1539  // To delete a DHCP options set
  1540  //
  1541  // This example deletes the specified DHCP options set.
  1542  func ExampleEC2_DeleteDhcpOptions_shared00() {
  1543  	svc := ec2.New(session.New())
  1544  	input := &ec2.DeleteDhcpOptionsInput{
  1545  		DhcpOptionsId: aws.String("dopt-d9070ebb"),
  1546  	}
  1547  
  1548  	result, err := svc.DeleteDhcpOptions(input)
  1549  	if err != nil {
  1550  		if aerr, ok := err.(awserr.Error); ok {
  1551  			switch aerr.Code() {
  1552  			default:
  1553  				fmt.Println(aerr.Error())
  1554  			}
  1555  		} else {
  1556  			// Print the error, cast err to awserr.Error to get the Code and
  1557  			// Message from an error.
  1558  			fmt.Println(err.Error())
  1559  		}
  1560  		return
  1561  	}
  1562  
  1563  	fmt.Println(result)
  1564  }
  1565  
  1566  // To delete an Internet gateway
  1567  //
  1568  // This example deletes the specified Internet gateway.
  1569  func ExampleEC2_DeleteInternetGateway_shared00() {
  1570  	svc := ec2.New(session.New())
  1571  	input := &ec2.DeleteInternetGatewayInput{
  1572  		InternetGatewayId: aws.String("igw-c0a643a9"),
  1573  	}
  1574  
  1575  	result, err := svc.DeleteInternetGateway(input)
  1576  	if err != nil {
  1577  		if aerr, ok := err.(awserr.Error); ok {
  1578  			switch aerr.Code() {
  1579  			default:
  1580  				fmt.Println(aerr.Error())
  1581  			}
  1582  		} else {
  1583  			// Print the error, cast err to awserr.Error to get the Code and
  1584  			// Message from an error.
  1585  			fmt.Println(err.Error())
  1586  		}
  1587  		return
  1588  	}
  1589  
  1590  	fmt.Println(result)
  1591  }
  1592  
  1593  // To delete a key pair
  1594  //
  1595  // This example deletes the specified key pair.
  1596  func ExampleEC2_DeleteKeyPair_shared00() {
  1597  	svc := ec2.New(session.New())
  1598  	input := &ec2.DeleteKeyPairInput{
  1599  		KeyName: aws.String("my-key-pair"),
  1600  	}
  1601  
  1602  	result, err := svc.DeleteKeyPair(input)
  1603  	if err != nil {
  1604  		if aerr, ok := err.(awserr.Error); ok {
  1605  			switch aerr.Code() {
  1606  			default:
  1607  				fmt.Println(aerr.Error())
  1608  			}
  1609  		} else {
  1610  			// Print the error, cast err to awserr.Error to get the Code and
  1611  			// Message from an error.
  1612  			fmt.Println(err.Error())
  1613  		}
  1614  		return
  1615  	}
  1616  
  1617  	fmt.Println(result)
  1618  }
  1619  
  1620  // To delete a launch template
  1621  //
  1622  // This example deletes the specified launch template.
  1623  func ExampleEC2_DeleteLaunchTemplate_shared00() {
  1624  	svc := ec2.New(session.New())
  1625  	input := &ec2.DeleteLaunchTemplateInput{
  1626  		LaunchTemplateId: aws.String("lt-0abcd290751193123"),
  1627  	}
  1628  
  1629  	result, err := svc.DeleteLaunchTemplate(input)
  1630  	if err != nil {
  1631  		if aerr, ok := err.(awserr.Error); ok {
  1632  			switch aerr.Code() {
  1633  			default:
  1634  				fmt.Println(aerr.Error())
  1635  			}
  1636  		} else {
  1637  			// Print the error, cast err to awserr.Error to get the Code and
  1638  			// Message from an error.
  1639  			fmt.Println(err.Error())
  1640  		}
  1641  		return
  1642  	}
  1643  
  1644  	fmt.Println(result)
  1645  }
  1646  
  1647  // To delete a launch template version
  1648  //
  1649  // This example deletes the specified launch template version.
  1650  func ExampleEC2_DeleteLaunchTemplateVersions_shared00() {
  1651  	svc := ec2.New(session.New())
  1652  	input := &ec2.DeleteLaunchTemplateVersionsInput{
  1653  		LaunchTemplateId: aws.String("lt-0abcd290751193123"),
  1654  		Versions: []*string{
  1655  			aws.String("1"),
  1656  		},
  1657  	}
  1658  
  1659  	result, err := svc.DeleteLaunchTemplateVersions(input)
  1660  	if err != nil {
  1661  		if aerr, ok := err.(awserr.Error); ok {
  1662  			switch aerr.Code() {
  1663  			default:
  1664  				fmt.Println(aerr.Error())
  1665  			}
  1666  		} else {
  1667  			// Print the error, cast err to awserr.Error to get the Code and
  1668  			// Message from an error.
  1669  			fmt.Println(err.Error())
  1670  		}
  1671  		return
  1672  	}
  1673  
  1674  	fmt.Println(result)
  1675  }
  1676  
  1677  // To delete a NAT gateway
  1678  //
  1679  // This example deletes the specified NAT gateway.
  1680  func ExampleEC2_DeleteNatGateway_shared00() {
  1681  	svc := ec2.New(session.New())
  1682  	input := &ec2.DeleteNatGatewayInput{
  1683  		NatGatewayId: aws.String("nat-04ae55e711cec5680"),
  1684  	}
  1685  
  1686  	result, err := svc.DeleteNatGateway(input)
  1687  	if err != nil {
  1688  		if aerr, ok := err.(awserr.Error); ok {
  1689  			switch aerr.Code() {
  1690  			default:
  1691  				fmt.Println(aerr.Error())
  1692  			}
  1693  		} else {
  1694  			// Print the error, cast err to awserr.Error to get the Code and
  1695  			// Message from an error.
  1696  			fmt.Println(err.Error())
  1697  		}
  1698  		return
  1699  	}
  1700  
  1701  	fmt.Println(result)
  1702  }
  1703  
  1704  // To delete a network ACL
  1705  //
  1706  // This example deletes the specified network ACL.
  1707  func ExampleEC2_DeleteNetworkAcl_shared00() {
  1708  	svc := ec2.New(session.New())
  1709  	input := &ec2.DeleteNetworkAclInput{
  1710  		NetworkAclId: aws.String("acl-5fb85d36"),
  1711  	}
  1712  
  1713  	result, err := svc.DeleteNetworkAcl(input)
  1714  	if err != nil {
  1715  		if aerr, ok := err.(awserr.Error); ok {
  1716  			switch aerr.Code() {
  1717  			default:
  1718  				fmt.Println(aerr.Error())
  1719  			}
  1720  		} else {
  1721  			// Print the error, cast err to awserr.Error to get the Code and
  1722  			// Message from an error.
  1723  			fmt.Println(err.Error())
  1724  		}
  1725  		return
  1726  	}
  1727  
  1728  	fmt.Println(result)
  1729  }
  1730  
  1731  // To delete a network ACL entry
  1732  //
  1733  // This example deletes ingress rule number 100 from the specified network ACL.
  1734  func ExampleEC2_DeleteNetworkAclEntry_shared00() {
  1735  	svc := ec2.New(session.New())
  1736  	input := &ec2.DeleteNetworkAclEntryInput{
  1737  		Egress:       aws.Bool(true),
  1738  		NetworkAclId: aws.String("acl-5fb85d36"),
  1739  		RuleNumber:   aws.Int64(100),
  1740  	}
  1741  
  1742  	result, err := svc.DeleteNetworkAclEntry(input)
  1743  	if err != nil {
  1744  		if aerr, ok := err.(awserr.Error); ok {
  1745  			switch aerr.Code() {
  1746  			default:
  1747  				fmt.Println(aerr.Error())
  1748  			}
  1749  		} else {
  1750  			// Print the error, cast err to awserr.Error to get the Code and
  1751  			// Message from an error.
  1752  			fmt.Println(err.Error())
  1753  		}
  1754  		return
  1755  	}
  1756  
  1757  	fmt.Println(result)
  1758  }
  1759  
  1760  // To delete a network interface
  1761  //
  1762  // This example deletes the specified network interface.
  1763  func ExampleEC2_DeleteNetworkInterface_shared00() {
  1764  	svc := ec2.New(session.New())
  1765  	input := &ec2.DeleteNetworkInterfaceInput{
  1766  		NetworkInterfaceId: aws.String("eni-e5aa89a3"),
  1767  	}
  1768  
  1769  	result, err := svc.DeleteNetworkInterface(input)
  1770  	if err != nil {
  1771  		if aerr, ok := err.(awserr.Error); ok {
  1772  			switch aerr.Code() {
  1773  			default:
  1774  				fmt.Println(aerr.Error())
  1775  			}
  1776  		} else {
  1777  			// Print the error, cast err to awserr.Error to get the Code and
  1778  			// Message from an error.
  1779  			fmt.Println(err.Error())
  1780  		}
  1781  		return
  1782  	}
  1783  
  1784  	fmt.Println(result)
  1785  }
  1786  
  1787  // To delete a placement group
  1788  //
  1789  // This example deletes the specified placement group.
  1790  func ExampleEC2_DeletePlacementGroup_shared00() {
  1791  	svc := ec2.New(session.New())
  1792  	input := &ec2.DeletePlacementGroupInput{
  1793  		GroupName: aws.String("my-cluster"),
  1794  	}
  1795  
  1796  	result, err := svc.DeletePlacementGroup(input)
  1797  	if err != nil {
  1798  		if aerr, ok := err.(awserr.Error); ok {
  1799  			switch aerr.Code() {
  1800  			default:
  1801  				fmt.Println(aerr.Error())
  1802  			}
  1803  		} else {
  1804  			// Print the error, cast err to awserr.Error to get the Code and
  1805  			// Message from an error.
  1806  			fmt.Println(err.Error())
  1807  		}
  1808  		return
  1809  	}
  1810  
  1811  	fmt.Println(result)
  1812  }
  1813  
  1814  // To delete a route
  1815  //
  1816  // This example deletes the specified route from the specified route table.
  1817  func ExampleEC2_DeleteRoute_shared00() {
  1818  	svc := ec2.New(session.New())
  1819  	input := &ec2.DeleteRouteInput{
  1820  		DestinationCidrBlock: aws.String("0.0.0.0/0"),
  1821  		RouteTableId:         aws.String("rtb-22574640"),
  1822  	}
  1823  
  1824  	result, err := svc.DeleteRoute(input)
  1825  	if err != nil {
  1826  		if aerr, ok := err.(awserr.Error); ok {
  1827  			switch aerr.Code() {
  1828  			default:
  1829  				fmt.Println(aerr.Error())
  1830  			}
  1831  		} else {
  1832  			// Print the error, cast err to awserr.Error to get the Code and
  1833  			// Message from an error.
  1834  			fmt.Println(err.Error())
  1835  		}
  1836  		return
  1837  	}
  1838  
  1839  	fmt.Println(result)
  1840  }
  1841  
  1842  // To delete a route table
  1843  //
  1844  // This example deletes the specified route table.
  1845  func ExampleEC2_DeleteRouteTable_shared00() {
  1846  	svc := ec2.New(session.New())
  1847  	input := &ec2.DeleteRouteTableInput{
  1848  		RouteTableId: aws.String("rtb-22574640"),
  1849  	}
  1850  
  1851  	result, err := svc.DeleteRouteTable(input)
  1852  	if err != nil {
  1853  		if aerr, ok := err.(awserr.Error); ok {
  1854  			switch aerr.Code() {
  1855  			default:
  1856  				fmt.Println(aerr.Error())
  1857  			}
  1858  		} else {
  1859  			// Print the error, cast err to awserr.Error to get the Code and
  1860  			// Message from an error.
  1861  			fmt.Println(err.Error())
  1862  		}
  1863  		return
  1864  	}
  1865  
  1866  	fmt.Println(result)
  1867  }
  1868  
  1869  // To delete a security group
  1870  //
  1871  // This example deletes the specified security group.
  1872  func ExampleEC2_DeleteSecurityGroup_shared00() {
  1873  	svc := ec2.New(session.New())
  1874  	input := &ec2.DeleteSecurityGroupInput{
  1875  		GroupId: aws.String("sg-903004f8"),
  1876  	}
  1877  
  1878  	result, err := svc.DeleteSecurityGroup(input)
  1879  	if err != nil {
  1880  		if aerr, ok := err.(awserr.Error); ok {
  1881  			switch aerr.Code() {
  1882  			default:
  1883  				fmt.Println(aerr.Error())
  1884  			}
  1885  		} else {
  1886  			// Print the error, cast err to awserr.Error to get the Code and
  1887  			// Message from an error.
  1888  			fmt.Println(err.Error())
  1889  		}
  1890  		return
  1891  	}
  1892  
  1893  	fmt.Println(result)
  1894  }
  1895  
  1896  // To delete a snapshot
  1897  //
  1898  // This example deletes a snapshot with the snapshot ID of ``snap-1234567890abcdef0``.
  1899  // If the command succeeds, no output is returned.
  1900  func ExampleEC2_DeleteSnapshot_shared00() {
  1901  	svc := ec2.New(session.New())
  1902  	input := &ec2.DeleteSnapshotInput{
  1903  		SnapshotId: aws.String("snap-1234567890abcdef0"),
  1904  	}
  1905  
  1906  	result, err := svc.DeleteSnapshot(input)
  1907  	if err != nil {
  1908  		if aerr, ok := err.(awserr.Error); ok {
  1909  			switch aerr.Code() {
  1910  			default:
  1911  				fmt.Println(aerr.Error())
  1912  			}
  1913  		} else {
  1914  			// Print the error, cast err to awserr.Error to get the Code and
  1915  			// Message from an error.
  1916  			fmt.Println(err.Error())
  1917  		}
  1918  		return
  1919  	}
  1920  
  1921  	fmt.Println(result)
  1922  }
  1923  
  1924  // To cancel a Spot Instance data feed subscription
  1925  //
  1926  // This example deletes a Spot data feed subscription for the account.
  1927  func ExampleEC2_DeleteSpotDatafeedSubscription_shared00() {
  1928  	svc := ec2.New(session.New())
  1929  	input := &ec2.DeleteSpotDatafeedSubscriptionInput{}
  1930  
  1931  	result, err := svc.DeleteSpotDatafeedSubscription(input)
  1932  	if err != nil {
  1933  		if aerr, ok := err.(awserr.Error); ok {
  1934  			switch aerr.Code() {
  1935  			default:
  1936  				fmt.Println(aerr.Error())
  1937  			}
  1938  		} else {
  1939  			// Print the error, cast err to awserr.Error to get the Code and
  1940  			// Message from an error.
  1941  			fmt.Println(err.Error())
  1942  		}
  1943  		return
  1944  	}
  1945  
  1946  	fmt.Println(result)
  1947  }
  1948  
  1949  // To delete a subnet
  1950  //
  1951  // This example deletes the specified subnet.
  1952  func ExampleEC2_DeleteSubnet_shared00() {
  1953  	svc := ec2.New(session.New())
  1954  	input := &ec2.DeleteSubnetInput{
  1955  		SubnetId: aws.String("subnet-9d4a7b6c"),
  1956  	}
  1957  
  1958  	result, err := svc.DeleteSubnet(input)
  1959  	if err != nil {
  1960  		if aerr, ok := err.(awserr.Error); ok {
  1961  			switch aerr.Code() {
  1962  			default:
  1963  				fmt.Println(aerr.Error())
  1964  			}
  1965  		} else {
  1966  			// Print the error, cast err to awserr.Error to get the Code and
  1967  			// Message from an error.
  1968  			fmt.Println(err.Error())
  1969  		}
  1970  		return
  1971  	}
  1972  
  1973  	fmt.Println(result)
  1974  }
  1975  
  1976  // To delete a tag from a resource
  1977  //
  1978  // This example deletes the tag Stack=test from the specified image.
  1979  func ExampleEC2_DeleteTags_shared00() {
  1980  	svc := ec2.New(session.New())
  1981  	input := &ec2.DeleteTagsInput{
  1982  		Resources: []*string{
  1983  			aws.String("ami-78a54011"),
  1984  		},
  1985  		Tags: []*ec2.Tag{
  1986  			{
  1987  				Key:   aws.String("Stack"),
  1988  				Value: aws.String("test"),
  1989  			},
  1990  		},
  1991  	}
  1992  
  1993  	result, err := svc.DeleteTags(input)
  1994  	if err != nil {
  1995  		if aerr, ok := err.(awserr.Error); ok {
  1996  			switch aerr.Code() {
  1997  			default:
  1998  				fmt.Println(aerr.Error())
  1999  			}
  2000  		} else {
  2001  			// Print the error, cast err to awserr.Error to get the Code and
  2002  			// Message from an error.
  2003  			fmt.Println(err.Error())
  2004  		}
  2005  		return
  2006  	}
  2007  
  2008  	fmt.Println(result)
  2009  }
  2010  
  2011  // To delete a volume
  2012  //
  2013  // This example deletes an available volume with the volume ID of ``vol-049df61146c4d7901``.
  2014  // If the command succeeds, no output is returned.
  2015  func ExampleEC2_DeleteVolume_shared00() {
  2016  	svc := ec2.New(session.New())
  2017  	input := &ec2.DeleteVolumeInput{
  2018  		VolumeId: aws.String("vol-049df61146c4d7901"),
  2019  	}
  2020  
  2021  	result, err := svc.DeleteVolume(input)
  2022  	if err != nil {
  2023  		if aerr, ok := err.(awserr.Error); ok {
  2024  			switch aerr.Code() {
  2025  			default:
  2026  				fmt.Println(aerr.Error())
  2027  			}
  2028  		} else {
  2029  			// Print the error, cast err to awserr.Error to get the Code and
  2030  			// Message from an error.
  2031  			fmt.Println(err.Error())
  2032  		}
  2033  		return
  2034  	}
  2035  
  2036  	fmt.Println(result)
  2037  }
  2038  
  2039  // To delete a VPC
  2040  //
  2041  // This example deletes the specified VPC.
  2042  func ExampleEC2_DeleteVpc_shared00() {
  2043  	svc := ec2.New(session.New())
  2044  	input := &ec2.DeleteVpcInput{
  2045  		VpcId: aws.String("vpc-a01106c2"),
  2046  	}
  2047  
  2048  	result, err := svc.DeleteVpc(input)
  2049  	if err != nil {
  2050  		if aerr, ok := err.(awserr.Error); ok {
  2051  			switch aerr.Code() {
  2052  			default:
  2053  				fmt.Println(aerr.Error())
  2054  			}
  2055  		} else {
  2056  			// Print the error, cast err to awserr.Error to get the Code and
  2057  			// Message from an error.
  2058  			fmt.Println(err.Error())
  2059  		}
  2060  		return
  2061  	}
  2062  
  2063  	fmt.Println(result)
  2064  }
  2065  
  2066  // To describe a single attribute for your AWS account
  2067  //
  2068  // This example describes the supported-platforms attribute for your AWS account.
  2069  func ExampleEC2_DescribeAccountAttributes_shared00() {
  2070  	svc := ec2.New(session.New())
  2071  	input := &ec2.DescribeAccountAttributesInput{
  2072  		AttributeNames: []*string{
  2073  			aws.String("supported-platforms"),
  2074  		},
  2075  	}
  2076  
  2077  	result, err := svc.DescribeAccountAttributes(input)
  2078  	if err != nil {
  2079  		if aerr, ok := err.(awserr.Error); ok {
  2080  			switch aerr.Code() {
  2081  			default:
  2082  				fmt.Println(aerr.Error())
  2083  			}
  2084  		} else {
  2085  			// Print the error, cast err to awserr.Error to get the Code and
  2086  			// Message from an error.
  2087  			fmt.Println(err.Error())
  2088  		}
  2089  		return
  2090  	}
  2091  
  2092  	fmt.Println(result)
  2093  }
  2094  
  2095  // To describe all attributes for your AWS account
  2096  //
  2097  // This example describes the attributes for your AWS account.
  2098  func ExampleEC2_DescribeAccountAttributes_shared01() {
  2099  	svc := ec2.New(session.New())
  2100  	input := &ec2.DescribeAccountAttributesInput{}
  2101  
  2102  	result, err := svc.DescribeAccountAttributes(input)
  2103  	if err != nil {
  2104  		if aerr, ok := err.(awserr.Error); ok {
  2105  			switch aerr.Code() {
  2106  			default:
  2107  				fmt.Println(aerr.Error())
  2108  			}
  2109  		} else {
  2110  			// Print the error, cast err to awserr.Error to get the Code and
  2111  			// Message from an error.
  2112  			fmt.Println(err.Error())
  2113  		}
  2114  		return
  2115  	}
  2116  
  2117  	fmt.Println(result)
  2118  }
  2119  
  2120  // To describe your Elastic IP addresses
  2121  //
  2122  // This example describes your Elastic IP addresses.
  2123  func ExampleEC2_DescribeAddresses_shared00() {
  2124  	svc := ec2.New(session.New())
  2125  	input := &ec2.DescribeAddressesInput{}
  2126  
  2127  	result, err := svc.DescribeAddresses(input)
  2128  	if err != nil {
  2129  		if aerr, ok := err.(awserr.Error); ok {
  2130  			switch aerr.Code() {
  2131  			default:
  2132  				fmt.Println(aerr.Error())
  2133  			}
  2134  		} else {
  2135  			// Print the error, cast err to awserr.Error to get the Code and
  2136  			// Message from an error.
  2137  			fmt.Println(err.Error())
  2138  		}
  2139  		return
  2140  	}
  2141  
  2142  	fmt.Println(result)
  2143  }
  2144  
  2145  // To describe your Elastic IP addresses for EC2-VPC
  2146  //
  2147  // This example describes your Elastic IP addresses for use with instances in a VPC.
  2148  func ExampleEC2_DescribeAddresses_shared01() {
  2149  	svc := ec2.New(session.New())
  2150  	input := &ec2.DescribeAddressesInput{
  2151  		Filters: []*ec2.Filter{
  2152  			{
  2153  				Name: aws.String("domain"),
  2154  				Values: []*string{
  2155  					aws.String("vpc"),
  2156  				},
  2157  			},
  2158  		},
  2159  	}
  2160  
  2161  	result, err := svc.DescribeAddresses(input)
  2162  	if err != nil {
  2163  		if aerr, ok := err.(awserr.Error); ok {
  2164  			switch aerr.Code() {
  2165  			default:
  2166  				fmt.Println(aerr.Error())
  2167  			}
  2168  		} else {
  2169  			// Print the error, cast err to awserr.Error to get the Code and
  2170  			// Message from an error.
  2171  			fmt.Println(err.Error())
  2172  		}
  2173  		return
  2174  	}
  2175  
  2176  	fmt.Println(result)
  2177  }
  2178  
  2179  // To describe your Elastic IP addresses for EC2-Classic
  2180  //
  2181  // This example describes your Elastic IP addresses for use with instances in EC2-Classic.
  2182  func ExampleEC2_DescribeAddresses_shared02() {
  2183  	svc := ec2.New(session.New())
  2184  	input := &ec2.DescribeAddressesInput{
  2185  		Filters: []*ec2.Filter{
  2186  			{
  2187  				Name: aws.String("domain"),
  2188  				Values: []*string{
  2189  					aws.String("standard"),
  2190  				},
  2191  			},
  2192  		},
  2193  	}
  2194  
  2195  	result, err := svc.DescribeAddresses(input)
  2196  	if err != nil {
  2197  		if aerr, ok := err.(awserr.Error); ok {
  2198  			switch aerr.Code() {
  2199  			default:
  2200  				fmt.Println(aerr.Error())
  2201  			}
  2202  		} else {
  2203  			// Print the error, cast err to awserr.Error to get the Code and
  2204  			// Message from an error.
  2205  			fmt.Println(err.Error())
  2206  		}
  2207  		return
  2208  	}
  2209  
  2210  	fmt.Println(result)
  2211  }
  2212  
  2213  // To describe your Availability Zones
  2214  //
  2215  // This example describes the Availability Zones that are available to you. The response
  2216  // includes Availability Zones only for the current region.
  2217  func ExampleEC2_DescribeAvailabilityZones_shared00() {
  2218  	svc := ec2.New(session.New())
  2219  	input := &ec2.DescribeAvailabilityZonesInput{}
  2220  
  2221  	result, err := svc.DescribeAvailabilityZones(input)
  2222  	if err != nil {
  2223  		if aerr, ok := err.(awserr.Error); ok {
  2224  			switch aerr.Code() {
  2225  			default:
  2226  				fmt.Println(aerr.Error())
  2227  			}
  2228  		} else {
  2229  			// Print the error, cast err to awserr.Error to get the Code and
  2230  			// Message from an error.
  2231  			fmt.Println(err.Error())
  2232  		}
  2233  		return
  2234  	}
  2235  
  2236  	fmt.Println(result)
  2237  }
  2238  
  2239  // To describe a customer gateway
  2240  //
  2241  // This example describes the specified customer gateway.
  2242  func ExampleEC2_DescribeCustomerGateways_shared00() {
  2243  	svc := ec2.New(session.New())
  2244  	input := &ec2.DescribeCustomerGatewaysInput{
  2245  		CustomerGatewayIds: []*string{
  2246  			aws.String("cgw-0e11f167"),
  2247  		},
  2248  	}
  2249  
  2250  	result, err := svc.DescribeCustomerGateways(input)
  2251  	if err != nil {
  2252  		if aerr, ok := err.(awserr.Error); ok {
  2253  			switch aerr.Code() {
  2254  			default:
  2255  				fmt.Println(aerr.Error())
  2256  			}
  2257  		} else {
  2258  			// Print the error, cast err to awserr.Error to get the Code and
  2259  			// Message from an error.
  2260  			fmt.Println(err.Error())
  2261  		}
  2262  		return
  2263  	}
  2264  
  2265  	fmt.Println(result)
  2266  }
  2267  
  2268  // To describe a DHCP options set
  2269  //
  2270  // This example describes the specified DHCP options set.
  2271  func ExampleEC2_DescribeDhcpOptions_shared00() {
  2272  	svc := ec2.New(session.New())
  2273  	input := &ec2.DescribeDhcpOptionsInput{
  2274  		DhcpOptionsIds: []*string{
  2275  			aws.String("dopt-d9070ebb"),
  2276  		},
  2277  	}
  2278  
  2279  	result, err := svc.DescribeDhcpOptions(input)
  2280  	if err != nil {
  2281  		if aerr, ok := err.(awserr.Error); ok {
  2282  			switch aerr.Code() {
  2283  			default:
  2284  				fmt.Println(aerr.Error())
  2285  			}
  2286  		} else {
  2287  			// Print the error, cast err to awserr.Error to get the Code and
  2288  			// Message from an error.
  2289  			fmt.Println(err.Error())
  2290  		}
  2291  		return
  2292  	}
  2293  
  2294  	fmt.Println(result)
  2295  }
  2296  
  2297  // To describe an IAM instance profile association
  2298  //
  2299  // This example describes the specified IAM instance profile association.
  2300  func ExampleEC2_DescribeIamInstanceProfileAssociations_shared00() {
  2301  	svc := ec2.New(session.New())
  2302  	input := &ec2.DescribeIamInstanceProfileAssociationsInput{
  2303  		AssociationIds: []*string{
  2304  			aws.String("iip-assoc-0db249b1f25fa24b8"),
  2305  		},
  2306  	}
  2307  
  2308  	result, err := svc.DescribeIamInstanceProfileAssociations(input)
  2309  	if err != nil {
  2310  		if aerr, ok := err.(awserr.Error); ok {
  2311  			switch aerr.Code() {
  2312  			default:
  2313  				fmt.Println(aerr.Error())
  2314  			}
  2315  		} else {
  2316  			// Print the error, cast err to awserr.Error to get the Code and
  2317  			// Message from an error.
  2318  			fmt.Println(err.Error())
  2319  		}
  2320  		return
  2321  	}
  2322  
  2323  	fmt.Println(result)
  2324  }
  2325  
  2326  // To describe the launch permissions for an AMI
  2327  //
  2328  // This example describes the launch permissions for the specified AMI.
  2329  func ExampleEC2_DescribeImageAttribute_shared00() {
  2330  	svc := ec2.New(session.New())
  2331  	input := &ec2.DescribeImageAttributeInput{
  2332  		Attribute: aws.String("launchPermission"),
  2333  		ImageId:   aws.String("ami-5731123e"),
  2334  	}
  2335  
  2336  	result, err := svc.DescribeImageAttribute(input)
  2337  	if err != nil {
  2338  		if aerr, ok := err.(awserr.Error); ok {
  2339  			switch aerr.Code() {
  2340  			default:
  2341  				fmt.Println(aerr.Error())
  2342  			}
  2343  		} else {
  2344  			// Print the error, cast err to awserr.Error to get the Code and
  2345  			// Message from an error.
  2346  			fmt.Println(err.Error())
  2347  		}
  2348  		return
  2349  	}
  2350  
  2351  	fmt.Println(result)
  2352  }
  2353  
  2354  // To describe an AMI
  2355  //
  2356  // This example describes the specified AMI.
  2357  func ExampleEC2_DescribeImages_shared00() {
  2358  	svc := ec2.New(session.New())
  2359  	input := &ec2.DescribeImagesInput{
  2360  		ImageIds: []*string{
  2361  			aws.String("ami-5731123e"),
  2362  		},
  2363  	}
  2364  
  2365  	result, err := svc.DescribeImages(input)
  2366  	if err != nil {
  2367  		if aerr, ok := err.(awserr.Error); ok {
  2368  			switch aerr.Code() {
  2369  			default:
  2370  				fmt.Println(aerr.Error())
  2371  			}
  2372  		} else {
  2373  			// Print the error, cast err to awserr.Error to get the Code and
  2374  			// Message from an error.
  2375  			fmt.Println(err.Error())
  2376  		}
  2377  		return
  2378  	}
  2379  
  2380  	fmt.Println(result)
  2381  }
  2382  
  2383  // To describe the instance type
  2384  //
  2385  // This example describes the instance type of the specified instance.
  2386  func ExampleEC2_DescribeInstanceAttribute_shared00() {
  2387  	svc := ec2.New(session.New())
  2388  	input := &ec2.DescribeInstanceAttributeInput{
  2389  		Attribute:  aws.String("instanceType"),
  2390  		InstanceId: aws.String("i-1234567890abcdef0"),
  2391  	}
  2392  
  2393  	result, err := svc.DescribeInstanceAttribute(input)
  2394  	if err != nil {
  2395  		if aerr, ok := err.(awserr.Error); ok {
  2396  			switch aerr.Code() {
  2397  			default:
  2398  				fmt.Println(aerr.Error())
  2399  			}
  2400  		} else {
  2401  			// Print the error, cast err to awserr.Error to get the Code and
  2402  			// Message from an error.
  2403  			fmt.Println(err.Error())
  2404  		}
  2405  		return
  2406  	}
  2407  
  2408  	fmt.Println(result)
  2409  }
  2410  
  2411  // To describe the disableApiTermination attribute
  2412  //
  2413  // This example describes the ``disableApiTermination`` attribute of the specified instance.
  2414  func ExampleEC2_DescribeInstanceAttribute_shared01() {
  2415  	svc := ec2.New(session.New())
  2416  	input := &ec2.DescribeInstanceAttributeInput{
  2417  		Attribute:  aws.String("disableApiTermination"),
  2418  		InstanceId: aws.String("i-1234567890abcdef0"),
  2419  	}
  2420  
  2421  	result, err := svc.DescribeInstanceAttribute(input)
  2422  	if err != nil {
  2423  		if aerr, ok := err.(awserr.Error); ok {
  2424  			switch aerr.Code() {
  2425  			default:
  2426  				fmt.Println(aerr.Error())
  2427  			}
  2428  		} else {
  2429  			// Print the error, cast err to awserr.Error to get the Code and
  2430  			// Message from an error.
  2431  			fmt.Println(err.Error())
  2432  		}
  2433  		return
  2434  	}
  2435  
  2436  	fmt.Println(result)
  2437  }
  2438  
  2439  // To describe the block device mapping for an instance
  2440  //
  2441  // This example describes the ``blockDeviceMapping`` attribute of the specified instance.
  2442  func ExampleEC2_DescribeInstanceAttribute_shared02() {
  2443  	svc := ec2.New(session.New())
  2444  	input := &ec2.DescribeInstanceAttributeInput{
  2445  		Attribute:  aws.String("blockDeviceMapping"),
  2446  		InstanceId: aws.String("i-1234567890abcdef0"),
  2447  	}
  2448  
  2449  	result, err := svc.DescribeInstanceAttribute(input)
  2450  	if err != nil {
  2451  		if aerr, ok := err.(awserr.Error); ok {
  2452  			switch aerr.Code() {
  2453  			default:
  2454  				fmt.Println(aerr.Error())
  2455  			}
  2456  		} else {
  2457  			// Print the error, cast err to awserr.Error to get the Code and
  2458  			// Message from an error.
  2459  			fmt.Println(err.Error())
  2460  		}
  2461  		return
  2462  	}
  2463  
  2464  	fmt.Println(result)
  2465  }
  2466  
  2467  // To describe the status of an instance
  2468  //
  2469  // This example describes the current status of the specified instance.
  2470  func ExampleEC2_DescribeInstanceStatus_shared00() {
  2471  	svc := ec2.New(session.New())
  2472  	input := &ec2.DescribeInstanceStatusInput{
  2473  		InstanceIds: []*string{
  2474  			aws.String("i-1234567890abcdef0"),
  2475  		},
  2476  	}
  2477  
  2478  	result, err := svc.DescribeInstanceStatus(input)
  2479  	if err != nil {
  2480  		if aerr, ok := err.(awserr.Error); ok {
  2481  			switch aerr.Code() {
  2482  			default:
  2483  				fmt.Println(aerr.Error())
  2484  			}
  2485  		} else {
  2486  			// Print the error, cast err to awserr.Error to get the Code and
  2487  			// Message from an error.
  2488  			fmt.Println(err.Error())
  2489  		}
  2490  		return
  2491  	}
  2492  
  2493  	fmt.Println(result)
  2494  }
  2495  
  2496  // To describe an Amazon EC2 instance
  2497  //
  2498  // This example describes the specified instance.
  2499  func ExampleEC2_DescribeInstances_shared00() {
  2500  	svc := ec2.New(session.New())
  2501  	input := &ec2.DescribeInstancesInput{
  2502  		InstanceIds: []*string{
  2503  			aws.String("i-1234567890abcdef0"),
  2504  		},
  2505  	}
  2506  
  2507  	result, err := svc.DescribeInstances(input)
  2508  	if err != nil {
  2509  		if aerr, ok := err.(awserr.Error); ok {
  2510  			switch aerr.Code() {
  2511  			default:
  2512  				fmt.Println(aerr.Error())
  2513  			}
  2514  		} else {
  2515  			// Print the error, cast err to awserr.Error to get the Code and
  2516  			// Message from an error.
  2517  			fmt.Println(err.Error())
  2518  		}
  2519  		return
  2520  	}
  2521  
  2522  	fmt.Println(result)
  2523  }
  2524  
  2525  // To describe the instances with a specific instance type
  2526  //
  2527  // This example describes the instances with the t2.micro instance type.
  2528  func ExampleEC2_DescribeInstances_shared01() {
  2529  	svc := ec2.New(session.New())
  2530  	input := &ec2.DescribeInstancesInput{
  2531  		Filters: []*ec2.Filter{
  2532  			{
  2533  				Name: aws.String("instance-type"),
  2534  				Values: []*string{
  2535  					aws.String("t2.micro"),
  2536  				},
  2537  			},
  2538  		},
  2539  	}
  2540  
  2541  	result, err := svc.DescribeInstances(input)
  2542  	if err != nil {
  2543  		if aerr, ok := err.(awserr.Error); ok {
  2544  			switch aerr.Code() {
  2545  			default:
  2546  				fmt.Println(aerr.Error())
  2547  			}
  2548  		} else {
  2549  			// Print the error, cast err to awserr.Error to get the Code and
  2550  			// Message from an error.
  2551  			fmt.Println(err.Error())
  2552  		}
  2553  		return
  2554  	}
  2555  
  2556  	fmt.Println(result)
  2557  }
  2558  
  2559  // To describe the instances with a specific tag
  2560  //
  2561  // This example describes the instances with the Purpose=test tag.
  2562  func ExampleEC2_DescribeInstances_shared02() {
  2563  	svc := ec2.New(session.New())
  2564  	input := &ec2.DescribeInstancesInput{
  2565  		Filters: []*ec2.Filter{
  2566  			{
  2567  				Name: aws.String("tag:Purpose"),
  2568  				Values: []*string{
  2569  					aws.String("test"),
  2570  				},
  2571  			},
  2572  		},
  2573  	}
  2574  
  2575  	result, err := svc.DescribeInstances(input)
  2576  	if err != nil {
  2577  		if aerr, ok := err.(awserr.Error); ok {
  2578  			switch aerr.Code() {
  2579  			default:
  2580  				fmt.Println(aerr.Error())
  2581  			}
  2582  		} else {
  2583  			// Print the error, cast err to awserr.Error to get the Code and
  2584  			// Message from an error.
  2585  			fmt.Println(err.Error())
  2586  		}
  2587  		return
  2588  	}
  2589  
  2590  	fmt.Println(result)
  2591  }
  2592  
  2593  // To describe the Internet gateway for a VPC
  2594  //
  2595  // This example describes the Internet gateway for the specified VPC.
  2596  func ExampleEC2_DescribeInternetGateways_shared00() {
  2597  	svc := ec2.New(session.New())
  2598  	input := &ec2.DescribeInternetGatewaysInput{
  2599  		Filters: []*ec2.Filter{
  2600  			{
  2601  				Name: aws.String("attachment.vpc-id"),
  2602  				Values: []*string{
  2603  					aws.String("vpc-a01106c2"),
  2604  				},
  2605  			},
  2606  		},
  2607  	}
  2608  
  2609  	result, err := svc.DescribeInternetGateways(input)
  2610  	if err != nil {
  2611  		if aerr, ok := err.(awserr.Error); ok {
  2612  			switch aerr.Code() {
  2613  			default:
  2614  				fmt.Println(aerr.Error())
  2615  			}
  2616  		} else {
  2617  			// Print the error, cast err to awserr.Error to get the Code and
  2618  			// Message from an error.
  2619  			fmt.Println(err.Error())
  2620  		}
  2621  		return
  2622  	}
  2623  
  2624  	fmt.Println(result)
  2625  }
  2626  
  2627  // To display a key pair
  2628  //
  2629  // This example displays the fingerprint for the specified key.
  2630  func ExampleEC2_DescribeKeyPairs_shared00() {
  2631  	svc := ec2.New(session.New())
  2632  	input := &ec2.DescribeKeyPairsInput{
  2633  		KeyNames: []*string{
  2634  			aws.String("my-key-pair"),
  2635  		},
  2636  	}
  2637  
  2638  	result, err := svc.DescribeKeyPairs(input)
  2639  	if err != nil {
  2640  		if aerr, ok := err.(awserr.Error); ok {
  2641  			switch aerr.Code() {
  2642  			default:
  2643  				fmt.Println(aerr.Error())
  2644  			}
  2645  		} else {
  2646  			// Print the error, cast err to awserr.Error to get the Code and
  2647  			// Message from an error.
  2648  			fmt.Println(err.Error())
  2649  		}
  2650  		return
  2651  	}
  2652  
  2653  	fmt.Println(result)
  2654  }
  2655  
  2656  // To describe the versions for a launch template
  2657  //
  2658  // This example describes the versions for the specified launch template.
  2659  func ExampleEC2_DescribeLaunchTemplateVersions_shared00() {
  2660  	svc := ec2.New(session.New())
  2661  	input := &ec2.DescribeLaunchTemplateVersionsInput{
  2662  		LaunchTemplateId: aws.String("068f72b72934aff71"),
  2663  	}
  2664  
  2665  	result, err := svc.DescribeLaunchTemplateVersions(input)
  2666  	if err != nil {
  2667  		if aerr, ok := err.(awserr.Error); ok {
  2668  			switch aerr.Code() {
  2669  			default:
  2670  				fmt.Println(aerr.Error())
  2671  			}
  2672  		} else {
  2673  			// Print the error, cast err to awserr.Error to get the Code and
  2674  			// Message from an error.
  2675  			fmt.Println(err.Error())
  2676  		}
  2677  		return
  2678  	}
  2679  
  2680  	fmt.Println(result)
  2681  }
  2682  
  2683  // To describe a launch template
  2684  //
  2685  // This example describes the specified launch template.
  2686  func ExampleEC2_DescribeLaunchTemplates_shared00() {
  2687  	svc := ec2.New(session.New())
  2688  	input := &ec2.DescribeLaunchTemplatesInput{
  2689  		LaunchTemplateIds: []*string{
  2690  			aws.String("lt-01238c059e3466abc"),
  2691  		},
  2692  	}
  2693  
  2694  	result, err := svc.DescribeLaunchTemplates(input)
  2695  	if err != nil {
  2696  		if aerr, ok := err.(awserr.Error); ok {
  2697  			switch aerr.Code() {
  2698  			default:
  2699  				fmt.Println(aerr.Error())
  2700  			}
  2701  		} else {
  2702  			// Print the error, cast err to awserr.Error to get the Code and
  2703  			// Message from an error.
  2704  			fmt.Println(err.Error())
  2705  		}
  2706  		return
  2707  	}
  2708  
  2709  	fmt.Println(result)
  2710  }
  2711  
  2712  // To describe your moving addresses
  2713  //
  2714  // This example describes all of your moving Elastic IP addresses.
  2715  func ExampleEC2_DescribeMovingAddresses_shared00() {
  2716  	svc := ec2.New(session.New())
  2717  	input := &ec2.DescribeMovingAddressesInput{}
  2718  
  2719  	result, err := svc.DescribeMovingAddresses(input)
  2720  	if err != nil {
  2721  		if aerr, ok := err.(awserr.Error); ok {
  2722  			switch aerr.Code() {
  2723  			default:
  2724  				fmt.Println(aerr.Error())
  2725  			}
  2726  		} else {
  2727  			// Print the error, cast err to awserr.Error to get the Code and
  2728  			// Message from an error.
  2729  			fmt.Println(err.Error())
  2730  		}
  2731  		return
  2732  	}
  2733  
  2734  	fmt.Println(result)
  2735  }
  2736  
  2737  // To describe a NAT gateway
  2738  //
  2739  // This example describes the NAT gateway for the specified VPC.
  2740  func ExampleEC2_DescribeNatGateways_shared00() {
  2741  	svc := ec2.New(session.New())
  2742  	input := &ec2.DescribeNatGatewaysInput{
  2743  		Filter: []*ec2.Filter{
  2744  			{
  2745  				Name: aws.String("vpc-id"),
  2746  				Values: []*string{
  2747  					aws.String("vpc-1a2b3c4d"),
  2748  				},
  2749  			},
  2750  		},
  2751  	}
  2752  
  2753  	result, err := svc.DescribeNatGateways(input)
  2754  	if err != nil {
  2755  		if aerr, ok := err.(awserr.Error); ok {
  2756  			switch aerr.Code() {
  2757  			default:
  2758  				fmt.Println(aerr.Error())
  2759  			}
  2760  		} else {
  2761  			// Print the error, cast err to awserr.Error to get the Code and
  2762  			// Message from an error.
  2763  			fmt.Println(err.Error())
  2764  		}
  2765  		return
  2766  	}
  2767  
  2768  	fmt.Println(result)
  2769  }
  2770  
  2771  // To describe a network ACL
  2772  //
  2773  // This example describes the specified network ACL.
  2774  func ExampleEC2_DescribeNetworkAcls_shared00() {
  2775  	svc := ec2.New(session.New())
  2776  	input := &ec2.DescribeNetworkAclsInput{
  2777  		NetworkAclIds: []*string{
  2778  			aws.String("acl-5fb85d36"),
  2779  		},
  2780  	}
  2781  
  2782  	result, err := svc.DescribeNetworkAcls(input)
  2783  	if err != nil {
  2784  		if aerr, ok := err.(awserr.Error); ok {
  2785  			switch aerr.Code() {
  2786  			default:
  2787  				fmt.Println(aerr.Error())
  2788  			}
  2789  		} else {
  2790  			// Print the error, cast err to awserr.Error to get the Code and
  2791  			// Message from an error.
  2792  			fmt.Println(err.Error())
  2793  		}
  2794  		return
  2795  	}
  2796  
  2797  	fmt.Println(result)
  2798  }
  2799  
  2800  // To describe the attachment attribute of a network interface
  2801  //
  2802  // This example describes the attachment attribute of the specified network interface.
  2803  func ExampleEC2_DescribeNetworkInterfaceAttribute_shared00() {
  2804  	svc := ec2.New(session.New())
  2805  	input := &ec2.DescribeNetworkInterfaceAttributeInput{
  2806  		Attribute:          aws.String("attachment"),
  2807  		NetworkInterfaceId: aws.String("eni-686ea200"),
  2808  	}
  2809  
  2810  	result, err := svc.DescribeNetworkInterfaceAttribute(input)
  2811  	if err != nil {
  2812  		if aerr, ok := err.(awserr.Error); ok {
  2813  			switch aerr.Code() {
  2814  			default:
  2815  				fmt.Println(aerr.Error())
  2816  			}
  2817  		} else {
  2818  			// Print the error, cast err to awserr.Error to get the Code and
  2819  			// Message from an error.
  2820  			fmt.Println(err.Error())
  2821  		}
  2822  		return
  2823  	}
  2824  
  2825  	fmt.Println(result)
  2826  }
  2827  
  2828  // To describe the description attribute of a network interface
  2829  //
  2830  // This example describes the description attribute of the specified network interface.
  2831  func ExampleEC2_DescribeNetworkInterfaceAttribute_shared01() {
  2832  	svc := ec2.New(session.New())
  2833  	input := &ec2.DescribeNetworkInterfaceAttributeInput{
  2834  		Attribute:          aws.String("description"),
  2835  		NetworkInterfaceId: aws.String("eni-686ea200"),
  2836  	}
  2837  
  2838  	result, err := svc.DescribeNetworkInterfaceAttribute(input)
  2839  	if err != nil {
  2840  		if aerr, ok := err.(awserr.Error); ok {
  2841  			switch aerr.Code() {
  2842  			default:
  2843  				fmt.Println(aerr.Error())
  2844  			}
  2845  		} else {
  2846  			// Print the error, cast err to awserr.Error to get the Code and
  2847  			// Message from an error.
  2848  			fmt.Println(err.Error())
  2849  		}
  2850  		return
  2851  	}
  2852  
  2853  	fmt.Println(result)
  2854  }
  2855  
  2856  // To describe the groupSet attribute of a network interface
  2857  //
  2858  // This example describes the groupSet attribute of the specified network interface.
  2859  func ExampleEC2_DescribeNetworkInterfaceAttribute_shared02() {
  2860  	svc := ec2.New(session.New())
  2861  	input := &ec2.DescribeNetworkInterfaceAttributeInput{
  2862  		Attribute:          aws.String("groupSet"),
  2863  		NetworkInterfaceId: aws.String("eni-686ea200"),
  2864  	}
  2865  
  2866  	result, err := svc.DescribeNetworkInterfaceAttribute(input)
  2867  	if err != nil {
  2868  		if aerr, ok := err.(awserr.Error); ok {
  2869  			switch aerr.Code() {
  2870  			default:
  2871  				fmt.Println(aerr.Error())
  2872  			}
  2873  		} else {
  2874  			// Print the error, cast err to awserr.Error to get the Code and
  2875  			// Message from an error.
  2876  			fmt.Println(err.Error())
  2877  		}
  2878  		return
  2879  	}
  2880  
  2881  	fmt.Println(result)
  2882  }
  2883  
  2884  // To describe the sourceDestCheck attribute of a network interface
  2885  //
  2886  // This example describes the sourceDestCheck attribute of the specified network interface.
  2887  func ExampleEC2_DescribeNetworkInterfaceAttribute_shared03() {
  2888  	svc := ec2.New(session.New())
  2889  	input := &ec2.DescribeNetworkInterfaceAttributeInput{
  2890  		Attribute:          aws.String("sourceDestCheck"),
  2891  		NetworkInterfaceId: aws.String("eni-686ea200"),
  2892  	}
  2893  
  2894  	result, err := svc.DescribeNetworkInterfaceAttribute(input)
  2895  	if err != nil {
  2896  		if aerr, ok := err.(awserr.Error); ok {
  2897  			switch aerr.Code() {
  2898  			default:
  2899  				fmt.Println(aerr.Error())
  2900  			}
  2901  		} else {
  2902  			// Print the error, cast err to awserr.Error to get the Code and
  2903  			// Message from an error.
  2904  			fmt.Println(err.Error())
  2905  		}
  2906  		return
  2907  	}
  2908  
  2909  	fmt.Println(result)
  2910  }
  2911  
  2912  // To describe a network interface
  2913  //
  2914  
  2915  func ExampleEC2_DescribeNetworkInterfaces_shared00() {
  2916  	svc := ec2.New(session.New())
  2917  	input := &ec2.DescribeNetworkInterfacesInput{
  2918  		NetworkInterfaceIds: []*string{
  2919  			aws.String("eni-e5aa89a3"),
  2920  		},
  2921  	}
  2922  
  2923  	result, err := svc.DescribeNetworkInterfaces(input)
  2924  	if err != nil {
  2925  		if aerr, ok := err.(awserr.Error); ok {
  2926  			switch aerr.Code() {
  2927  			default:
  2928  				fmt.Println(aerr.Error())
  2929  			}
  2930  		} else {
  2931  			// Print the error, cast err to awserr.Error to get the Code and
  2932  			// Message from an error.
  2933  			fmt.Println(err.Error())
  2934  		}
  2935  		return
  2936  	}
  2937  
  2938  	fmt.Println(result)
  2939  }
  2940  
  2941  // To describe your regions
  2942  //
  2943  // This example describes all the regions that are available to you.
  2944  func ExampleEC2_DescribeRegions_shared00() {
  2945  	svc := ec2.New(session.New())
  2946  	input := &ec2.DescribeRegionsInput{}
  2947  
  2948  	result, err := svc.DescribeRegions(input)
  2949  	if err != nil {
  2950  		if aerr, ok := err.(awserr.Error); ok {
  2951  			switch aerr.Code() {
  2952  			default:
  2953  				fmt.Println(aerr.Error())
  2954  			}
  2955  		} else {
  2956  			// Print the error, cast err to awserr.Error to get the Code and
  2957  			// Message from an error.
  2958  			fmt.Println(err.Error())
  2959  		}
  2960  		return
  2961  	}
  2962  
  2963  	fmt.Println(result)
  2964  }
  2965  
  2966  // To describe a route table
  2967  //
  2968  // This example describes the specified route table.
  2969  func ExampleEC2_DescribeRouteTables_shared00() {
  2970  	svc := ec2.New(session.New())
  2971  	input := &ec2.DescribeRouteTablesInput{
  2972  		RouteTableIds: []*string{
  2973  			aws.String("rtb-1f382e7d"),
  2974  		},
  2975  	}
  2976  
  2977  	result, err := svc.DescribeRouteTables(input)
  2978  	if err != nil {
  2979  		if aerr, ok := err.(awserr.Error); ok {
  2980  			switch aerr.Code() {
  2981  			default:
  2982  				fmt.Println(aerr.Error())
  2983  			}
  2984  		} else {
  2985  			// Print the error, cast err to awserr.Error to get the Code and
  2986  			// Message from an error.
  2987  			fmt.Println(err.Error())
  2988  		}
  2989  		return
  2990  	}
  2991  
  2992  	fmt.Println(result)
  2993  }
  2994  
  2995  // To describe an available schedule
  2996  //
  2997  // This example describes a schedule that occurs every week on Sunday, starting on the
  2998  // specified date. Note that the output contains a single schedule as an example.
  2999  func ExampleEC2_DescribeScheduledInstanceAvailability_shared00() {
  3000  	svc := ec2.New(session.New())
  3001  	input := &ec2.DescribeScheduledInstanceAvailabilityInput{
  3002  		FirstSlotStartTimeRange: &ec2.SlotDateTimeRangeRequest{
  3003  			EarliestTime: parseTime("2006-01-02T15:04:05.999999999Z", "2016-01-31T00:00:00Z"),
  3004  			LatestTime:   parseTime("2006-01-02T15:04:05.999999999Z", "2016-01-31T04:00:00Z"),
  3005  		},
  3006  		Recurrence: &ec2.ScheduledInstanceRecurrenceRequest{
  3007  			Frequency: aws.String("Weekly"),
  3008  			Interval:  aws.Int64(1),
  3009  			OccurrenceDays: []*int64{
  3010  				aws.Int64(1),
  3011  			},
  3012  		},
  3013  	}
  3014  
  3015  	result, err := svc.DescribeScheduledInstanceAvailability(input)
  3016  	if err != nil {
  3017  		if aerr, ok := err.(awserr.Error); ok {
  3018  			switch aerr.Code() {
  3019  			default:
  3020  				fmt.Println(aerr.Error())
  3021  			}
  3022  		} else {
  3023  			// Print the error, cast err to awserr.Error to get the Code and
  3024  			// Message from an error.
  3025  			fmt.Println(err.Error())
  3026  		}
  3027  		return
  3028  	}
  3029  
  3030  	fmt.Println(result)
  3031  }
  3032  
  3033  // To describe your Scheduled Instances
  3034  //
  3035  // This example describes the specified Scheduled Instance.
  3036  func ExampleEC2_DescribeScheduledInstances_shared00() {
  3037  	svc := ec2.New(session.New())
  3038  	input := &ec2.DescribeScheduledInstancesInput{
  3039  		ScheduledInstanceIds: []*string{
  3040  			aws.String("sci-1234-1234-1234-1234-123456789012"),
  3041  		},
  3042  	}
  3043  
  3044  	result, err := svc.DescribeScheduledInstances(input)
  3045  	if err != nil {
  3046  		if aerr, ok := err.(awserr.Error); ok {
  3047  			switch aerr.Code() {
  3048  			default:
  3049  				fmt.Println(aerr.Error())
  3050  			}
  3051  		} else {
  3052  			// Print the error, cast err to awserr.Error to get the Code and
  3053  			// Message from an error.
  3054  			fmt.Println(err.Error())
  3055  		}
  3056  		return
  3057  	}
  3058  
  3059  	fmt.Println(result)
  3060  }
  3061  
  3062  // To describe security group references
  3063  //
  3064  // This example describes the security group references for the specified security group.
  3065  func ExampleEC2_DescribeSecurityGroupReferences_shared00() {
  3066  	svc := ec2.New(session.New())
  3067  	input := &ec2.DescribeSecurityGroupReferencesInput{
  3068  		GroupId: []*string{
  3069  			aws.String("sg-903004f8"),
  3070  		},
  3071  	}
  3072  
  3073  	result, err := svc.DescribeSecurityGroupReferences(input)
  3074  	if err != nil {
  3075  		if aerr, ok := err.(awserr.Error); ok {
  3076  			switch aerr.Code() {
  3077  			default:
  3078  				fmt.Println(aerr.Error())
  3079  			}
  3080  		} else {
  3081  			// Print the error, cast err to awserr.Error to get the Code and
  3082  			// Message from an error.
  3083  			fmt.Println(err.Error())
  3084  		}
  3085  		return
  3086  	}
  3087  
  3088  	fmt.Println(result)
  3089  }
  3090  
  3091  // To describe a security group
  3092  //
  3093  // This example describes the specified security group.
  3094  func ExampleEC2_DescribeSecurityGroups_shared00() {
  3095  	svc := ec2.New(session.New())
  3096  	input := &ec2.DescribeSecurityGroupsInput{
  3097  		GroupIds: []*string{
  3098  			aws.String("sg-903004f8"),
  3099  		},
  3100  	}
  3101  
  3102  	result, err := svc.DescribeSecurityGroups(input)
  3103  	if err != nil {
  3104  		if aerr, ok := err.(awserr.Error); ok {
  3105  			switch aerr.Code() {
  3106  			default:
  3107  				fmt.Println(aerr.Error())
  3108  			}
  3109  		} else {
  3110  			// Print the error, cast err to awserr.Error to get the Code and
  3111  			// Message from an error.
  3112  			fmt.Println(err.Error())
  3113  		}
  3114  		return
  3115  	}
  3116  
  3117  	fmt.Println(result)
  3118  }
  3119  
  3120  // To describe a tagged security group
  3121  //
  3122  // This example describes the security groups that include the specified tag (Purpose=test).
  3123  func ExampleEC2_DescribeSecurityGroups_shared01() {
  3124  	svc := ec2.New(session.New())
  3125  	input := &ec2.DescribeSecurityGroupsInput{
  3126  		Filters: []*ec2.Filter{
  3127  			{
  3128  				Name: aws.String("tag:Purpose"),
  3129  				Values: []*string{
  3130  					aws.String("test"),
  3131  				},
  3132  			},
  3133  		},
  3134  	}
  3135  
  3136  	result, err := svc.DescribeSecurityGroups(input)
  3137  	if err != nil {
  3138  		if aerr, ok := err.(awserr.Error); ok {
  3139  			switch aerr.Code() {
  3140  			default:
  3141  				fmt.Println(aerr.Error())
  3142  			}
  3143  		} else {
  3144  			// Print the error, cast err to awserr.Error to get the Code and
  3145  			// Message from an error.
  3146  			fmt.Println(err.Error())
  3147  		}
  3148  		return
  3149  	}
  3150  
  3151  	fmt.Println(result)
  3152  }
  3153  
  3154  // To describe snapshot attributes
  3155  //
  3156  // This example describes the ``createVolumePermission`` attribute on a snapshot with
  3157  // the snapshot ID of ``snap-066877671789bd71b``.
  3158  func ExampleEC2_DescribeSnapshotAttribute_shared00() {
  3159  	svc := ec2.New(session.New())
  3160  	input := &ec2.DescribeSnapshotAttributeInput{
  3161  		Attribute:  aws.String("createVolumePermission"),
  3162  		SnapshotId: aws.String("snap-066877671789bd71b"),
  3163  	}
  3164  
  3165  	result, err := svc.DescribeSnapshotAttribute(input)
  3166  	if err != nil {
  3167  		if aerr, ok := err.(awserr.Error); ok {
  3168  			switch aerr.Code() {
  3169  			default:
  3170  				fmt.Println(aerr.Error())
  3171  			}
  3172  		} else {
  3173  			// Print the error, cast err to awserr.Error to get the Code and
  3174  			// Message from an error.
  3175  			fmt.Println(err.Error())
  3176  		}
  3177  		return
  3178  	}
  3179  
  3180  	fmt.Println(result)
  3181  }
  3182  
  3183  // To describe a snapshot
  3184  //
  3185  // This example describes a snapshot with the snapshot ID of ``snap-1234567890abcdef0``.
  3186  func ExampleEC2_DescribeSnapshots_shared00() {
  3187  	svc := ec2.New(session.New())
  3188  	input := &ec2.DescribeSnapshotsInput{
  3189  		SnapshotIds: []*string{
  3190  			aws.String("snap-1234567890abcdef0"),
  3191  		},
  3192  	}
  3193  
  3194  	result, err := svc.DescribeSnapshots(input)
  3195  	if err != nil {
  3196  		if aerr, ok := err.(awserr.Error); ok {
  3197  			switch aerr.Code() {
  3198  			default:
  3199  				fmt.Println(aerr.Error())
  3200  			}
  3201  		} else {
  3202  			// Print the error, cast err to awserr.Error to get the Code and
  3203  			// Message from an error.
  3204  			fmt.Println(err.Error())
  3205  		}
  3206  		return
  3207  	}
  3208  
  3209  	fmt.Println(result)
  3210  }
  3211  
  3212  // To describe snapshots using filters
  3213  //
  3214  // This example describes all snapshots owned by the ID 012345678910 that are in the
  3215  // ``pending`` status.
  3216  func ExampleEC2_DescribeSnapshots_shared01() {
  3217  	svc := ec2.New(session.New())
  3218  	input := &ec2.DescribeSnapshotsInput{
  3219  		Filters: []*ec2.Filter{
  3220  			{
  3221  				Name: aws.String("status"),
  3222  				Values: []*string{
  3223  					aws.String("pending"),
  3224  				},
  3225  			},
  3226  		},
  3227  		OwnerIds: []*string{
  3228  			aws.String("012345678910"),
  3229  		},
  3230  	}
  3231  
  3232  	result, err := svc.DescribeSnapshots(input)
  3233  	if err != nil {
  3234  		if aerr, ok := err.(awserr.Error); ok {
  3235  			switch aerr.Code() {
  3236  			default:
  3237  				fmt.Println(aerr.Error())
  3238  			}
  3239  		} else {
  3240  			// Print the error, cast err to awserr.Error to get the Code and
  3241  			// Message from an error.
  3242  			fmt.Println(err.Error())
  3243  		}
  3244  		return
  3245  	}
  3246  
  3247  	fmt.Println(result)
  3248  }
  3249  
  3250  // To describe the datafeed for your AWS account
  3251  //
  3252  // This example describes the Spot Instance datafeed subscription for your AWS account.
  3253  func ExampleEC2_DescribeSpotDatafeedSubscription_shared00() {
  3254  	svc := ec2.New(session.New())
  3255  	input := &ec2.DescribeSpotDatafeedSubscriptionInput{}
  3256  
  3257  	result, err := svc.DescribeSpotDatafeedSubscription(input)
  3258  	if err != nil {
  3259  		if aerr, ok := err.(awserr.Error); ok {
  3260  			switch aerr.Code() {
  3261  			default:
  3262  				fmt.Println(aerr.Error())
  3263  			}
  3264  		} else {
  3265  			// Print the error, cast err to awserr.Error to get the Code and
  3266  			// Message from an error.
  3267  			fmt.Println(err.Error())
  3268  		}
  3269  		return
  3270  	}
  3271  
  3272  	fmt.Println(result)
  3273  }
  3274  
  3275  // To describe the Spot Instances associated with a Spot fleet
  3276  //
  3277  // This example lists the Spot Instances associated with the specified Spot fleet.
  3278  func ExampleEC2_DescribeSpotFleetInstances_shared00() {
  3279  	svc := ec2.New(session.New())
  3280  	input := &ec2.DescribeSpotFleetInstancesInput{
  3281  		SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
  3282  	}
  3283  
  3284  	result, err := svc.DescribeSpotFleetInstances(input)
  3285  	if err != nil {
  3286  		if aerr, ok := err.(awserr.Error); ok {
  3287  			switch aerr.Code() {
  3288  			default:
  3289  				fmt.Println(aerr.Error())
  3290  			}
  3291  		} else {
  3292  			// Print the error, cast err to awserr.Error to get the Code and
  3293  			// Message from an error.
  3294  			fmt.Println(err.Error())
  3295  		}
  3296  		return
  3297  	}
  3298  
  3299  	fmt.Println(result)
  3300  }
  3301  
  3302  // To describe Spot fleet history
  3303  //
  3304  // This example returns the history for the specified Spot fleet starting at the specified
  3305  // time.
  3306  func ExampleEC2_DescribeSpotFleetRequestHistory_shared00() {
  3307  	svc := ec2.New(session.New())
  3308  	input := &ec2.DescribeSpotFleetRequestHistoryInput{
  3309  		SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
  3310  		StartTime:          parseTime("2006-01-02T15:04:05.999999999Z", "2015-05-26T00:00:00Z"),
  3311  	}
  3312  
  3313  	result, err := svc.DescribeSpotFleetRequestHistory(input)
  3314  	if err != nil {
  3315  		if aerr, ok := err.(awserr.Error); ok {
  3316  			switch aerr.Code() {
  3317  			default:
  3318  				fmt.Println(aerr.Error())
  3319  			}
  3320  		} else {
  3321  			// Print the error, cast err to awserr.Error to get the Code and
  3322  			// Message from an error.
  3323  			fmt.Println(err.Error())
  3324  		}
  3325  		return
  3326  	}
  3327  
  3328  	fmt.Println(result)
  3329  }
  3330  
  3331  // To describe a Spot fleet request
  3332  //
  3333  // This example describes the specified Spot fleet request.
  3334  func ExampleEC2_DescribeSpotFleetRequests_shared00() {
  3335  	svc := ec2.New(session.New())
  3336  	input := &ec2.DescribeSpotFleetRequestsInput{
  3337  		SpotFleetRequestIds: []*string{
  3338  			aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
  3339  		},
  3340  	}
  3341  
  3342  	result, err := svc.DescribeSpotFleetRequests(input)
  3343  	if err != nil {
  3344  		if aerr, ok := err.(awserr.Error); ok {
  3345  			switch aerr.Code() {
  3346  			default:
  3347  				fmt.Println(aerr.Error())
  3348  			}
  3349  		} else {
  3350  			// Print the error, cast err to awserr.Error to get the Code and
  3351  			// Message from an error.
  3352  			fmt.Println(err.Error())
  3353  		}
  3354  		return
  3355  	}
  3356  
  3357  	fmt.Println(result)
  3358  }
  3359  
  3360  // To describe a Spot Instance request
  3361  //
  3362  // This example describes the specified Spot Instance request.
  3363  func ExampleEC2_DescribeSpotInstanceRequests_shared00() {
  3364  	svc := ec2.New(session.New())
  3365  	input := &ec2.DescribeSpotInstanceRequestsInput{
  3366  		SpotInstanceRequestIds: []*string{
  3367  			aws.String("sir-08b93456"),
  3368  		},
  3369  	}
  3370  
  3371  	result, err := svc.DescribeSpotInstanceRequests(input)
  3372  	if err != nil {
  3373  		if aerr, ok := err.(awserr.Error); ok {
  3374  			switch aerr.Code() {
  3375  			default:
  3376  				fmt.Println(aerr.Error())
  3377  			}
  3378  		} else {
  3379  			// Print the error, cast err to awserr.Error to get the Code and
  3380  			// Message from an error.
  3381  			fmt.Println(err.Error())
  3382  		}
  3383  		return
  3384  	}
  3385  
  3386  	fmt.Println(result)
  3387  }
  3388  
  3389  // To describe Spot price history for Linux/UNIX (Amazon VPC)
  3390  //
  3391  // This example returns the Spot Price history for m1.xlarge, Linux/UNIX (Amazon VPC)
  3392  // instances for a particular day in January.
  3393  func ExampleEC2_DescribeSpotPriceHistory_shared00() {
  3394  	svc := ec2.New(session.New())
  3395  	input := &ec2.DescribeSpotPriceHistoryInput{
  3396  		EndTime: parseTime("2006-01-02T15:04:05.999999999Z", "2014-01-06T08:09:10"),
  3397  		InstanceTypes: []*string{
  3398  			aws.String("m1.xlarge"),
  3399  		},
  3400  		ProductDescriptions: []*string{
  3401  			aws.String("Linux/UNIX (Amazon VPC)"),
  3402  		},
  3403  		StartTime: parseTime("2006-01-02T15:04:05.999999999Z", "2014-01-06T07:08:09"),
  3404  	}
  3405  
  3406  	result, err := svc.DescribeSpotPriceHistory(input)
  3407  	if err != nil {
  3408  		if aerr, ok := err.(awserr.Error); ok {
  3409  			switch aerr.Code() {
  3410  			default:
  3411  				fmt.Println(aerr.Error())
  3412  			}
  3413  		} else {
  3414  			// Print the error, cast err to awserr.Error to get the Code and
  3415  			// Message from an error.
  3416  			fmt.Println(err.Error())
  3417  		}
  3418  		return
  3419  	}
  3420  
  3421  	fmt.Println(result)
  3422  }
  3423  
  3424  // To describe the subnets for a VPC
  3425  //
  3426  // This example describes the subnets for the specified VPC.
  3427  func ExampleEC2_DescribeSubnets_shared00() {
  3428  	svc := ec2.New(session.New())
  3429  	input := &ec2.DescribeSubnetsInput{
  3430  		Filters: []*ec2.Filter{
  3431  			{
  3432  				Name: aws.String("vpc-id"),
  3433  				Values: []*string{
  3434  					aws.String("vpc-a01106c2"),
  3435  				},
  3436  			},
  3437  		},
  3438  	}
  3439  
  3440  	result, err := svc.DescribeSubnets(input)
  3441  	if err != nil {
  3442  		if aerr, ok := err.(awserr.Error); ok {
  3443  			switch aerr.Code() {
  3444  			default:
  3445  				fmt.Println(aerr.Error())
  3446  			}
  3447  		} else {
  3448  			// Print the error, cast err to awserr.Error to get the Code and
  3449  			// Message from an error.
  3450  			fmt.Println(err.Error())
  3451  		}
  3452  		return
  3453  	}
  3454  
  3455  	fmt.Println(result)
  3456  }
  3457  
  3458  // To describe the tags for a single resource
  3459  //
  3460  // This example describes the tags for the specified instance.
  3461  func ExampleEC2_DescribeTags_shared00() {
  3462  	svc := ec2.New(session.New())
  3463  	input := &ec2.DescribeTagsInput{
  3464  		Filters: []*ec2.Filter{
  3465  			{
  3466  				Name: aws.String("resource-id"),
  3467  				Values: []*string{
  3468  					aws.String("i-1234567890abcdef8"),
  3469  				},
  3470  			},
  3471  		},
  3472  	}
  3473  
  3474  	result, err := svc.DescribeTags(input)
  3475  	if err != nil {
  3476  		if aerr, ok := err.(awserr.Error); ok {
  3477  			switch aerr.Code() {
  3478  			default:
  3479  				fmt.Println(aerr.Error())
  3480  			}
  3481  		} else {
  3482  			// Print the error, cast err to awserr.Error to get the Code and
  3483  			// Message from an error.
  3484  			fmt.Println(err.Error())
  3485  		}
  3486  		return
  3487  	}
  3488  
  3489  	fmt.Println(result)
  3490  }
  3491  
  3492  // To describe a volume attribute
  3493  //
  3494  // This example describes the ``autoEnableIo`` attribute of the volume with the ID ``vol-049df61146c4d7901``.
  3495  func ExampleEC2_DescribeVolumeAttribute_shared00() {
  3496  	svc := ec2.New(session.New())
  3497  	input := &ec2.DescribeVolumeAttributeInput{
  3498  		Attribute: aws.String("autoEnableIO"),
  3499  		VolumeId:  aws.String("vol-049df61146c4d7901"),
  3500  	}
  3501  
  3502  	result, err := svc.DescribeVolumeAttribute(input)
  3503  	if err != nil {
  3504  		if aerr, ok := err.(awserr.Error); ok {
  3505  			switch aerr.Code() {
  3506  			default:
  3507  				fmt.Println(aerr.Error())
  3508  			}
  3509  		} else {
  3510  			// Print the error, cast err to awserr.Error to get the Code and
  3511  			// Message from an error.
  3512  			fmt.Println(err.Error())
  3513  		}
  3514  		return
  3515  	}
  3516  
  3517  	fmt.Println(result)
  3518  }
  3519  
  3520  // To describe the status of a single volume
  3521  //
  3522  // This example describes the status for the volume ``vol-1234567890abcdef0``.
  3523  func ExampleEC2_DescribeVolumeStatus_shared00() {
  3524  	svc := ec2.New(session.New())
  3525  	input := &ec2.DescribeVolumeStatusInput{
  3526  		VolumeIds: []*string{
  3527  			aws.String("vol-1234567890abcdef0"),
  3528  		},
  3529  	}
  3530  
  3531  	result, err := svc.DescribeVolumeStatus(input)
  3532  	if err != nil {
  3533  		if aerr, ok := err.(awserr.Error); ok {
  3534  			switch aerr.Code() {
  3535  			default:
  3536  				fmt.Println(aerr.Error())
  3537  			}
  3538  		} else {
  3539  			// Print the error, cast err to awserr.Error to get the Code and
  3540  			// Message from an error.
  3541  			fmt.Println(err.Error())
  3542  		}
  3543  		return
  3544  	}
  3545  
  3546  	fmt.Println(result)
  3547  }
  3548  
  3549  // To describe the status of impaired volumes
  3550  //
  3551  // This example describes the status for all volumes that are impaired. In this example
  3552  // output, there are no impaired volumes.
  3553  func ExampleEC2_DescribeVolumeStatus_shared01() {
  3554  	svc := ec2.New(session.New())
  3555  	input := &ec2.DescribeVolumeStatusInput{
  3556  		Filters: []*ec2.Filter{
  3557  			{
  3558  				Name: aws.String("volume-status.status"),
  3559  				Values: []*string{
  3560  					aws.String("impaired"),
  3561  				},
  3562  			},
  3563  		},
  3564  	}
  3565  
  3566  	result, err := svc.DescribeVolumeStatus(input)
  3567  	if err != nil {
  3568  		if aerr, ok := err.(awserr.Error); ok {
  3569  			switch aerr.Code() {
  3570  			default:
  3571  				fmt.Println(aerr.Error())
  3572  			}
  3573  		} else {
  3574  			// Print the error, cast err to awserr.Error to get the Code and
  3575  			// Message from an error.
  3576  			fmt.Println(err.Error())
  3577  		}
  3578  		return
  3579  	}
  3580  
  3581  	fmt.Println(result)
  3582  }
  3583  
  3584  // To describe all volumes
  3585  //
  3586  // This example describes all of your volumes in the default region.
  3587  func ExampleEC2_DescribeVolumes_shared00() {
  3588  	svc := ec2.New(session.New())
  3589  	input := &ec2.DescribeVolumesInput{}
  3590  
  3591  	result, err := svc.DescribeVolumes(input)
  3592  	if err != nil {
  3593  		if aerr, ok := err.(awserr.Error); ok {
  3594  			switch aerr.Code() {
  3595  			default:
  3596  				fmt.Println(aerr.Error())
  3597  			}
  3598  		} else {
  3599  			// Print the error, cast err to awserr.Error to get the Code and
  3600  			// Message from an error.
  3601  			fmt.Println(err.Error())
  3602  		}
  3603  		return
  3604  	}
  3605  
  3606  	fmt.Println(result)
  3607  }
  3608  
  3609  // To describe volumes that are attached to a specific instance
  3610  //
  3611  // This example describes all volumes that are both attached to the instance with the
  3612  // ID i-1234567890abcdef0 and set to delete when the instance terminates.
  3613  func ExampleEC2_DescribeVolumes_shared01() {
  3614  	svc := ec2.New(session.New())
  3615  	input := &ec2.DescribeVolumesInput{
  3616  		Filters: []*ec2.Filter{
  3617  			{
  3618  				Name: aws.String("attachment.instance-id"),
  3619  				Values: []*string{
  3620  					aws.String("i-1234567890abcdef0"),
  3621  				},
  3622  			},
  3623  			{
  3624  				Name: aws.String("attachment.delete-on-termination"),
  3625  				Values: []*string{
  3626  					aws.String("true"),
  3627  				},
  3628  			},
  3629  		},
  3630  	}
  3631  
  3632  	result, err := svc.DescribeVolumes(input)
  3633  	if err != nil {
  3634  		if aerr, ok := err.(awserr.Error); ok {
  3635  			switch aerr.Code() {
  3636  			default:
  3637  				fmt.Println(aerr.Error())
  3638  			}
  3639  		} else {
  3640  			// Print the error, cast err to awserr.Error to get the Code and
  3641  			// Message from an error.
  3642  			fmt.Println(err.Error())
  3643  		}
  3644  		return
  3645  	}
  3646  
  3647  	fmt.Println(result)
  3648  }
  3649  
  3650  // To describe the enableDnsSupport attribute
  3651  //
  3652  // This example describes the enableDnsSupport attribute. This attribute indicates whether
  3653  // DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS
  3654  // server resolves DNS hostnames for your instances to their corresponding IP addresses;
  3655  // otherwise, it does not.
  3656  func ExampleEC2_DescribeVpcAttribute_shared00() {
  3657  	svc := ec2.New(session.New())
  3658  	input := &ec2.DescribeVpcAttributeInput{
  3659  		Attribute: aws.String("enableDnsSupport"),
  3660  		VpcId:     aws.String("vpc-a01106c2"),
  3661  	}
  3662  
  3663  	result, err := svc.DescribeVpcAttribute(input)
  3664  	if err != nil {
  3665  		if aerr, ok := err.(awserr.Error); ok {
  3666  			switch aerr.Code() {
  3667  			default:
  3668  				fmt.Println(aerr.Error())
  3669  			}
  3670  		} else {
  3671  			// Print the error, cast err to awserr.Error to get the Code and
  3672  			// Message from an error.
  3673  			fmt.Println(err.Error())
  3674  		}
  3675  		return
  3676  	}
  3677  
  3678  	fmt.Println(result)
  3679  }
  3680  
  3681  // To describe the enableDnsHostnames attribute
  3682  //
  3683  // This example describes the enableDnsHostnames attribute. This attribute indicates
  3684  // whether the instances launched in the VPC get DNS hostnames. If this attribute is
  3685  // true, instances in the VPC get DNS hostnames; otherwise, they do not.
  3686  func ExampleEC2_DescribeVpcAttribute_shared01() {
  3687  	svc := ec2.New(session.New())
  3688  	input := &ec2.DescribeVpcAttributeInput{
  3689  		Attribute: aws.String("enableDnsHostnames"),
  3690  		VpcId:     aws.String("vpc-a01106c2"),
  3691  	}
  3692  
  3693  	result, err := svc.DescribeVpcAttribute(input)
  3694  	if err != nil {
  3695  		if aerr, ok := err.(awserr.Error); ok {
  3696  			switch aerr.Code() {
  3697  			default:
  3698  				fmt.Println(aerr.Error())
  3699  			}
  3700  		} else {
  3701  			// Print the error, cast err to awserr.Error to get the Code and
  3702  			// Message from an error.
  3703  			fmt.Println(err.Error())
  3704  		}
  3705  		return
  3706  	}
  3707  
  3708  	fmt.Println(result)
  3709  }
  3710  
  3711  // To describe a VPC
  3712  //
  3713  // This example describes the specified VPC.
  3714  func ExampleEC2_DescribeVpcs_shared00() {
  3715  	svc := ec2.New(session.New())
  3716  	input := &ec2.DescribeVpcsInput{
  3717  		VpcIds: []*string{
  3718  			aws.String("vpc-a01106c2"),
  3719  		},
  3720  	}
  3721  
  3722  	result, err := svc.DescribeVpcs(input)
  3723  	if err != nil {
  3724  		if aerr, ok := err.(awserr.Error); ok {
  3725  			switch aerr.Code() {
  3726  			default:
  3727  				fmt.Println(aerr.Error())
  3728  			}
  3729  		} else {
  3730  			// Print the error, cast err to awserr.Error to get the Code and
  3731  			// Message from an error.
  3732  			fmt.Println(err.Error())
  3733  		}
  3734  		return
  3735  	}
  3736  
  3737  	fmt.Println(result)
  3738  }
  3739  
  3740  // To detach an Internet gateway from a VPC
  3741  //
  3742  // This example detaches the specified Internet gateway from the specified VPC.
  3743  func ExampleEC2_DetachInternetGateway_shared00() {
  3744  	svc := ec2.New(session.New())
  3745  	input := &ec2.DetachInternetGatewayInput{
  3746  		InternetGatewayId: aws.String("igw-c0a643a9"),
  3747  		VpcId:             aws.String("vpc-a01106c2"),
  3748  	}
  3749  
  3750  	result, err := svc.DetachInternetGateway(input)
  3751  	if err != nil {
  3752  		if aerr, ok := err.(awserr.Error); ok {
  3753  			switch aerr.Code() {
  3754  			default:
  3755  				fmt.Println(aerr.Error())
  3756  			}
  3757  		} else {
  3758  			// Print the error, cast err to awserr.Error to get the Code and
  3759  			// Message from an error.
  3760  			fmt.Println(err.Error())
  3761  		}
  3762  		return
  3763  	}
  3764  
  3765  	fmt.Println(result)
  3766  }
  3767  
  3768  // To detach a network interface from an instance
  3769  //
  3770  // This example detaches the specified network interface from its attached instance.
  3771  func ExampleEC2_DetachNetworkInterface_shared00() {
  3772  	svc := ec2.New(session.New())
  3773  	input := &ec2.DetachNetworkInterfaceInput{
  3774  		AttachmentId: aws.String("eni-attach-66c4350a"),
  3775  	}
  3776  
  3777  	result, err := svc.DetachNetworkInterface(input)
  3778  	if err != nil {
  3779  		if aerr, ok := err.(awserr.Error); ok {
  3780  			switch aerr.Code() {
  3781  			default:
  3782  				fmt.Println(aerr.Error())
  3783  			}
  3784  		} else {
  3785  			// Print the error, cast err to awserr.Error to get the Code and
  3786  			// Message from an error.
  3787  			fmt.Println(err.Error())
  3788  		}
  3789  		return
  3790  	}
  3791  
  3792  	fmt.Println(result)
  3793  }
  3794  
  3795  // To detach a volume from an instance
  3796  //
  3797  // This example detaches the volume (``vol-049df61146c4d7901``) from the instance it
  3798  // is attached to.
  3799  func ExampleEC2_DetachVolume_shared00() {
  3800  	svc := ec2.New(session.New())
  3801  	input := &ec2.DetachVolumeInput{
  3802  		VolumeId: aws.String("vol-1234567890abcdef0"),
  3803  	}
  3804  
  3805  	result, err := svc.DetachVolume(input)
  3806  	if err != nil {
  3807  		if aerr, ok := err.(awserr.Error); ok {
  3808  			switch aerr.Code() {
  3809  			default:
  3810  				fmt.Println(aerr.Error())
  3811  			}
  3812  		} else {
  3813  			// Print the error, cast err to awserr.Error to get the Code and
  3814  			// Message from an error.
  3815  			fmt.Println(err.Error())
  3816  		}
  3817  		return
  3818  	}
  3819  
  3820  	fmt.Println(result)
  3821  }
  3822  
  3823  // To disable route propagation
  3824  //
  3825  // This example disables the specified virtual private gateway from propagating static
  3826  // routes to the specified route table.
  3827  func ExampleEC2_DisableVgwRoutePropagation_shared00() {
  3828  	svc := ec2.New(session.New())
  3829  	input := &ec2.DisableVgwRoutePropagationInput{
  3830  		GatewayId:    aws.String("vgw-9a4cacf3"),
  3831  		RouteTableId: aws.String("rtb-22574640"),
  3832  	}
  3833  
  3834  	result, err := svc.DisableVgwRoutePropagation(input)
  3835  	if err != nil {
  3836  		if aerr, ok := err.(awserr.Error); ok {
  3837  			switch aerr.Code() {
  3838  			default:
  3839  				fmt.Println(aerr.Error())
  3840  			}
  3841  		} else {
  3842  			// Print the error, cast err to awserr.Error to get the Code and
  3843  			// Message from an error.
  3844  			fmt.Println(err.Error())
  3845  		}
  3846  		return
  3847  	}
  3848  
  3849  	fmt.Println(result)
  3850  }
  3851  
  3852  // To disassociate an Elastic IP address in EC2-VPC
  3853  //
  3854  // This example disassociates an Elastic IP address from an instance in a VPC.
  3855  func ExampleEC2_DisassociateAddress_shared00() {
  3856  	svc := ec2.New(session.New())
  3857  	input := &ec2.DisassociateAddressInput{
  3858  		AssociationId: aws.String("eipassoc-2bebb745"),
  3859  	}
  3860  
  3861  	result, err := svc.DisassociateAddress(input)
  3862  	if err != nil {
  3863  		if aerr, ok := err.(awserr.Error); ok {
  3864  			switch aerr.Code() {
  3865  			default:
  3866  				fmt.Println(aerr.Error())
  3867  			}
  3868  		} else {
  3869  			// Print the error, cast err to awserr.Error to get the Code and
  3870  			// Message from an error.
  3871  			fmt.Println(err.Error())
  3872  		}
  3873  		return
  3874  	}
  3875  
  3876  	fmt.Println(result)
  3877  }
  3878  
  3879  // To disassociate an Elastic IP addresses in EC2-Classic
  3880  //
  3881  // This example disassociates an Elastic IP address from an instance in EC2-Classic.
  3882  func ExampleEC2_DisassociateAddress_shared01() {
  3883  	svc := ec2.New(session.New())
  3884  	input := &ec2.DisassociateAddressInput{
  3885  		PublicIp: aws.String("198.51.100.0"),
  3886  	}
  3887  
  3888  	result, err := svc.DisassociateAddress(input)
  3889  	if err != nil {
  3890  		if aerr, ok := err.(awserr.Error); ok {
  3891  			switch aerr.Code() {
  3892  			default:
  3893  				fmt.Println(aerr.Error())
  3894  			}
  3895  		} else {
  3896  			// Print the error, cast err to awserr.Error to get the Code and
  3897  			// Message from an error.
  3898  			fmt.Println(err.Error())
  3899  		}
  3900  		return
  3901  	}
  3902  
  3903  	fmt.Println(result)
  3904  }
  3905  
  3906  // To disassociate an IAM instance profile
  3907  //
  3908  // This example disassociates the specified IAM instance profile from an instance.
  3909  func ExampleEC2_DisassociateIamInstanceProfile_shared00() {
  3910  	svc := ec2.New(session.New())
  3911  	input := &ec2.DisassociateIamInstanceProfileInput{
  3912  		AssociationId: aws.String("iip-assoc-05020b59952902f5f"),
  3913  	}
  3914  
  3915  	result, err := svc.DisassociateIamInstanceProfile(input)
  3916  	if err != nil {
  3917  		if aerr, ok := err.(awserr.Error); ok {
  3918  			switch aerr.Code() {
  3919  			default:
  3920  				fmt.Println(aerr.Error())
  3921  			}
  3922  		} else {
  3923  			// Print the error, cast err to awserr.Error to get the Code and
  3924  			// Message from an error.
  3925  			fmt.Println(err.Error())
  3926  		}
  3927  		return
  3928  	}
  3929  
  3930  	fmt.Println(result)
  3931  }
  3932  
  3933  // To disassociate a route table
  3934  //
  3935  // This example disassociates the specified route table from its associated subnet.
  3936  func ExampleEC2_DisassociateRouteTable_shared00() {
  3937  	svc := ec2.New(session.New())
  3938  	input := &ec2.DisassociateRouteTableInput{
  3939  		AssociationId: aws.String("rtbassoc-781d0d1a"),
  3940  	}
  3941  
  3942  	result, err := svc.DisassociateRouteTable(input)
  3943  	if err != nil {
  3944  		if aerr, ok := err.(awserr.Error); ok {
  3945  			switch aerr.Code() {
  3946  			default:
  3947  				fmt.Println(aerr.Error())
  3948  			}
  3949  		} else {
  3950  			// Print the error, cast err to awserr.Error to get the Code and
  3951  			// Message from an error.
  3952  			fmt.Println(err.Error())
  3953  		}
  3954  		return
  3955  	}
  3956  
  3957  	fmt.Println(result)
  3958  }
  3959  
  3960  // To enable route propagation
  3961  //
  3962  // This example enables the specified virtual private gateway to propagate static routes
  3963  // to the specified route table.
  3964  func ExampleEC2_EnableVgwRoutePropagation_shared00() {
  3965  	svc := ec2.New(session.New())
  3966  	input := &ec2.EnableVgwRoutePropagationInput{
  3967  		GatewayId:    aws.String("vgw-9a4cacf3"),
  3968  		RouteTableId: aws.String("rtb-22574640"),
  3969  	}
  3970  
  3971  	result, err := svc.EnableVgwRoutePropagation(input)
  3972  	if err != nil {
  3973  		if aerr, ok := err.(awserr.Error); ok {
  3974  			switch aerr.Code() {
  3975  			default:
  3976  				fmt.Println(aerr.Error())
  3977  			}
  3978  		} else {
  3979  			// Print the error, cast err to awserr.Error to get the Code and
  3980  			// Message from an error.
  3981  			fmt.Println(err.Error())
  3982  		}
  3983  		return
  3984  	}
  3985  
  3986  	fmt.Println(result)
  3987  }
  3988  
  3989  // To enable I/O for a volume
  3990  //
  3991  // This example enables I/O on volume ``vol-1234567890abcdef0``.
  3992  func ExampleEC2_EnableVolumeIO_shared00() {
  3993  	svc := ec2.New(session.New())
  3994  	input := &ec2.EnableVolumeIOInput{
  3995  		VolumeId: aws.String("vol-1234567890abcdef0"),
  3996  	}
  3997  
  3998  	result, err := svc.EnableVolumeIO(input)
  3999  	if err != nil {
  4000  		if aerr, ok := err.(awserr.Error); ok {
  4001  			switch aerr.Code() {
  4002  			default:
  4003  				fmt.Println(aerr.Error())
  4004  			}
  4005  		} else {
  4006  			// Print the error, cast err to awserr.Error to get the Code and
  4007  			// Message from an error.
  4008  			fmt.Println(err.Error())
  4009  		}
  4010  		return
  4011  	}
  4012  
  4013  	fmt.Println(result)
  4014  }
  4015  
  4016  // To get the console output
  4017  //
  4018  // This example gets the console output for the specified instance.
  4019  func ExampleEC2_GetConsoleOutput_shared00() {
  4020  	svc := ec2.New(session.New())
  4021  	input := &ec2.GetConsoleOutputInput{
  4022  		InstanceId: aws.String("i-1234567890abcdef0"),
  4023  	}
  4024  
  4025  	result, err := svc.GetConsoleOutput(input)
  4026  	if err != nil {
  4027  		if aerr, ok := err.(awserr.Error); ok {
  4028  			switch aerr.Code() {
  4029  			default:
  4030  				fmt.Println(aerr.Error())
  4031  			}
  4032  		} else {
  4033  			// Print the error, cast err to awserr.Error to get the Code and
  4034  			// Message from an error.
  4035  			fmt.Println(err.Error())
  4036  		}
  4037  		return
  4038  	}
  4039  
  4040  	fmt.Println(result)
  4041  }
  4042  
  4043  // To get the launch template data for an instance
  4044  //
  4045  // This example gets the launch template data for the specified instance.
  4046  func ExampleEC2_GetLaunchTemplateData_shared00() {
  4047  	svc := ec2.New(session.New())
  4048  	input := &ec2.GetLaunchTemplateDataInput{
  4049  		InstanceId: aws.String("0123d646e8048babc"),
  4050  	}
  4051  
  4052  	result, err := svc.GetLaunchTemplateData(input)
  4053  	if err != nil {
  4054  		if aerr, ok := err.(awserr.Error); ok {
  4055  			switch aerr.Code() {
  4056  			default:
  4057  				fmt.Println(aerr.Error())
  4058  			}
  4059  		} else {
  4060  			// Print the error, cast err to awserr.Error to get the Code and
  4061  			// Message from an error.
  4062  			fmt.Println(err.Error())
  4063  		}
  4064  		return
  4065  	}
  4066  
  4067  	fmt.Println(result)
  4068  }
  4069  
  4070  // To make an AMI public
  4071  //
  4072  // This example makes the specified AMI public.
  4073  func ExampleEC2_ModifyImageAttribute_shared00() {
  4074  	svc := ec2.New(session.New())
  4075  	input := &ec2.ModifyImageAttributeInput{
  4076  		ImageId: aws.String("ami-5731123e"),
  4077  		LaunchPermission: &ec2.LaunchPermissionModifications{
  4078  			Add: []*ec2.LaunchPermission{
  4079  				{
  4080  					Group: aws.String("all"),
  4081  				},
  4082  			},
  4083  		},
  4084  	}
  4085  
  4086  	result, err := svc.ModifyImageAttribute(input)
  4087  	if err != nil {
  4088  		if aerr, ok := err.(awserr.Error); ok {
  4089  			switch aerr.Code() {
  4090  			default:
  4091  				fmt.Println(aerr.Error())
  4092  			}
  4093  		} else {
  4094  			// Print the error, cast err to awserr.Error to get the Code and
  4095  			// Message from an error.
  4096  			fmt.Println(err.Error())
  4097  		}
  4098  		return
  4099  	}
  4100  
  4101  	fmt.Println(result)
  4102  }
  4103  
  4104  // To grant launch permissions
  4105  //
  4106  // This example grants launch permissions for the specified AMI to the specified AWS
  4107  // account.
  4108  func ExampleEC2_ModifyImageAttribute_shared01() {
  4109  	svc := ec2.New(session.New())
  4110  	input := &ec2.ModifyImageAttributeInput{
  4111  		ImageId: aws.String("ami-5731123e"),
  4112  		LaunchPermission: &ec2.LaunchPermissionModifications{
  4113  			Add: []*ec2.LaunchPermission{
  4114  				{
  4115  					UserId: aws.String("123456789012"),
  4116  				},
  4117  			},
  4118  		},
  4119  	}
  4120  
  4121  	result, err := svc.ModifyImageAttribute(input)
  4122  	if err != nil {
  4123  		if aerr, ok := err.(awserr.Error); ok {
  4124  			switch aerr.Code() {
  4125  			default:
  4126  				fmt.Println(aerr.Error())
  4127  			}
  4128  		} else {
  4129  			// Print the error, cast err to awserr.Error to get the Code and
  4130  			// Message from an error.
  4131  			fmt.Println(err.Error())
  4132  		}
  4133  		return
  4134  	}
  4135  
  4136  	fmt.Println(result)
  4137  }
  4138  
  4139  // To modify the instance type
  4140  //
  4141  // This example modifies the instance type of the specified stopped instance.
  4142  func ExampleEC2_ModifyInstanceAttribute_shared00() {
  4143  	svc := ec2.New(session.New())
  4144  	input := &ec2.ModifyInstanceAttributeInput{
  4145  		InstanceId: aws.String("i-1234567890abcdef0"),
  4146  		InstanceType: &ec2.AttributeValue{
  4147  			Value: aws.String("m5.large"),
  4148  		},
  4149  	}
  4150  
  4151  	result, err := svc.ModifyInstanceAttribute(input)
  4152  	if err != nil {
  4153  		if aerr, ok := err.(awserr.Error); ok {
  4154  			switch aerr.Code() {
  4155  			default:
  4156  				fmt.Println(aerr.Error())
  4157  			}
  4158  		} else {
  4159  			// Print the error, cast err to awserr.Error to get the Code and
  4160  			// Message from an error.
  4161  			fmt.Println(err.Error())
  4162  		}
  4163  		return
  4164  	}
  4165  
  4166  	fmt.Println(result)
  4167  }
  4168  
  4169  // To enable enhanced networking
  4170  //
  4171  // This example enables enhanced networking for the specified stopped instance.
  4172  func ExampleEC2_ModifyInstanceAttribute_shared01() {
  4173  	svc := ec2.New(session.New())
  4174  	input := &ec2.ModifyInstanceAttributeInput{
  4175  		EnaSupport: &ec2.AttributeBooleanValue{
  4176  			Value: aws.Bool(true),
  4177  		},
  4178  		InstanceId: aws.String("i-1234567890abcdef0"),
  4179  	}
  4180  
  4181  	result, err := svc.ModifyInstanceAttribute(input)
  4182  	if err != nil {
  4183  		if aerr, ok := err.(awserr.Error); ok {
  4184  			switch aerr.Code() {
  4185  			default:
  4186  				fmt.Println(aerr.Error())
  4187  			}
  4188  		} else {
  4189  			// Print the error, cast err to awserr.Error to get the Code and
  4190  			// Message from an error.
  4191  			fmt.Println(err.Error())
  4192  		}
  4193  		return
  4194  	}
  4195  
  4196  	fmt.Println(result)
  4197  }
  4198  
  4199  // To change the default version of a launch template
  4200  //
  4201  // This example specifies version 2 as the default version of the specified launch template.
  4202  func ExampleEC2_ModifyLaunchTemplate_shared00() {
  4203  	svc := ec2.New(session.New())
  4204  	input := &ec2.ModifyLaunchTemplateInput{
  4205  		DefaultVersion:   aws.String("2"),
  4206  		LaunchTemplateId: aws.String("lt-0abcd290751193123"),
  4207  	}
  4208  
  4209  	result, err := svc.ModifyLaunchTemplate(input)
  4210  	if err != nil {
  4211  		if aerr, ok := err.(awserr.Error); ok {
  4212  			switch aerr.Code() {
  4213  			default:
  4214  				fmt.Println(aerr.Error())
  4215  			}
  4216  		} else {
  4217  			// Print the error, cast err to awserr.Error to get the Code and
  4218  			// Message from an error.
  4219  			fmt.Println(err.Error())
  4220  		}
  4221  		return
  4222  	}
  4223  
  4224  	fmt.Println(result)
  4225  }
  4226  
  4227  // To modify the attachment attribute of a network interface
  4228  //
  4229  // This example modifies the attachment attribute of the specified network interface.
  4230  func ExampleEC2_ModifyNetworkInterfaceAttribute_shared00() {
  4231  	svc := ec2.New(session.New())
  4232  	input := &ec2.ModifyNetworkInterfaceAttributeInput{
  4233  		Attachment: &ec2.NetworkInterfaceAttachmentChanges{
  4234  			AttachmentId:        aws.String("eni-attach-43348162"),
  4235  			DeleteOnTermination: aws.Bool(false),
  4236  		},
  4237  		NetworkInterfaceId: aws.String("eni-686ea200"),
  4238  	}
  4239  
  4240  	result, err := svc.ModifyNetworkInterfaceAttribute(input)
  4241  	if err != nil {
  4242  		if aerr, ok := err.(awserr.Error); ok {
  4243  			switch aerr.Code() {
  4244  			default:
  4245  				fmt.Println(aerr.Error())
  4246  			}
  4247  		} else {
  4248  			// Print the error, cast err to awserr.Error to get the Code and
  4249  			// Message from an error.
  4250  			fmt.Println(err.Error())
  4251  		}
  4252  		return
  4253  	}
  4254  
  4255  	fmt.Println(result)
  4256  }
  4257  
  4258  // To modify the description attribute of a network interface
  4259  //
  4260  // This example modifies the description attribute of the specified network interface.
  4261  func ExampleEC2_ModifyNetworkInterfaceAttribute_shared01() {
  4262  	svc := ec2.New(session.New())
  4263  	input := &ec2.ModifyNetworkInterfaceAttributeInput{
  4264  		Description: &ec2.AttributeValue{
  4265  			Value: aws.String("My description"),
  4266  		},
  4267  		NetworkInterfaceId: aws.String("eni-686ea200"),
  4268  	}
  4269  
  4270  	result, err := svc.ModifyNetworkInterfaceAttribute(input)
  4271  	if err != nil {
  4272  		if aerr, ok := err.(awserr.Error); ok {
  4273  			switch aerr.Code() {
  4274  			default:
  4275  				fmt.Println(aerr.Error())
  4276  			}
  4277  		} else {
  4278  			// Print the error, cast err to awserr.Error to get the Code and
  4279  			// Message from an error.
  4280  			fmt.Println(err.Error())
  4281  		}
  4282  		return
  4283  	}
  4284  
  4285  	fmt.Println(result)
  4286  }
  4287  
  4288  // To modify the groupSet attribute of a network interface
  4289  //
  4290  // This example command modifies the groupSet attribute of the specified network interface.
  4291  func ExampleEC2_ModifyNetworkInterfaceAttribute_shared02() {
  4292  	svc := ec2.New(session.New())
  4293  	input := &ec2.ModifyNetworkInterfaceAttributeInput{
  4294  		Groups: []*string{
  4295  			aws.String("sg-903004f8"),
  4296  			aws.String("sg-1a2b3c4d"),
  4297  		},
  4298  		NetworkInterfaceId: aws.String("eni-686ea200"),
  4299  	}
  4300  
  4301  	result, err := svc.ModifyNetworkInterfaceAttribute(input)
  4302  	if err != nil {
  4303  		if aerr, ok := err.(awserr.Error); ok {
  4304  			switch aerr.Code() {
  4305  			default:
  4306  				fmt.Println(aerr.Error())
  4307  			}
  4308  		} else {
  4309  			// Print the error, cast err to awserr.Error to get the Code and
  4310  			// Message from an error.
  4311  			fmt.Println(err.Error())
  4312  		}
  4313  		return
  4314  	}
  4315  
  4316  	fmt.Println(result)
  4317  }
  4318  
  4319  // To modify the sourceDestCheck attribute of a network interface
  4320  //
  4321  // This example command modifies the sourceDestCheck attribute of the specified network
  4322  // interface.
  4323  func ExampleEC2_ModifyNetworkInterfaceAttribute_shared03() {
  4324  	svc := ec2.New(session.New())
  4325  	input := &ec2.ModifyNetworkInterfaceAttributeInput{
  4326  		NetworkInterfaceId: aws.String("eni-686ea200"),
  4327  		SourceDestCheck: &ec2.AttributeBooleanValue{
  4328  			Value: aws.Bool(false),
  4329  		},
  4330  	}
  4331  
  4332  	result, err := svc.ModifyNetworkInterfaceAttribute(input)
  4333  	if err != nil {
  4334  		if aerr, ok := err.(awserr.Error); ok {
  4335  			switch aerr.Code() {
  4336  			default:
  4337  				fmt.Println(aerr.Error())
  4338  			}
  4339  		} else {
  4340  			// Print the error, cast err to awserr.Error to get the Code and
  4341  			// Message from an error.
  4342  			fmt.Println(err.Error())
  4343  		}
  4344  		return
  4345  	}
  4346  
  4347  	fmt.Println(result)
  4348  }
  4349  
  4350  // To modify a snapshot attribute
  4351  //
  4352  // This example modifies snapshot ``snap-1234567890abcdef0`` to remove the create volume
  4353  // permission for a user with the account ID ``123456789012``. If the command succeeds,
  4354  // no output is returned.
  4355  func ExampleEC2_ModifySnapshotAttribute_shared00() {
  4356  	svc := ec2.New(session.New())
  4357  	input := &ec2.ModifySnapshotAttributeInput{
  4358  		Attribute:     aws.String("createVolumePermission"),
  4359  		OperationType: aws.String("remove"),
  4360  		SnapshotId:    aws.String("snap-1234567890abcdef0"),
  4361  		UserIds: []*string{
  4362  			aws.String("123456789012"),
  4363  		},
  4364  	}
  4365  
  4366  	result, err := svc.ModifySnapshotAttribute(input)
  4367  	if err != nil {
  4368  		if aerr, ok := err.(awserr.Error); ok {
  4369  			switch aerr.Code() {
  4370  			default:
  4371  				fmt.Println(aerr.Error())
  4372  			}
  4373  		} else {
  4374  			// Print the error, cast err to awserr.Error to get the Code and
  4375  			// Message from an error.
  4376  			fmt.Println(err.Error())
  4377  		}
  4378  		return
  4379  	}
  4380  
  4381  	fmt.Println(result)
  4382  }
  4383  
  4384  // To make a snapshot public
  4385  //
  4386  // This example makes the snapshot ``snap-1234567890abcdef0`` public.
  4387  func ExampleEC2_ModifySnapshotAttribute_shared01() {
  4388  	svc := ec2.New(session.New())
  4389  	input := &ec2.ModifySnapshotAttributeInput{
  4390  		Attribute: aws.String("createVolumePermission"),
  4391  		GroupNames: []*string{
  4392  			aws.String("all"),
  4393  		},
  4394  		OperationType: aws.String("add"),
  4395  		SnapshotId:    aws.String("snap-1234567890abcdef0"),
  4396  	}
  4397  
  4398  	result, err := svc.ModifySnapshotAttribute(input)
  4399  	if err != nil {
  4400  		if aerr, ok := err.(awserr.Error); ok {
  4401  			switch aerr.Code() {
  4402  			default:
  4403  				fmt.Println(aerr.Error())
  4404  			}
  4405  		} else {
  4406  			// Print the error, cast err to awserr.Error to get the Code and
  4407  			// Message from an error.
  4408  			fmt.Println(err.Error())
  4409  		}
  4410  		return
  4411  	}
  4412  
  4413  	fmt.Println(result)
  4414  }
  4415  
  4416  // To increase the target capacity of a Spot fleet request
  4417  //
  4418  // This example increases the target capacity of the specified Spot fleet request.
  4419  func ExampleEC2_ModifySpotFleetRequest_shared00() {
  4420  	svc := ec2.New(session.New())
  4421  	input := &ec2.ModifySpotFleetRequestInput{
  4422  		SpotFleetRequestId: aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
  4423  		TargetCapacity:     aws.Int64(20),
  4424  	}
  4425  
  4426  	result, err := svc.ModifySpotFleetRequest(input)
  4427  	if err != nil {
  4428  		if aerr, ok := err.(awserr.Error); ok {
  4429  			switch aerr.Code() {
  4430  			default:
  4431  				fmt.Println(aerr.Error())
  4432  			}
  4433  		} else {
  4434  			// Print the error, cast err to awserr.Error to get the Code and
  4435  			// Message from an error.
  4436  			fmt.Println(err.Error())
  4437  		}
  4438  		return
  4439  	}
  4440  
  4441  	fmt.Println(result)
  4442  }
  4443  
  4444  // To decrease the target capacity of a Spot fleet request
  4445  //
  4446  // This example decreases the target capacity of the specified Spot fleet request without
  4447  // terminating any Spot Instances as a result.
  4448  func ExampleEC2_ModifySpotFleetRequest_shared01() {
  4449  	svc := ec2.New(session.New())
  4450  	input := &ec2.ModifySpotFleetRequestInput{
  4451  		ExcessCapacityTerminationPolicy: aws.String("NoTermination "),
  4452  		SpotFleetRequestId:              aws.String("sfr-73fbd2ce-aa30-494c-8788-1cee4EXAMPLE"),
  4453  		TargetCapacity:                  aws.Int64(10),
  4454  	}
  4455  
  4456  	result, err := svc.ModifySpotFleetRequest(input)
  4457  	if err != nil {
  4458  		if aerr, ok := err.(awserr.Error); ok {
  4459  			switch aerr.Code() {
  4460  			default:
  4461  				fmt.Println(aerr.Error())
  4462  			}
  4463  		} else {
  4464  			// Print the error, cast err to awserr.Error to get the Code and
  4465  			// Message from an error.
  4466  			fmt.Println(err.Error())
  4467  		}
  4468  		return
  4469  	}
  4470  
  4471  	fmt.Println(result)
  4472  }
  4473  
  4474  // To change a subnet's public IP addressing behavior
  4475  //
  4476  // This example modifies the specified subnet so that all instances launched into this
  4477  // subnet are assigned a public IP address.
  4478  func ExampleEC2_ModifySubnetAttribute_shared00() {
  4479  	svc := ec2.New(session.New())
  4480  	input := &ec2.ModifySubnetAttributeInput{
  4481  		MapPublicIpOnLaunch: &ec2.AttributeBooleanValue{
  4482  			Value: aws.Bool(true),
  4483  		},
  4484  		SubnetId: aws.String("subnet-1a2b3c4d"),
  4485  	}
  4486  
  4487  	result, err := svc.ModifySubnetAttribute(input)
  4488  	if err != nil {
  4489  		if aerr, ok := err.(awserr.Error); ok {
  4490  			switch aerr.Code() {
  4491  			default:
  4492  				fmt.Println(aerr.Error())
  4493  			}
  4494  		} else {
  4495  			// Print the error, cast err to awserr.Error to get the Code and
  4496  			// Message from an error.
  4497  			fmt.Println(err.Error())
  4498  		}
  4499  		return
  4500  	}
  4501  
  4502  	fmt.Println(result)
  4503  }
  4504  
  4505  // To modify a volume attribute
  4506  //
  4507  // This example sets the ``autoEnableIo`` attribute of the volume with the ID ``vol-1234567890abcdef0``
  4508  // to ``true``. If the command succeeds, no output is returned.
  4509  func ExampleEC2_ModifyVolumeAttribute_shared00() {
  4510  	svc := ec2.New(session.New())
  4511  	input := &ec2.ModifyVolumeAttributeInput{
  4512  		AutoEnableIO: &ec2.AttributeBooleanValue{
  4513  			Value: aws.Bool(true),
  4514  		},
  4515  		DryRun:   aws.Bool(true),
  4516  		VolumeId: aws.String("vol-1234567890abcdef0"),
  4517  	}
  4518  
  4519  	result, err := svc.ModifyVolumeAttribute(input)
  4520  	if err != nil {
  4521  		if aerr, ok := err.(awserr.Error); ok {
  4522  			switch aerr.Code() {
  4523  			default:
  4524  				fmt.Println(aerr.Error())
  4525  			}
  4526  		} else {
  4527  			// Print the error, cast err to awserr.Error to get the Code and
  4528  			// Message from an error.
  4529  			fmt.Println(err.Error())
  4530  		}
  4531  		return
  4532  	}
  4533  
  4534  	fmt.Println(result)
  4535  }
  4536  
  4537  // To modify the enableDnsSupport attribute
  4538  //
  4539  // This example modifies the enableDnsSupport attribute. This attribute indicates whether
  4540  // DNS resolution is enabled for the VPC. If this attribute is true, the Amazon DNS
  4541  // server resolves DNS hostnames for instances in the VPC to their corresponding IP
  4542  // addresses; otherwise, it does not.
  4543  func ExampleEC2_ModifyVpcAttribute_shared00() {
  4544  	svc := ec2.New(session.New())
  4545  	input := &ec2.ModifyVpcAttributeInput{
  4546  		EnableDnsSupport: &ec2.AttributeBooleanValue{
  4547  			Value: aws.Bool(false),
  4548  		},
  4549  		VpcId: aws.String("vpc-a01106c2"),
  4550  	}
  4551  
  4552  	result, err := svc.ModifyVpcAttribute(input)
  4553  	if err != nil {
  4554  		if aerr, ok := err.(awserr.Error); ok {
  4555  			switch aerr.Code() {
  4556  			default:
  4557  				fmt.Println(aerr.Error())
  4558  			}
  4559  		} else {
  4560  			// Print the error, cast err to awserr.Error to get the Code and
  4561  			// Message from an error.
  4562  			fmt.Println(err.Error())
  4563  		}
  4564  		return
  4565  	}
  4566  
  4567  	fmt.Println(result)
  4568  }
  4569  
  4570  // To modify the enableDnsHostnames attribute
  4571  //
  4572  // This example modifies the enableDnsHostnames attribute. This attribute indicates
  4573  // whether instances launched in the VPC get DNS hostnames. If this attribute is true,
  4574  // instances in the VPC get DNS hostnames; otherwise, they do not.
  4575  func ExampleEC2_ModifyVpcAttribute_shared01() {
  4576  	svc := ec2.New(session.New())
  4577  	input := &ec2.ModifyVpcAttributeInput{
  4578  		EnableDnsHostnames: &ec2.AttributeBooleanValue{
  4579  			Value: aws.Bool(false),
  4580  		},
  4581  		VpcId: aws.String("vpc-a01106c2"),
  4582  	}
  4583  
  4584  	result, err := svc.ModifyVpcAttribute(input)
  4585  	if err != nil {
  4586  		if aerr, ok := err.(awserr.Error); ok {
  4587  			switch aerr.Code() {
  4588  			default:
  4589  				fmt.Println(aerr.Error())
  4590  			}
  4591  		} else {
  4592  			// Print the error, cast err to awserr.Error to get the Code and
  4593  			// Message from an error.
  4594  			fmt.Println(err.Error())
  4595  		}
  4596  		return
  4597  	}
  4598  
  4599  	fmt.Println(result)
  4600  }
  4601  
  4602  // To move an address to EC2-VPC
  4603  //
  4604  // This example moves the specified Elastic IP address to the EC2-VPC platform.
  4605  func ExampleEC2_MoveAddressToVpc_shared00() {
  4606  	svc := ec2.New(session.New())
  4607  	input := &ec2.MoveAddressToVpcInput{
  4608  		PublicIp: aws.String("54.123.4.56"),
  4609  	}
  4610  
  4611  	result, err := svc.MoveAddressToVpc(input)
  4612  	if err != nil {
  4613  		if aerr, ok := err.(awserr.Error); ok {
  4614  			switch aerr.Code() {
  4615  			default:
  4616  				fmt.Println(aerr.Error())
  4617  			}
  4618  		} else {
  4619  			// Print the error, cast err to awserr.Error to get the Code and
  4620  			// Message from an error.
  4621  			fmt.Println(err.Error())
  4622  		}
  4623  		return
  4624  	}
  4625  
  4626  	fmt.Println(result)
  4627  }
  4628  
  4629  // To purchase a Scheduled Instance
  4630  //
  4631  // This example purchases a Scheduled Instance.
  4632  func ExampleEC2_PurchaseScheduledInstances_shared00() {
  4633  	svc := ec2.New(session.New())
  4634  	input := &ec2.PurchaseScheduledInstancesInput{
  4635  		PurchaseRequests: []*ec2.PurchaseRequest{
  4636  			{
  4637  				InstanceCount: aws.Int64(1),
  4638  				PurchaseToken: aws.String("eyJ2IjoiMSIsInMiOjEsImMiOi..."),
  4639  			},
  4640  		},
  4641  	}
  4642  
  4643  	result, err := svc.PurchaseScheduledInstances(input)
  4644  	if err != nil {
  4645  		if aerr, ok := err.(awserr.Error); ok {
  4646  			switch aerr.Code() {
  4647  			default:
  4648  				fmt.Println(aerr.Error())
  4649  			}
  4650  		} else {
  4651  			// Print the error, cast err to awserr.Error to get the Code and
  4652  			// Message from an error.
  4653  			fmt.Println(err.Error())
  4654  		}
  4655  		return
  4656  	}
  4657  
  4658  	fmt.Println(result)
  4659  }
  4660  
  4661  // To reboot an EC2 instance
  4662  //
  4663  // This example reboots the specified EC2 instance.
  4664  func ExampleEC2_RebootInstances_shared00() {
  4665  	svc := ec2.New(session.New())
  4666  	input := &ec2.RebootInstancesInput{
  4667  		InstanceIds: []*string{
  4668  			aws.String("i-1234567890abcdef5"),
  4669  		},
  4670  	}
  4671  
  4672  	result, err := svc.RebootInstances(input)
  4673  	if err != nil {
  4674  		if aerr, ok := err.(awserr.Error); ok {
  4675  			switch aerr.Code() {
  4676  			default:
  4677  				fmt.Println(aerr.Error())
  4678  			}
  4679  		} else {
  4680  			// Print the error, cast err to awserr.Error to get the Code and
  4681  			// Message from an error.
  4682  			fmt.Println(err.Error())
  4683  		}
  4684  		return
  4685  	}
  4686  
  4687  	fmt.Println(result)
  4688  }
  4689  
  4690  // To release an Elastic IP address for EC2-VPC
  4691  //
  4692  // This example releases an Elastic IP address for use with instances in a VPC.
  4693  func ExampleEC2_ReleaseAddress_shared00() {
  4694  	svc := ec2.New(session.New())
  4695  	input := &ec2.ReleaseAddressInput{
  4696  		AllocationId: aws.String("eipalloc-64d5890a"),
  4697  	}
  4698  
  4699  	result, err := svc.ReleaseAddress(input)
  4700  	if err != nil {
  4701  		if aerr, ok := err.(awserr.Error); ok {
  4702  			switch aerr.Code() {
  4703  			default:
  4704  				fmt.Println(aerr.Error())
  4705  			}
  4706  		} else {
  4707  			// Print the error, cast err to awserr.Error to get the Code and
  4708  			// Message from an error.
  4709  			fmt.Println(err.Error())
  4710  		}
  4711  		return
  4712  	}
  4713  
  4714  	fmt.Println(result)
  4715  }
  4716  
  4717  // To release an Elastic IP addresses for EC2-Classic
  4718  //
  4719  // This example releases an Elastic IP address for use with instances in EC2-Classic.
  4720  func ExampleEC2_ReleaseAddress_shared01() {
  4721  	svc := ec2.New(session.New())
  4722  	input := &ec2.ReleaseAddressInput{
  4723  		PublicIp: aws.String("198.51.100.0"),
  4724  	}
  4725  
  4726  	result, err := svc.ReleaseAddress(input)
  4727  	if err != nil {
  4728  		if aerr, ok := err.(awserr.Error); ok {
  4729  			switch aerr.Code() {
  4730  			default:
  4731  				fmt.Println(aerr.Error())
  4732  			}
  4733  		} else {
  4734  			// Print the error, cast err to awserr.Error to get the Code and
  4735  			// Message from an error.
  4736  			fmt.Println(err.Error())
  4737  		}
  4738  		return
  4739  	}
  4740  
  4741  	fmt.Println(result)
  4742  }
  4743  
  4744  // To replace the network ACL associated with a subnet
  4745  //
  4746  // This example associates the specified network ACL with the subnet for the specified
  4747  // network ACL association.
  4748  func ExampleEC2_ReplaceNetworkAclAssociation_shared00() {
  4749  	svc := ec2.New(session.New())
  4750  	input := &ec2.ReplaceNetworkAclAssociationInput{
  4751  		AssociationId: aws.String("aclassoc-e5b95c8c"),
  4752  		NetworkAclId:  aws.String("acl-5fb85d36"),
  4753  	}
  4754  
  4755  	result, err := svc.ReplaceNetworkAclAssociation(input)
  4756  	if err != nil {
  4757  		if aerr, ok := err.(awserr.Error); ok {
  4758  			switch aerr.Code() {
  4759  			default:
  4760  				fmt.Println(aerr.Error())
  4761  			}
  4762  		} else {
  4763  			// Print the error, cast err to awserr.Error to get the Code and
  4764  			// Message from an error.
  4765  			fmt.Println(err.Error())
  4766  		}
  4767  		return
  4768  	}
  4769  
  4770  	fmt.Println(result)
  4771  }
  4772  
  4773  // To replace a network ACL entry
  4774  //
  4775  // This example replaces an entry for the specified network ACL. The new rule 100 allows
  4776  // ingress traffic from 203.0.113.12/24 on UDP port 53 (DNS) into any associated subnet.
  4777  func ExampleEC2_ReplaceNetworkAclEntry_shared00() {
  4778  	svc := ec2.New(session.New())
  4779  	input := &ec2.ReplaceNetworkAclEntryInput{
  4780  		CidrBlock:    aws.String("203.0.113.12/24"),
  4781  		Egress:       aws.Bool(false),
  4782  		NetworkAclId: aws.String("acl-5fb85d36"),
  4783  		PortRange: &ec2.PortRange{
  4784  			From: aws.Int64(53),
  4785  			To:   aws.Int64(53),
  4786  		},
  4787  		Protocol:   aws.String("17"),
  4788  		RuleAction: aws.String("allow"),
  4789  		RuleNumber: aws.Int64(100),
  4790  	}
  4791  
  4792  	result, err := svc.ReplaceNetworkAclEntry(input)
  4793  	if err != nil {
  4794  		if aerr, ok := err.(awserr.Error); ok {
  4795  			switch aerr.Code() {
  4796  			default:
  4797  				fmt.Println(aerr.Error())
  4798  			}
  4799  		} else {
  4800  			// Print the error, cast err to awserr.Error to get the Code and
  4801  			// Message from an error.
  4802  			fmt.Println(err.Error())
  4803  		}
  4804  		return
  4805  	}
  4806  
  4807  	fmt.Println(result)
  4808  }
  4809  
  4810  // To replace a route
  4811  //
  4812  // This example replaces the specified route in the specified table table. The new route
  4813  // matches the specified CIDR and sends the traffic to the specified virtual private
  4814  // gateway.
  4815  func ExampleEC2_ReplaceRoute_shared00() {
  4816  	svc := ec2.New(session.New())
  4817  	input := &ec2.ReplaceRouteInput{
  4818  		DestinationCidrBlock: aws.String("10.0.0.0/16"),
  4819  		GatewayId:            aws.String("vgw-9a4cacf3"),
  4820  		RouteTableId:         aws.String("rtb-22574640"),
  4821  	}
  4822  
  4823  	result, err := svc.ReplaceRoute(input)
  4824  	if err != nil {
  4825  		if aerr, ok := err.(awserr.Error); ok {
  4826  			switch aerr.Code() {
  4827  			default:
  4828  				fmt.Println(aerr.Error())
  4829  			}
  4830  		} else {
  4831  			// Print the error, cast err to awserr.Error to get the Code and
  4832  			// Message from an error.
  4833  			fmt.Println(err.Error())
  4834  		}
  4835  		return
  4836  	}
  4837  
  4838  	fmt.Println(result)
  4839  }
  4840  
  4841  // To replace the route table associated with a subnet
  4842  //
  4843  // This example associates the specified route table with the subnet for the specified
  4844  // route table association.
  4845  func ExampleEC2_ReplaceRouteTableAssociation_shared00() {
  4846  	svc := ec2.New(session.New())
  4847  	input := &ec2.ReplaceRouteTableAssociationInput{
  4848  		AssociationId: aws.String("rtbassoc-781d0d1a"),
  4849  		RouteTableId:  aws.String("rtb-22574640"),
  4850  	}
  4851  
  4852  	result, err := svc.ReplaceRouteTableAssociation(input)
  4853  	if err != nil {
  4854  		if aerr, ok := err.(awserr.Error); ok {
  4855  			switch aerr.Code() {
  4856  			default:
  4857  				fmt.Println(aerr.Error())
  4858  			}
  4859  		} else {
  4860  			// Print the error, cast err to awserr.Error to get the Code and
  4861  			// Message from an error.
  4862  			fmt.Println(err.Error())
  4863  		}
  4864  		return
  4865  	}
  4866  
  4867  	fmt.Println(result)
  4868  }
  4869  
  4870  // To request a Spot fleet in the subnet with the lowest price
  4871  //
  4872  // This example creates a Spot fleet request with two launch specifications that differ
  4873  // only by subnet. The Spot fleet launches the instances in the specified subnet with
  4874  // the lowest price. If the instances are launched in a default VPC, they receive a
  4875  // public IP address by default. If the instances are launched in a nondefault VPC,
  4876  // they do not receive a public IP address by default. Note that you can't specify different
  4877  // subnets from the same Availability Zone in a Spot fleet request.
  4878  func ExampleEC2_RequestSpotFleet_shared00() {
  4879  	svc := ec2.New(session.New())
  4880  	input := &ec2.RequestSpotFleetInput{
  4881  		SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{
  4882  			IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"),
  4883  			LaunchSpecifications: []*ec2.SpotFleetLaunchSpecification{
  4884  				{
  4885  					IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
  4886  						Arn: aws.String("arn:aws:iam::123456789012:instance-profile/my-iam-role"),
  4887  					},
  4888  					ImageId:      aws.String("ami-1a2b3c4d"),
  4889  					InstanceType: aws.String("m3.medium"),
  4890  					KeyName:      aws.String("my-key-pair"),
  4891  					SecurityGroups: []*ec2.GroupIdentifier{
  4892  						{
  4893  							GroupId: aws.String("sg-1a2b3c4d"),
  4894  						},
  4895  					},
  4896  					SubnetId: aws.String("subnet-1a2b3c4d, subnet-3c4d5e6f"),
  4897  				},
  4898  			},
  4899  			SpotPrice:      aws.String("0.04"),
  4900  			TargetCapacity: aws.Int64(2),
  4901  		},
  4902  	}
  4903  
  4904  	result, err := svc.RequestSpotFleet(input)
  4905  	if err != nil {
  4906  		if aerr, ok := err.(awserr.Error); ok {
  4907  			switch aerr.Code() {
  4908  			default:
  4909  				fmt.Println(aerr.Error())
  4910  			}
  4911  		} else {
  4912  			// Print the error, cast err to awserr.Error to get the Code and
  4913  			// Message from an error.
  4914  			fmt.Println(err.Error())
  4915  		}
  4916  		return
  4917  	}
  4918  
  4919  	fmt.Println(result)
  4920  }
  4921  
  4922  // To request a Spot fleet in the Availability Zone with the lowest price
  4923  //
  4924  // This example creates a Spot fleet request with two launch specifications that differ
  4925  // only by Availability Zone. The Spot fleet launches the instances in the specified
  4926  // Availability Zone with the lowest price. If your account supports EC2-VPC only, Amazon
  4927  // EC2 launches the Spot instances in the default subnet of the Availability Zone. If
  4928  // your account supports EC2-Classic, Amazon EC2 launches the instances in EC2-Classic
  4929  // in the Availability Zone.
  4930  func ExampleEC2_RequestSpotFleet_shared01() {
  4931  	svc := ec2.New(session.New())
  4932  	input := &ec2.RequestSpotFleetInput{
  4933  		SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{
  4934  			IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"),
  4935  			LaunchSpecifications: []*ec2.SpotFleetLaunchSpecification{
  4936  				{
  4937  					IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
  4938  						Arn: aws.String("arn:aws:iam::123456789012:instance-profile/my-iam-role"),
  4939  					},
  4940  					ImageId:      aws.String("ami-1a2b3c4d"),
  4941  					InstanceType: aws.String("m3.medium"),
  4942  					KeyName:      aws.String("my-key-pair"),
  4943  					Placement: &ec2.SpotPlacement{
  4944  						AvailabilityZone: aws.String("us-west-2a, us-west-2b"),
  4945  					},
  4946  					SecurityGroups: []*ec2.GroupIdentifier{
  4947  						{
  4948  							GroupId: aws.String("sg-1a2b3c4d"),
  4949  						},
  4950  					},
  4951  				},
  4952  			},
  4953  			SpotPrice:      aws.String("0.04"),
  4954  			TargetCapacity: aws.Int64(2),
  4955  		},
  4956  	}
  4957  
  4958  	result, err := svc.RequestSpotFleet(input)
  4959  	if err != nil {
  4960  		if aerr, ok := err.(awserr.Error); ok {
  4961  			switch aerr.Code() {
  4962  			default:
  4963  				fmt.Println(aerr.Error())
  4964  			}
  4965  		} else {
  4966  			// Print the error, cast err to awserr.Error to get the Code and
  4967  			// Message from an error.
  4968  			fmt.Println(err.Error())
  4969  		}
  4970  		return
  4971  	}
  4972  
  4973  	fmt.Println(result)
  4974  }
  4975  
  4976  // To launch Spot instances in a subnet and assign them public IP addresses
  4977  //
  4978  // This example assigns public addresses to instances launched in a nondefault VPC.
  4979  // Note that when you specify a network interface, you must include the subnet ID and
  4980  // security group ID using the network interface.
  4981  func ExampleEC2_RequestSpotFleet_shared02() {
  4982  	svc := ec2.New(session.New())
  4983  	input := &ec2.RequestSpotFleetInput{
  4984  		SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{
  4985  			IamFleetRole: aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"),
  4986  			LaunchSpecifications: []*ec2.SpotFleetLaunchSpecification{
  4987  				{
  4988  					IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
  4989  						Arn: aws.String("arn:aws:iam::880185128111:instance-profile/my-iam-role"),
  4990  					},
  4991  					ImageId:      aws.String("ami-1a2b3c4d"),
  4992  					InstanceType: aws.String("m3.medium"),
  4993  					KeyName:      aws.String("my-key-pair"),
  4994  					NetworkInterfaces: []*ec2.InstanceNetworkInterfaceSpecification{
  4995  						{
  4996  							AssociatePublicIpAddress: aws.Bool(true),
  4997  							DeviceIndex:              aws.Int64(0),
  4998  							Groups: []*string{
  4999  								aws.String("sg-1a2b3c4d"),
  5000  							},
  5001  							SubnetId: aws.String("subnet-1a2b3c4d"),
  5002  						},
  5003  					},
  5004  				},
  5005  			},
  5006  			SpotPrice:      aws.String("0.04"),
  5007  			TargetCapacity: aws.Int64(2),
  5008  		},
  5009  	}
  5010  
  5011  	result, err := svc.RequestSpotFleet(input)
  5012  	if err != nil {
  5013  		if aerr, ok := err.(awserr.Error); ok {
  5014  			switch aerr.Code() {
  5015  			default:
  5016  				fmt.Println(aerr.Error())
  5017  			}
  5018  		} else {
  5019  			// Print the error, cast err to awserr.Error to get the Code and
  5020  			// Message from an error.
  5021  			fmt.Println(err.Error())
  5022  		}
  5023  		return
  5024  	}
  5025  
  5026  	fmt.Println(result)
  5027  }
  5028  
  5029  // To request a Spot fleet using the diversified allocation strategy
  5030  //
  5031  // This example creates a Spot fleet request that launches 30 instances using the diversified
  5032  // allocation strategy. The launch specifications differ by instance type. The Spot
  5033  // fleet distributes the instances across the launch specifications such that there
  5034  // are 10 instances of each type.
  5035  func ExampleEC2_RequestSpotFleet_shared03() {
  5036  	svc := ec2.New(session.New())
  5037  	input := &ec2.RequestSpotFleetInput{
  5038  		SpotFleetRequestConfig: &ec2.SpotFleetRequestConfigData{
  5039  			AllocationStrategy: aws.String("diversified"),
  5040  			IamFleetRole:       aws.String("arn:aws:iam::123456789012:role/my-spot-fleet-role"),
  5041  			LaunchSpecifications: []*ec2.SpotFleetLaunchSpecification{
  5042  				{
  5043  					ImageId:      aws.String("ami-1a2b3c4d"),
  5044  					InstanceType: aws.String("c4.2xlarge"),
  5045  					SubnetId:     aws.String("subnet-1a2b3c4d"),
  5046  				},
  5047  				{
  5048  					ImageId:      aws.String("ami-1a2b3c4d"),
  5049  					InstanceType: aws.String("m3.2xlarge"),
  5050  					SubnetId:     aws.String("subnet-1a2b3c4d"),
  5051  				},
  5052  				{
  5053  					ImageId:      aws.String("ami-1a2b3c4d"),
  5054  					InstanceType: aws.String("r3.2xlarge"),
  5055  					SubnetId:     aws.String("subnet-1a2b3c4d"),
  5056  				},
  5057  			},
  5058  			SpotPrice:      aws.String("0.70"),
  5059  			TargetCapacity: aws.Int64(30),
  5060  		},
  5061  	}
  5062  
  5063  	result, err := svc.RequestSpotFleet(input)
  5064  	if err != nil {
  5065  		if aerr, ok := err.(awserr.Error); ok {
  5066  			switch aerr.Code() {
  5067  			default:
  5068  				fmt.Println(aerr.Error())
  5069  			}
  5070  		} else {
  5071  			// Print the error, cast err to awserr.Error to get the Code and
  5072  			// Message from an error.
  5073  			fmt.Println(err.Error())
  5074  		}
  5075  		return
  5076  	}
  5077  
  5078  	fmt.Println(result)
  5079  }
  5080  
  5081  // To create a one-time Spot Instance request
  5082  //
  5083  // This example creates a one-time Spot Instance request for five instances in the specified
  5084  // Availability Zone. If your account supports EC2-VPC only, Amazon EC2 launches the
  5085  // instances in the default subnet of the specified Availability Zone. If your account
  5086  // supports EC2-Classic, Amazon EC2 launches the instances in EC2-Classic in the specified
  5087  // Availability Zone.
  5088  func ExampleEC2_RequestSpotInstances_shared00() {
  5089  	svc := ec2.New(session.New())
  5090  	input := &ec2.RequestSpotInstancesInput{
  5091  		InstanceCount: aws.Int64(5),
  5092  		LaunchSpecification: &ec2.RequestSpotLaunchSpecification{
  5093  			IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
  5094  				Arn: aws.String("arn:aws:iam::123456789012:instance-profile/my-iam-role"),
  5095  			},
  5096  			ImageId:      aws.String("ami-1a2b3c4d"),
  5097  			InstanceType: aws.String("m3.medium"),
  5098  			KeyName:      aws.String("my-key-pair"),
  5099  			Placement: &ec2.SpotPlacement{
  5100  				AvailabilityZone: aws.String("us-west-2a"),
  5101  			},
  5102  			SecurityGroupIds: []*string{
  5103  				aws.String("sg-1a2b3c4d"),
  5104  			},
  5105  		},
  5106  		SpotPrice: aws.String("0.03"),
  5107  		Type:      aws.String("one-time"),
  5108  	}
  5109  
  5110  	result, err := svc.RequestSpotInstances(input)
  5111  	if err != nil {
  5112  		if aerr, ok := err.(awserr.Error); ok {
  5113  			switch aerr.Code() {
  5114  			default:
  5115  				fmt.Println(aerr.Error())
  5116  			}
  5117  		} else {
  5118  			// Print the error, cast err to awserr.Error to get the Code and
  5119  			// Message from an error.
  5120  			fmt.Println(err.Error())
  5121  		}
  5122  		return
  5123  	}
  5124  
  5125  	fmt.Println(result)
  5126  }
  5127  
  5128  // To create a one-time Spot Instance request
  5129  //
  5130  // This example command creates a one-time Spot Instance request for five instances
  5131  // in the specified subnet. Amazon EC2 launches the instances in the specified subnet.
  5132  // If the VPC is a nondefault VPC, the instances do not receive a public IP address
  5133  // by default.
  5134  func ExampleEC2_RequestSpotInstances_shared01() {
  5135  	svc := ec2.New(session.New())
  5136  	input := &ec2.RequestSpotInstancesInput{
  5137  		InstanceCount: aws.Int64(5),
  5138  		LaunchSpecification: &ec2.RequestSpotLaunchSpecification{
  5139  			IamInstanceProfile: &ec2.IamInstanceProfileSpecification{
  5140  				Arn: aws.String("arn:aws:iam::123456789012:instance-profile/my-iam-role"),
  5141  			},
  5142  			ImageId:      aws.String("ami-1a2b3c4d"),
  5143  			InstanceType: aws.String("m3.medium"),
  5144  			SecurityGroupIds: []*string{
  5145  				aws.String("sg-1a2b3c4d"),
  5146  			},
  5147  			SubnetId: aws.String("subnet-1a2b3c4d"),
  5148  		},
  5149  		SpotPrice: aws.String("0.050"),
  5150  		Type:      aws.String("one-time"),
  5151  	}
  5152  
  5153  	result, err := svc.RequestSpotInstances(input)
  5154  	if err != nil {
  5155  		if aerr, ok := err.(awserr.Error); ok {
  5156  			switch aerr.Code() {
  5157  			default:
  5158  				fmt.Println(aerr.Error())
  5159  			}
  5160  		} else {
  5161  			// Print the error, cast err to awserr.Error to get the Code and
  5162  			// Message from an error.
  5163  			fmt.Println(err.Error())
  5164  		}
  5165  		return
  5166  	}
  5167  
  5168  	fmt.Println(result)
  5169  }
  5170  
  5171  // To reset the launchPermission attribute
  5172  //
  5173  // This example resets the launchPermission attribute for the specified AMI. By default,
  5174  // AMIs are private.
  5175  func ExampleEC2_ResetImageAttribute_shared00() {
  5176  	svc := ec2.New(session.New())
  5177  	input := &ec2.ResetImageAttributeInput{
  5178  		Attribute: aws.String("launchPermission"),
  5179  		ImageId:   aws.String("ami-5731123e"),
  5180  	}
  5181  
  5182  	result, err := svc.ResetImageAttribute(input)
  5183  	if err != nil {
  5184  		if aerr, ok := err.(awserr.Error); ok {
  5185  			switch aerr.Code() {
  5186  			default:
  5187  				fmt.Println(aerr.Error())
  5188  			}
  5189  		} else {
  5190  			// Print the error, cast err to awserr.Error to get the Code and
  5191  			// Message from an error.
  5192  			fmt.Println(err.Error())
  5193  		}
  5194  		return
  5195  	}
  5196  
  5197  	fmt.Println(result)
  5198  }
  5199  
  5200  // To reset the sourceDestCheck attribute
  5201  //
  5202  // This example resets the sourceDestCheck attribute for the specified instance.
  5203  func ExampleEC2_ResetInstanceAttribute_shared00() {
  5204  	svc := ec2.New(session.New())
  5205  	input := &ec2.ResetInstanceAttributeInput{
  5206  		Attribute:  aws.String("sourceDestCheck"),
  5207  		InstanceId: aws.String("i-1234567890abcdef0"),
  5208  	}
  5209  
  5210  	result, err := svc.ResetInstanceAttribute(input)
  5211  	if err != nil {
  5212  		if aerr, ok := err.(awserr.Error); ok {
  5213  			switch aerr.Code() {
  5214  			default:
  5215  				fmt.Println(aerr.Error())
  5216  			}
  5217  		} else {
  5218  			// Print the error, cast err to awserr.Error to get the Code and
  5219  			// Message from an error.
  5220  			fmt.Println(err.Error())
  5221  		}
  5222  		return
  5223  	}
  5224  
  5225  	fmt.Println(result)
  5226  }
  5227  
  5228  // To reset a snapshot attribute
  5229  //
  5230  // This example resets the create volume permissions for snapshot ``snap-1234567890abcdef0``.
  5231  // If the command succeeds, no output is returned.
  5232  func ExampleEC2_ResetSnapshotAttribute_shared00() {
  5233  	svc := ec2.New(session.New())
  5234  	input := &ec2.ResetSnapshotAttributeInput{
  5235  		Attribute:  aws.String("createVolumePermission"),
  5236  		SnapshotId: aws.String("snap-1234567890abcdef0"),
  5237  	}
  5238  
  5239  	result, err := svc.ResetSnapshotAttribute(input)
  5240  	if err != nil {
  5241  		if aerr, ok := err.(awserr.Error); ok {
  5242  			switch aerr.Code() {
  5243  			default:
  5244  				fmt.Println(aerr.Error())
  5245  			}
  5246  		} else {
  5247  			// Print the error, cast err to awserr.Error to get the Code and
  5248  			// Message from an error.
  5249  			fmt.Println(err.Error())
  5250  		}
  5251  		return
  5252  	}
  5253  
  5254  	fmt.Println(result)
  5255  }
  5256  
  5257  // To restore an address to EC2-Classic
  5258  //
  5259  // This example restores the specified Elastic IP address to the EC2-Classic platform.
  5260  func ExampleEC2_RestoreAddressToClassic_shared00() {
  5261  	svc := ec2.New(session.New())
  5262  	input := &ec2.RestoreAddressToClassicInput{
  5263  		PublicIp: aws.String("198.51.100.0"),
  5264  	}
  5265  
  5266  	result, err := svc.RestoreAddressToClassic(input)
  5267  	if err != nil {
  5268  		if aerr, ok := err.(awserr.Error); ok {
  5269  			switch aerr.Code() {
  5270  			default:
  5271  				fmt.Println(aerr.Error())
  5272  			}
  5273  		} else {
  5274  			// Print the error, cast err to awserr.Error to get the Code and
  5275  			// Message from an error.
  5276  			fmt.Println(err.Error())
  5277  		}
  5278  		return
  5279  	}
  5280  
  5281  	fmt.Println(result)
  5282  }
  5283  
  5284  // To launch an instance
  5285  //
  5286  // This example launches an instance using the specified AMI, instance type, security
  5287  // group, subnet, block device mapping, and tags.
  5288  func ExampleEC2_RunInstances_shared00() {
  5289  	svc := ec2.New(session.New())
  5290  	input := &ec2.RunInstancesInput{
  5291  		BlockDeviceMappings: []*ec2.BlockDeviceMapping{
  5292  			{
  5293  				DeviceName: aws.String("/dev/sdh"),
  5294  				Ebs: &ec2.EbsBlockDevice{
  5295  					VolumeSize: aws.Int64(100),
  5296  				},
  5297  			},
  5298  		},
  5299  		ImageId:      aws.String("ami-abc12345"),
  5300  		InstanceType: aws.String("t2.micro"),
  5301  		KeyName:      aws.String("my-key-pair"),
  5302  		MaxCount:     aws.Int64(1),
  5303  		MinCount:     aws.Int64(1),
  5304  		SecurityGroupIds: []*string{
  5305  			aws.String("sg-1a2b3c4d"),
  5306  		},
  5307  		SubnetId: aws.String("subnet-6e7f829e"),
  5308  		TagSpecifications: []*ec2.TagSpecification{
  5309  			{
  5310  				ResourceType: aws.String("instance"),
  5311  				Tags: []*ec2.Tag{
  5312  					{
  5313  						Key:   aws.String("Purpose"),
  5314  						Value: aws.String("test"),
  5315  					},
  5316  				},
  5317  			},
  5318  		},
  5319  	}
  5320  
  5321  	result, err := svc.RunInstances(input)
  5322  	if err != nil {
  5323  		if aerr, ok := err.(awserr.Error); ok {
  5324  			switch aerr.Code() {
  5325  			default:
  5326  				fmt.Println(aerr.Error())
  5327  			}
  5328  		} else {
  5329  			// Print the error, cast err to awserr.Error to get the Code and
  5330  			// Message from an error.
  5331  			fmt.Println(err.Error())
  5332  		}
  5333  		return
  5334  	}
  5335  
  5336  	fmt.Println(result)
  5337  }
  5338  
  5339  // To launch a Scheduled Instance in a VPC
  5340  //
  5341  // This example launches the specified Scheduled Instance in a VPC.
  5342  func ExampleEC2_RunScheduledInstances_shared00() {
  5343  	svc := ec2.New(session.New())
  5344  	input := &ec2.RunScheduledInstancesInput{
  5345  		InstanceCount: aws.Int64(1),
  5346  		LaunchSpecification: &ec2.ScheduledInstancesLaunchSpecification{
  5347  			IamInstanceProfile: &ec2.ScheduledInstancesIamInstanceProfile{
  5348  				Name: aws.String("my-iam-role"),
  5349  			},
  5350  			ImageId:      aws.String("ami-12345678"),
  5351  			InstanceType: aws.String("c4.large"),
  5352  			KeyName:      aws.String("my-key-pair"),
  5353  			NetworkInterfaces: []*ec2.ScheduledInstancesNetworkInterface{
  5354  				{
  5355  					AssociatePublicIpAddress: aws.Bool(true),
  5356  					DeviceIndex:              aws.Int64(0),
  5357  					Groups: []*string{
  5358  						aws.String("sg-12345678"),
  5359  					},
  5360  					SubnetId: aws.String("subnet-12345678"),
  5361  				},
  5362  			},
  5363  		},
  5364  		ScheduledInstanceId: aws.String("sci-1234-1234-1234-1234-123456789012"),
  5365  	}
  5366  
  5367  	result, err := svc.RunScheduledInstances(input)
  5368  	if err != nil {
  5369  		if aerr, ok := err.(awserr.Error); ok {
  5370  			switch aerr.Code() {
  5371  			default:
  5372  				fmt.Println(aerr.Error())
  5373  			}
  5374  		} else {
  5375  			// Print the error, cast err to awserr.Error to get the Code and
  5376  			// Message from an error.
  5377  			fmt.Println(err.Error())
  5378  		}
  5379  		return
  5380  	}
  5381  
  5382  	fmt.Println(result)
  5383  }
  5384  
  5385  // To launch a Scheduled Instance in EC2-Classic
  5386  //
  5387  // This example launches the specified Scheduled Instance in EC2-Classic.
  5388  func ExampleEC2_RunScheduledInstances_shared01() {
  5389  	svc := ec2.New(session.New())
  5390  	input := &ec2.RunScheduledInstancesInput{
  5391  		InstanceCount: aws.Int64(1),
  5392  		LaunchSpecification: &ec2.ScheduledInstancesLaunchSpecification{
  5393  			IamInstanceProfile: &ec2.ScheduledInstancesIamInstanceProfile{
  5394  				Name: aws.String("my-iam-role"),
  5395  			},
  5396  			ImageId:      aws.String("ami-12345678"),
  5397  			InstanceType: aws.String("c4.large"),
  5398  			KeyName:      aws.String("my-key-pair"),
  5399  			Placement: &ec2.ScheduledInstancesPlacement{
  5400  				AvailabilityZone: aws.String("us-west-2b"),
  5401  			},
  5402  			SecurityGroupIds: []*string{
  5403  				aws.String("sg-12345678"),
  5404  			},
  5405  		},
  5406  		ScheduledInstanceId: aws.String("sci-1234-1234-1234-1234-123456789012"),
  5407  	}
  5408  
  5409  	result, err := svc.RunScheduledInstances(input)
  5410  	if err != nil {
  5411  		if aerr, ok := err.(awserr.Error); ok {
  5412  			switch aerr.Code() {
  5413  			default:
  5414  				fmt.Println(aerr.Error())
  5415  			}
  5416  		} else {
  5417  			// Print the error, cast err to awserr.Error to get the Code and
  5418  			// Message from an error.
  5419  			fmt.Println(err.Error())
  5420  		}
  5421  		return
  5422  	}
  5423  
  5424  	fmt.Println(result)
  5425  }
  5426  
  5427  // To start a stopped EC2 instance
  5428  //
  5429  // This example starts the specified EC2 instance.
  5430  func ExampleEC2_StartInstances_shared00() {
  5431  	svc := ec2.New(session.New())
  5432  	input := &ec2.StartInstancesInput{
  5433  		InstanceIds: []*string{
  5434  			aws.String("i-1234567890abcdef0"),
  5435  		},
  5436  	}
  5437  
  5438  	result, err := svc.StartInstances(input)
  5439  	if err != nil {
  5440  		if aerr, ok := err.(awserr.Error); ok {
  5441  			switch aerr.Code() {
  5442  			default:
  5443  				fmt.Println(aerr.Error())
  5444  			}
  5445  		} else {
  5446  			// Print the error, cast err to awserr.Error to get the Code and
  5447  			// Message from an error.
  5448  			fmt.Println(err.Error())
  5449  		}
  5450  		return
  5451  	}
  5452  
  5453  	fmt.Println(result)
  5454  }
  5455  
  5456  // To stop a running EC2 instance
  5457  //
  5458  // This example stops the specified EC2 instance.
  5459  func ExampleEC2_StopInstances_shared00() {
  5460  	svc := ec2.New(session.New())
  5461  	input := &ec2.StopInstancesInput{
  5462  		InstanceIds: []*string{
  5463  			aws.String("i-1234567890abcdef0"),
  5464  		},
  5465  	}
  5466  
  5467  	result, err := svc.StopInstances(input)
  5468  	if err != nil {
  5469  		if aerr, ok := err.(awserr.Error); ok {
  5470  			switch aerr.Code() {
  5471  			default:
  5472  				fmt.Println(aerr.Error())
  5473  			}
  5474  		} else {
  5475  			// Print the error, cast err to awserr.Error to get the Code and
  5476  			// Message from an error.
  5477  			fmt.Println(err.Error())
  5478  		}
  5479  		return
  5480  	}
  5481  
  5482  	fmt.Println(result)
  5483  }
  5484  
  5485  // To terminate an EC2 instance
  5486  //
  5487  // This example terminates the specified EC2 instance.
  5488  func ExampleEC2_TerminateInstances_shared00() {
  5489  	svc := ec2.New(session.New())
  5490  	input := &ec2.TerminateInstancesInput{
  5491  		InstanceIds: []*string{
  5492  			aws.String("i-1234567890abcdef0"),
  5493  		},
  5494  	}
  5495  
  5496  	result, err := svc.TerminateInstances(input)
  5497  	if err != nil {
  5498  		if aerr, ok := err.(awserr.Error); ok {
  5499  			switch aerr.Code() {
  5500  			default:
  5501  				fmt.Println(aerr.Error())
  5502  			}
  5503  		} else {
  5504  			// Print the error, cast err to awserr.Error to get the Code and
  5505  			// Message from an error.
  5506  			fmt.Println(err.Error())
  5507  		}
  5508  		return
  5509  	}
  5510  
  5511  	fmt.Println(result)
  5512  }
  5513  
  5514  // To unassign a secondary private IP address from a network interface
  5515  //
  5516  // This example unassigns the specified private IP address from the specified network
  5517  // interface.
  5518  func ExampleEC2_UnassignPrivateIpAddresses_shared00() {
  5519  	svc := ec2.New(session.New())
  5520  	input := &ec2.UnassignPrivateIpAddressesInput{
  5521  		NetworkInterfaceId: aws.String("eni-e5aa89a3"),
  5522  		PrivateIpAddresses: []*string{
  5523  			aws.String("10.0.0.82"),
  5524  		},
  5525  	}
  5526  
  5527  	result, err := svc.UnassignPrivateIpAddresses(input)
  5528  	if err != nil {
  5529  		if aerr, ok := err.(awserr.Error); ok {
  5530  			switch aerr.Code() {
  5531  			default:
  5532  				fmt.Println(aerr.Error())
  5533  			}
  5534  		} else {
  5535  			// Print the error, cast err to awserr.Error to get the Code and
  5536  			// Message from an error.
  5537  			fmt.Println(err.Error())
  5538  		}
  5539  		return
  5540  	}
  5541  
  5542  	fmt.Println(result)
  5543  }
  5544  
  5545  // To update an outbound security group rule description
  5546  //
  5547  // This example updates the description for the specified security group rule.
  5548  func ExampleEC2_UpdateSecurityGroupRuleDescriptionsEgress_shared00() {
  5549  	svc := ec2.New(session.New())
  5550  	input := &ec2.UpdateSecurityGroupRuleDescriptionsEgressInput{
  5551  		GroupId: aws.String("sg-123abc12"),
  5552  		IpPermissions: []*ec2.IpPermission{
  5553  			{
  5554  				FromPort:   aws.Int64(80),
  5555  				IpProtocol: aws.String("tcp"),
  5556  				IpRanges: []*ec2.IpRange{
  5557  					{
  5558  						CidrIp:      aws.String("203.0.113.0/24"),
  5559  						Description: aws.String("Outbound HTTP access to server 2"),
  5560  					},
  5561  				},
  5562  				ToPort: aws.Int64(80),
  5563  			},
  5564  		},
  5565  	}
  5566  
  5567  	result, err := svc.UpdateSecurityGroupRuleDescriptionsEgress(input)
  5568  	if err != nil {
  5569  		if aerr, ok := err.(awserr.Error); ok {
  5570  			switch aerr.Code() {
  5571  			default:
  5572  				fmt.Println(aerr.Error())
  5573  			}
  5574  		} else {
  5575  			// Print the error, cast err to awserr.Error to get the Code and
  5576  			// Message from an error.
  5577  			fmt.Println(err.Error())
  5578  		}
  5579  		return
  5580  	}
  5581  
  5582  	fmt.Println(result)
  5583  }
  5584  
  5585  // To update an inbound security group rule description
  5586  //
  5587  // This example updates the description for the specified security group rule.
  5588  func ExampleEC2_UpdateSecurityGroupRuleDescriptionsIngress_shared00() {
  5589  	svc := ec2.New(session.New())
  5590  	input := &ec2.UpdateSecurityGroupRuleDescriptionsIngressInput{
  5591  		GroupId: aws.String("sg-123abc12"),
  5592  		IpPermissions: []*ec2.IpPermission{
  5593  			{
  5594  				FromPort:   aws.Int64(22),
  5595  				IpProtocol: aws.String("tcp"),
  5596  				IpRanges: []*ec2.IpRange{
  5597  					{
  5598  						CidrIp:      aws.String("203.0.113.0/16"),
  5599  						Description: aws.String("SSH access from the LA office"),
  5600  					},
  5601  				},
  5602  				ToPort: aws.Int64(22),
  5603  			},
  5604  		},
  5605  	}
  5606  
  5607  	result, err := svc.UpdateSecurityGroupRuleDescriptionsIngress(input)
  5608  	if err != nil {
  5609  		if aerr, ok := err.(awserr.Error); ok {
  5610  			switch aerr.Code() {
  5611  			default:
  5612  				fmt.Println(aerr.Error())
  5613  			}
  5614  		} else {
  5615  			// Print the error, cast err to awserr.Error to get the Code and
  5616  			// Message from an error.
  5617  			fmt.Println(err.Error())
  5618  		}
  5619  		return
  5620  	}
  5621  
  5622  	fmt.Println(result)
  5623  }