1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211
|
// 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)
}
// To list tags for a cluster
// This example lists all of the tags for the `beta` cluster.
func ExampleEKS_ListTagsForResource_shared00() {
svc := eks.New(session.New())
input := &eks.ListTagsForResourceInput{
ResourceArn: aws.String("arn:aws:eks:us-west-2:012345678910:cluster/beta"),
}
result, err := svc.ListTagsForResource(input)
if err != nil {
if aerr, ok := err.(awserr.Error); ok {
switch aerr.Code() {
case eks.ErrCodeBadRequestException:
fmt.Println(eks.ErrCodeBadRequestException, aerr.Error())
case eks.ErrCodeNotFoundException:
fmt.Println(eks.ErrCodeNotFoundException, 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)
}
|