| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
- package eks_test
- import (
- "fmt"
- "strings"
- "time"
- "github.com/aws/aws-sdk-go/aws"
- "github.com/aws/aws-sdk-go/aws/awserr"
- "github.com/aws/aws-sdk-go/aws/session"
- "github.com/aws/aws-sdk-go/service/eks"
- )
- var _ time.Duration
- var _ strings.Reader
- var _ aws.Config
- func parseTime(layout, value string) *time.Time {
- t, err := time.Parse(layout, value)
- if err != nil {
- panic(err)
- }
- return &t
- }
- // To create a new cluster
- //
- // The following example creates an Amazon EKS cluster called prod.
- func ExampleEKS_CreateCluster_shared00() {
- svc := eks.New(session.New())
- input := &eks.CreateClusterInput{
- ClientRequestToken: aws.String("1d2129a1-3d38-460a-9756-e5b91fddb951"),
- Name: aws.String("prod"),
- ResourcesVpcConfig: &eks.VpcConfigRequest{
- SecurityGroupIds: []*string{
- aws.String("sg-6979fe18"),
- },
- SubnetIds: []*string{
- aws.String("subnet-6782e71e"),
- aws.String("subnet-e7e761ac"),
- },
- },
- RoleArn: aws.String("arn:aws:iam::012345678910:role/eks-service-role-AWSServiceRoleForAmazonEKS-J7ONKE3BQ4PI"),
- Version: aws.String("1.10"),
- }
- result, err := svc.CreateCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case eks.ErrCodeResourceInUseException:
- fmt.Println(eks.ErrCodeResourceInUseException, aerr.Error())
- case eks.ErrCodeResourceLimitExceededException:
- fmt.Println(eks.ErrCodeResourceLimitExceededException, aerr.Error())
- case eks.ErrCodeInvalidParameterException:
- fmt.Println(eks.ErrCodeInvalidParameterException, aerr.Error())
- case eks.ErrCodeClientException:
- fmt.Println(eks.ErrCodeClientException, aerr.Error())
- case eks.ErrCodeServerException:
- fmt.Println(eks.ErrCodeServerException, aerr.Error())
- case eks.ErrCodeServiceUnavailableException:
- fmt.Println(eks.ErrCodeServiceUnavailableException, aerr.Error())
- case eks.ErrCodeUnsupportedAvailabilityZoneException:
- fmt.Println(eks.ErrCodeUnsupportedAvailabilityZoneException, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To delete a cluster
- //
- // This example command deletes a cluster named `devel` in your default region.
- func ExampleEKS_DeleteCluster_shared00() {
- svc := eks.New(session.New())
- input := &eks.DeleteClusterInput{
- Name: aws.String("devel"),
- }
- result, err := svc.DeleteCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case eks.ErrCodeResourceInUseException:
- fmt.Println(eks.ErrCodeResourceInUseException, aerr.Error())
- case eks.ErrCodeResourceNotFoundException:
- fmt.Println(eks.ErrCodeResourceNotFoundException, aerr.Error())
- case eks.ErrCodeClientException:
- fmt.Println(eks.ErrCodeClientException, aerr.Error())
- case eks.ErrCodeServerException:
- fmt.Println(eks.ErrCodeServerException, aerr.Error())
- case eks.ErrCodeServiceUnavailableException:
- fmt.Println(eks.ErrCodeServiceUnavailableException, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To describe a cluster
- //
- // This example command provides a description of the specified cluster in your default
- // region.
- func ExampleEKS_DescribeCluster_shared00() {
- svc := eks.New(session.New())
- input := &eks.DescribeClusterInput{
- Name: aws.String("devel"),
- }
- result, err := svc.DescribeCluster(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case eks.ErrCodeResourceNotFoundException:
- fmt.Println(eks.ErrCodeResourceNotFoundException, aerr.Error())
- case eks.ErrCodeClientException:
- fmt.Println(eks.ErrCodeClientException, aerr.Error())
- case eks.ErrCodeServerException:
- fmt.Println(eks.ErrCodeServerException, aerr.Error())
- case eks.ErrCodeServiceUnavailableException:
- fmt.Println(eks.ErrCodeServiceUnavailableException, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
- // To list your available clusters
- //
- // This example command lists all of your available clusters in your default region.
- func ExampleEKS_ListClusters_shared00() {
- svc := eks.New(session.New())
- input := &eks.ListClustersInput{}
- result, err := svc.ListClusters(input)
- if err != nil {
- if aerr, ok := err.(awserr.Error); ok {
- switch aerr.Code() {
- case eks.ErrCodeInvalidParameterException:
- fmt.Println(eks.ErrCodeInvalidParameterException, aerr.Error())
- case eks.ErrCodeClientException:
- fmt.Println(eks.ErrCodeClientException, aerr.Error())
- case eks.ErrCodeServerException:
- fmt.Println(eks.ErrCodeServerException, aerr.Error())
- case eks.ErrCodeServiceUnavailableException:
- fmt.Println(eks.ErrCodeServiceUnavailableException, aerr.Error())
- default:
- fmt.Println(aerr.Error())
- }
- } else {
- // Print the error, cast err to awserr.Error to get the Code and
- // Message from an error.
- fmt.Println(err.Error())
- }
- return
- }
- fmt.Println(result)
- }
|