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

     1  // Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
     2  
     3  package lambda_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/lambda"
    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 add permissions to a layer version
    29  //
    30  // The following example grants permission for the account 223456789012 to use version
    31  // 1 of a layer named my-layer.
    32  func ExampleLambda_AddLayerVersionPermission_shared00() {
    33  	svc := lambda.New(session.New())
    34  	input := &lambda.AddLayerVersionPermissionInput{
    35  		Action:        aws.String("lambda:GetLayerVersion"),
    36  		LayerName:     aws.String("my-layer"),
    37  		Principal:     aws.String("223456789012"),
    38  		StatementId:   aws.String("xaccount"),
    39  		VersionNumber: aws.Int64(1),
    40  	}
    41  
    42  	result, err := svc.AddLayerVersionPermission(input)
    43  	if err != nil {
    44  		if aerr, ok := err.(awserr.Error); ok {
    45  			switch aerr.Code() {
    46  			case lambda.ErrCodeServiceException:
    47  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
    48  			case lambda.ErrCodeResourceNotFoundException:
    49  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
    50  			case lambda.ErrCodeResourceConflictException:
    51  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
    52  			case lambda.ErrCodeTooManyRequestsException:
    53  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
    54  			case lambda.ErrCodeInvalidParameterValueException:
    55  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
    56  			case lambda.ErrCodePolicyLengthExceededException:
    57  				fmt.Println(lambda.ErrCodePolicyLengthExceededException, aerr.Error())
    58  			case lambda.ErrCodePreconditionFailedException:
    59  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
    60  			default:
    61  				fmt.Println(aerr.Error())
    62  			}
    63  		} else {
    64  			// Print the error, cast err to awserr.Error to get the Code and
    65  			// Message from an error.
    66  			fmt.Println(err.Error())
    67  		}
    68  		return
    69  	}
    70  
    71  	fmt.Println(result)
    72  }
    73  
    74  // To grant Amazon S3 permission to invoke a function
    75  //
    76  // The following example adds permission for Amazon S3 to invoke a Lambda function named
    77  // my-function for notifications from a bucket named my-bucket-1xpuxmplzrlbh in account
    78  // 123456789012.
    79  func ExampleLambda_AddPermission_shared00() {
    80  	svc := lambda.New(session.New())
    81  	input := &lambda.AddPermissionInput{
    82  		Action:        aws.String("lambda:InvokeFunction"),
    83  		FunctionName:  aws.String("my-function"),
    84  		Principal:     aws.String("s3.amazonaws.com"),
    85  		SourceAccount: aws.String("123456789012"),
    86  		SourceArn:     aws.String("arn:aws:s3:::my-bucket-1xpuxmplzrlbh/*"),
    87  		StatementId:   aws.String("s3"),
    88  	}
    89  
    90  	result, err := svc.AddPermission(input)
    91  	if err != nil {
    92  		if aerr, ok := err.(awserr.Error); ok {
    93  			switch aerr.Code() {
    94  			case lambda.ErrCodeServiceException:
    95  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
    96  			case lambda.ErrCodeResourceNotFoundException:
    97  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
    98  			case lambda.ErrCodeResourceConflictException:
    99  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   100  			case lambda.ErrCodeInvalidParameterValueException:
   101  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   102  			case lambda.ErrCodePolicyLengthExceededException:
   103  				fmt.Println(lambda.ErrCodePolicyLengthExceededException, aerr.Error())
   104  			case lambda.ErrCodeTooManyRequestsException:
   105  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   106  			case lambda.ErrCodePreconditionFailedException:
   107  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
   108  			default:
   109  				fmt.Println(aerr.Error())
   110  			}
   111  		} else {
   112  			// Print the error, cast err to awserr.Error to get the Code and
   113  			// Message from an error.
   114  			fmt.Println(err.Error())
   115  		}
   116  		return
   117  	}
   118  
   119  	fmt.Println(result)
   120  }
   121  
   122  // To grant another account permission to invoke a function
   123  //
   124  // The following example adds permission for account 223456789012 invoke a Lambda function
   125  // named my-function.
   126  func ExampleLambda_AddPermission_shared01() {
   127  	svc := lambda.New(session.New())
   128  	input := &lambda.AddPermissionInput{
   129  		Action:       aws.String("lambda:InvokeFunction"),
   130  		FunctionName: aws.String("my-function"),
   131  		Principal:    aws.String("223456789012"),
   132  		StatementId:  aws.String("xaccount"),
   133  	}
   134  
   135  	result, err := svc.AddPermission(input)
   136  	if err != nil {
   137  		if aerr, ok := err.(awserr.Error); ok {
   138  			switch aerr.Code() {
   139  			case lambda.ErrCodeServiceException:
   140  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   141  			case lambda.ErrCodeResourceNotFoundException:
   142  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   143  			case lambda.ErrCodeResourceConflictException:
   144  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   145  			case lambda.ErrCodeInvalidParameterValueException:
   146  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   147  			case lambda.ErrCodePolicyLengthExceededException:
   148  				fmt.Println(lambda.ErrCodePolicyLengthExceededException, aerr.Error())
   149  			case lambda.ErrCodeTooManyRequestsException:
   150  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   151  			case lambda.ErrCodePreconditionFailedException:
   152  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
   153  			default:
   154  				fmt.Println(aerr.Error())
   155  			}
   156  		} else {
   157  			// Print the error, cast err to awserr.Error to get the Code and
   158  			// Message from an error.
   159  			fmt.Println(err.Error())
   160  		}
   161  		return
   162  	}
   163  
   164  	fmt.Println(result)
   165  }
   166  
   167  // To create an alias for a Lambda function
   168  //
   169  // The following example creates an alias named LIVE that points to version 1 of the
   170  // my-function Lambda function.
   171  func ExampleLambda_CreateAlias_shared00() {
   172  	svc := lambda.New(session.New())
   173  	input := &lambda.CreateAliasInput{
   174  		Description:     aws.String("alias for live version of function"),
   175  		FunctionName:    aws.String("my-function"),
   176  		FunctionVersion: aws.String("1"),
   177  		Name:            aws.String("LIVE"),
   178  	}
   179  
   180  	result, err := svc.CreateAlias(input)
   181  	if err != nil {
   182  		if aerr, ok := err.(awserr.Error); ok {
   183  			switch aerr.Code() {
   184  			case lambda.ErrCodeServiceException:
   185  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   186  			case lambda.ErrCodeResourceNotFoundException:
   187  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   188  			case lambda.ErrCodeResourceConflictException:
   189  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   190  			case lambda.ErrCodeInvalidParameterValueException:
   191  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   192  			case lambda.ErrCodeTooManyRequestsException:
   193  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   194  			default:
   195  				fmt.Println(aerr.Error())
   196  			}
   197  		} else {
   198  			// Print the error, cast err to awserr.Error to get the Code and
   199  			// Message from an error.
   200  			fmt.Println(err.Error())
   201  		}
   202  		return
   203  	}
   204  
   205  	fmt.Println(result)
   206  }
   207  
   208  // To create a mapping between an event source and an AWS Lambda function
   209  //
   210  // The following example creates a mapping between an SQS queue and the my-function
   211  // Lambda function.
   212  func ExampleLambda_CreateEventSourceMapping_shared00() {
   213  	svc := lambda.New(session.New())
   214  	input := &lambda.CreateEventSourceMappingInput{
   215  		BatchSize:      aws.Int64(5),
   216  		EventSourceArn: aws.String("arn:aws:sqs:us-west-2:123456789012:my-queue"),
   217  		FunctionName:   aws.String("my-function"),
   218  	}
   219  
   220  	result, err := svc.CreateEventSourceMapping(input)
   221  	if err != nil {
   222  		if aerr, ok := err.(awserr.Error); ok {
   223  			switch aerr.Code() {
   224  			case lambda.ErrCodeServiceException:
   225  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   226  			case lambda.ErrCodeInvalidParameterValueException:
   227  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   228  			case lambda.ErrCodeResourceConflictException:
   229  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   230  			case lambda.ErrCodeTooManyRequestsException:
   231  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   232  			case lambda.ErrCodeResourceNotFoundException:
   233  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   234  			default:
   235  				fmt.Println(aerr.Error())
   236  			}
   237  		} else {
   238  			// Print the error, cast err to awserr.Error to get the Code and
   239  			// Message from an error.
   240  			fmt.Println(err.Error())
   241  		}
   242  		return
   243  	}
   244  
   245  	fmt.Println(result)
   246  }
   247  
   248  // To create a function
   249  //
   250  // The following example creates a function with a deployment package in Amazon S3 and
   251  // enables X-Ray tracing and environment variable encryption.
   252  func ExampleLambda_CreateFunction_shared00() {
   253  	svc := lambda.New(session.New())
   254  	input := &lambda.CreateFunctionInput{
   255  		Code: &lambda.FunctionCode{
   256  			S3Bucket: aws.String("my-bucket-1xpuxmplzrlbh"),
   257  			S3Key:    aws.String("function.zip"),
   258  		},
   259  		Description: aws.String("Process image objects from Amazon S3."),
   260  		Environment: &lambda.Environment{
   261  			Variables: map[string]*string{
   262  				"BUCKET": aws.String("my-bucket-1xpuxmplzrlbh"),
   263  				"PREFIX": aws.String("inbound"),
   264  			},
   265  		},
   266  		FunctionName: aws.String("my-function"),
   267  		Handler:      aws.String("index.handler"),
   268  		KMSKeyArn:    aws.String("arn:aws:kms:us-west-2:123456789012:key/b0844d6c-xmpl-4463-97a4-d49f50839966"),
   269  		MemorySize:   aws.Int64(256),
   270  		Publish:      aws.Bool(true),
   271  		Role:         aws.String("arn:aws:iam::123456789012:role/lambda-role"),
   272  		Runtime:      aws.String("nodejs12.x"),
   273  		Tags: map[string]*string{
   274  			"DEPARTMENT": aws.String("Assets"),
   275  		},
   276  		Timeout: aws.Int64(15),
   277  		TracingConfig: &lambda.TracingConfig{
   278  			Mode: aws.String("Active"),
   279  		},
   280  	}
   281  
   282  	result, err := svc.CreateFunction(input)
   283  	if err != nil {
   284  		if aerr, ok := err.(awserr.Error); ok {
   285  			switch aerr.Code() {
   286  			case lambda.ErrCodeServiceException:
   287  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   288  			case lambda.ErrCodeInvalidParameterValueException:
   289  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   290  			case lambda.ErrCodeResourceNotFoundException:
   291  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   292  			case lambda.ErrCodeResourceConflictException:
   293  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   294  			case lambda.ErrCodeTooManyRequestsException:
   295  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   296  			case lambda.ErrCodeCodeStorageExceededException:
   297  				fmt.Println(lambda.ErrCodeCodeStorageExceededException, aerr.Error())
   298  			case lambda.ErrCodeCodeVerificationFailedException:
   299  				fmt.Println(lambda.ErrCodeCodeVerificationFailedException, aerr.Error())
   300  			case lambda.ErrCodeInvalidCodeSignatureException:
   301  				fmt.Println(lambda.ErrCodeInvalidCodeSignatureException, aerr.Error())
   302  			case lambda.ErrCodeCodeSigningConfigNotFoundException:
   303  				fmt.Println(lambda.ErrCodeCodeSigningConfigNotFoundException, aerr.Error())
   304  			default:
   305  				fmt.Println(aerr.Error())
   306  			}
   307  		} else {
   308  			// Print the error, cast err to awserr.Error to get the Code and
   309  			// Message from an error.
   310  			fmt.Println(err.Error())
   311  		}
   312  		return
   313  	}
   314  
   315  	fmt.Println(result)
   316  }
   317  
   318  // To delete a Lambda function alias
   319  //
   320  // The following example deletes an alias named BLUE from a function named my-function
   321  func ExampleLambda_DeleteAlias_shared00() {
   322  	svc := lambda.New(session.New())
   323  	input := &lambda.DeleteAliasInput{
   324  		FunctionName: aws.String("my-function"),
   325  		Name:         aws.String("BLUE"),
   326  	}
   327  
   328  	result, err := svc.DeleteAlias(input)
   329  	if err != nil {
   330  		if aerr, ok := err.(awserr.Error); ok {
   331  			switch aerr.Code() {
   332  			case lambda.ErrCodeServiceException:
   333  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   334  			case lambda.ErrCodeInvalidParameterValueException:
   335  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   336  			case lambda.ErrCodeResourceConflictException:
   337  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   338  			case lambda.ErrCodeTooManyRequestsException:
   339  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   340  			default:
   341  				fmt.Println(aerr.Error())
   342  			}
   343  		} else {
   344  			// Print the error, cast err to awserr.Error to get the Code and
   345  			// Message from an error.
   346  			fmt.Println(err.Error())
   347  		}
   348  		return
   349  	}
   350  
   351  	fmt.Println(result)
   352  }
   353  
   354  // To delete a Lambda function event source mapping
   355  //
   356  // The following example deletes an event source mapping. To get a mapping's UUID, use
   357  // ListEventSourceMappings.
   358  func ExampleLambda_DeleteEventSourceMapping_shared00() {
   359  	svc := lambda.New(session.New())
   360  	input := &lambda.DeleteEventSourceMappingInput{
   361  		UUID: aws.String("14e0db71-xmpl-4eb5-b481-8945cf9d10c2"),
   362  	}
   363  
   364  	result, err := svc.DeleteEventSourceMapping(input)
   365  	if err != nil {
   366  		if aerr, ok := err.(awserr.Error); ok {
   367  			switch aerr.Code() {
   368  			case lambda.ErrCodeServiceException:
   369  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   370  			case lambda.ErrCodeResourceNotFoundException:
   371  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   372  			case lambda.ErrCodeInvalidParameterValueException:
   373  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   374  			case lambda.ErrCodeTooManyRequestsException:
   375  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   376  			case lambda.ErrCodeResourceInUseException:
   377  				fmt.Println(lambda.ErrCodeResourceInUseException, aerr.Error())
   378  			default:
   379  				fmt.Println(aerr.Error())
   380  			}
   381  		} else {
   382  			// Print the error, cast err to awserr.Error to get the Code and
   383  			// Message from an error.
   384  			fmt.Println(err.Error())
   385  		}
   386  		return
   387  	}
   388  
   389  	fmt.Println(result)
   390  }
   391  
   392  // To delete a version of a Lambda function
   393  //
   394  // The following example deletes version 1 of a Lambda function named my-function.
   395  func ExampleLambda_DeleteFunction_shared00() {
   396  	svc := lambda.New(session.New())
   397  	input := &lambda.DeleteFunctionInput{
   398  		FunctionName: aws.String("my-function"),
   399  		Qualifier:    aws.String("1"),
   400  	}
   401  
   402  	result, err := svc.DeleteFunction(input)
   403  	if err != nil {
   404  		if aerr, ok := err.(awserr.Error); ok {
   405  			switch aerr.Code() {
   406  			case lambda.ErrCodeServiceException:
   407  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   408  			case lambda.ErrCodeResourceNotFoundException:
   409  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   410  			case lambda.ErrCodeTooManyRequestsException:
   411  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   412  			case lambda.ErrCodeInvalidParameterValueException:
   413  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   414  			case lambda.ErrCodeResourceConflictException:
   415  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   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 remove the reserved concurrent execution limit from a function
   431  //
   432  // The following example deletes the reserved concurrent execution limit from a function
   433  // named my-function.
   434  func ExampleLambda_DeleteFunctionConcurrency_shared00() {
   435  	svc := lambda.New(session.New())
   436  	input := &lambda.DeleteFunctionConcurrencyInput{
   437  		FunctionName: aws.String("my-function"),
   438  	}
   439  
   440  	result, err := svc.DeleteFunctionConcurrency(input)
   441  	if err != nil {
   442  		if aerr, ok := err.(awserr.Error); ok {
   443  			switch aerr.Code() {
   444  			case lambda.ErrCodeServiceException:
   445  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   446  			case lambda.ErrCodeResourceNotFoundException:
   447  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   448  			case lambda.ErrCodeTooManyRequestsException:
   449  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   450  			case lambda.ErrCodeInvalidParameterValueException:
   451  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   452  			case lambda.ErrCodeResourceConflictException:
   453  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   454  			default:
   455  				fmt.Println(aerr.Error())
   456  			}
   457  		} else {
   458  			// Print the error, cast err to awserr.Error to get the Code and
   459  			// Message from an error.
   460  			fmt.Println(err.Error())
   461  		}
   462  		return
   463  	}
   464  
   465  	fmt.Println(result)
   466  }
   467  
   468  // To delete an asynchronous invocation configuration
   469  //
   470  // The following example deletes the asynchronous invocation configuration for the GREEN
   471  // alias of a function named my-function.
   472  func ExampleLambda_DeleteFunctionEventInvokeConfig_shared00() {
   473  	svc := lambda.New(session.New())
   474  	input := &lambda.DeleteFunctionEventInvokeConfigInput{
   475  		FunctionName: aws.String("my-function"),
   476  		Qualifier:    aws.String("GREEN"),
   477  	}
   478  
   479  	result, err := svc.DeleteFunctionEventInvokeConfig(input)
   480  	if err != nil {
   481  		if aerr, ok := err.(awserr.Error); ok {
   482  			switch aerr.Code() {
   483  			case lambda.ErrCodeServiceException:
   484  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   485  			case lambda.ErrCodeResourceNotFoundException:
   486  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   487  			case lambda.ErrCodeInvalidParameterValueException:
   488  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   489  			case lambda.ErrCodeTooManyRequestsException:
   490  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   491  			default:
   492  				fmt.Println(aerr.Error())
   493  			}
   494  		} else {
   495  			// Print the error, cast err to awserr.Error to get the Code and
   496  			// Message from an error.
   497  			fmt.Println(err.Error())
   498  		}
   499  		return
   500  	}
   501  
   502  	fmt.Println(result)
   503  }
   504  
   505  // To delete a version of a Lambda layer
   506  //
   507  // The following example deletes version 2 of a layer named my-layer.
   508  func ExampleLambda_DeleteLayerVersion_shared00() {
   509  	svc := lambda.New(session.New())
   510  	input := &lambda.DeleteLayerVersionInput{
   511  		LayerName:     aws.String("my-layer"),
   512  		VersionNumber: aws.Int64(2),
   513  	}
   514  
   515  	result, err := svc.DeleteLayerVersion(input)
   516  	if err != nil {
   517  		if aerr, ok := err.(awserr.Error); ok {
   518  			switch aerr.Code() {
   519  			case lambda.ErrCodeServiceException:
   520  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   521  			case lambda.ErrCodeTooManyRequestsException:
   522  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   523  			default:
   524  				fmt.Println(aerr.Error())
   525  			}
   526  		} else {
   527  			// Print the error, cast err to awserr.Error to get the Code and
   528  			// Message from an error.
   529  			fmt.Println(err.Error())
   530  		}
   531  		return
   532  	}
   533  
   534  	fmt.Println(result)
   535  }
   536  
   537  // To delete a provisioned concurrency configuration
   538  //
   539  // The following example deletes the provisioned concurrency configuration for the GREEN
   540  // alias of a function named my-function.
   541  func ExampleLambda_DeleteProvisionedConcurrencyConfig_shared00() {
   542  	svc := lambda.New(session.New())
   543  	input := &lambda.DeleteProvisionedConcurrencyConfigInput{
   544  		FunctionName: aws.String("my-function"),
   545  		Qualifier:    aws.String("GREEN"),
   546  	}
   547  
   548  	result, err := svc.DeleteProvisionedConcurrencyConfig(input)
   549  	if err != nil {
   550  		if aerr, ok := err.(awserr.Error); ok {
   551  			switch aerr.Code() {
   552  			case lambda.ErrCodeInvalidParameterValueException:
   553  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   554  			case lambda.ErrCodeResourceConflictException:
   555  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
   556  			case lambda.ErrCodeResourceNotFoundException:
   557  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   558  			case lambda.ErrCodeTooManyRequestsException:
   559  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   560  			case lambda.ErrCodeServiceException:
   561  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   562  			default:
   563  				fmt.Println(aerr.Error())
   564  			}
   565  		} else {
   566  			// Print the error, cast err to awserr.Error to get the Code and
   567  			// Message from an error.
   568  			fmt.Println(err.Error())
   569  		}
   570  		return
   571  	}
   572  
   573  	fmt.Println(result)
   574  }
   575  
   576  // To get account settings
   577  //
   578  // This operation takes no parameters and returns details about storage and concurrency
   579  // quotas in the current Region.
   580  func ExampleLambda_GetAccountSettings_shared00() {
   581  	svc := lambda.New(session.New())
   582  	input := &lambda.GetAccountSettingsInput{}
   583  
   584  	result, err := svc.GetAccountSettings(input)
   585  	if err != nil {
   586  		if aerr, ok := err.(awserr.Error); ok {
   587  			switch aerr.Code() {
   588  			case lambda.ErrCodeTooManyRequestsException:
   589  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   590  			case lambda.ErrCodeServiceException:
   591  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   592  			default:
   593  				fmt.Println(aerr.Error())
   594  			}
   595  		} else {
   596  			// Print the error, cast err to awserr.Error to get the Code and
   597  			// Message from an error.
   598  			fmt.Println(err.Error())
   599  		}
   600  		return
   601  	}
   602  
   603  	fmt.Println(result)
   604  }
   605  
   606  // To get a Lambda function alias
   607  //
   608  // The following example returns details about an alias named BLUE for a function named
   609  // my-function
   610  func ExampleLambda_GetAlias_shared00() {
   611  	svc := lambda.New(session.New())
   612  	input := &lambda.GetAliasInput{
   613  		FunctionName: aws.String("my-function"),
   614  		Name:         aws.String("BLUE"),
   615  	}
   616  
   617  	result, err := svc.GetAlias(input)
   618  	if err != nil {
   619  		if aerr, ok := err.(awserr.Error); ok {
   620  			switch aerr.Code() {
   621  			case lambda.ErrCodeServiceException:
   622  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   623  			case lambda.ErrCodeResourceNotFoundException:
   624  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   625  			case lambda.ErrCodeInvalidParameterValueException:
   626  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   627  			case lambda.ErrCodeTooManyRequestsException:
   628  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   629  			default:
   630  				fmt.Println(aerr.Error())
   631  			}
   632  		} else {
   633  			// Print the error, cast err to awserr.Error to get the Code and
   634  			// Message from an error.
   635  			fmt.Println(err.Error())
   636  		}
   637  		return
   638  	}
   639  
   640  	fmt.Println(result)
   641  }
   642  
   643  // To get a Lambda function's event source mapping
   644  //
   645  // The following example returns details about an event source mapping. To get a mapping's
   646  // UUID, use ListEventSourceMappings.
   647  func ExampleLambda_GetEventSourceMapping_shared00() {
   648  	svc := lambda.New(session.New())
   649  	input := &lambda.GetEventSourceMappingInput{
   650  		UUID: aws.String("14e0db71-xmpl-4eb5-b481-8945cf9d10c2"),
   651  	}
   652  
   653  	result, err := svc.GetEventSourceMapping(input)
   654  	if err != nil {
   655  		if aerr, ok := err.(awserr.Error); ok {
   656  			switch aerr.Code() {
   657  			case lambda.ErrCodeServiceException:
   658  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   659  			case lambda.ErrCodeResourceNotFoundException:
   660  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   661  			case lambda.ErrCodeInvalidParameterValueException:
   662  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   663  			case lambda.ErrCodeTooManyRequestsException:
   664  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   665  			default:
   666  				fmt.Println(aerr.Error())
   667  			}
   668  		} else {
   669  			// Print the error, cast err to awserr.Error to get the Code and
   670  			// Message from an error.
   671  			fmt.Println(err.Error())
   672  		}
   673  		return
   674  	}
   675  
   676  	fmt.Println(result)
   677  }
   678  
   679  // To get a Lambda function
   680  //
   681  // The following example returns code and configuration details for version 1 of a function
   682  // named my-function.
   683  func ExampleLambda_GetFunction_shared00() {
   684  	svc := lambda.New(session.New())
   685  	input := &lambda.GetFunctionInput{
   686  		FunctionName: aws.String("my-function"),
   687  		Qualifier:    aws.String("1"),
   688  	}
   689  
   690  	result, err := svc.GetFunction(input)
   691  	if err != nil {
   692  		if aerr, ok := err.(awserr.Error); ok {
   693  			switch aerr.Code() {
   694  			case lambda.ErrCodeServiceException:
   695  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   696  			case lambda.ErrCodeResourceNotFoundException:
   697  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   698  			case lambda.ErrCodeTooManyRequestsException:
   699  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   700  			case lambda.ErrCodeInvalidParameterValueException:
   701  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   702  			default:
   703  				fmt.Println(aerr.Error())
   704  			}
   705  		} else {
   706  			// Print the error, cast err to awserr.Error to get the Code and
   707  			// Message from an error.
   708  			fmt.Println(err.Error())
   709  		}
   710  		return
   711  	}
   712  
   713  	fmt.Println(result)
   714  }
   715  
   716  // To get the reserved concurrency setting for a function
   717  //
   718  // The following example returns the reserved concurrency setting for a function named
   719  // my-function.
   720  func ExampleLambda_GetFunctionConcurrency_shared00() {
   721  	svc := lambda.New(session.New())
   722  	input := &lambda.GetFunctionConcurrencyInput{
   723  		FunctionName: aws.String("my-function"),
   724  	}
   725  
   726  	result, err := svc.GetFunctionConcurrency(input)
   727  	if err != nil {
   728  		if aerr, ok := err.(awserr.Error); ok {
   729  			switch aerr.Code() {
   730  			case lambda.ErrCodeInvalidParameterValueException:
   731  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   732  			case lambda.ErrCodeResourceNotFoundException:
   733  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   734  			case lambda.ErrCodeTooManyRequestsException:
   735  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   736  			case lambda.ErrCodeServiceException:
   737  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   738  			default:
   739  				fmt.Println(aerr.Error())
   740  			}
   741  		} else {
   742  			// Print the error, cast err to awserr.Error to get the Code and
   743  			// Message from an error.
   744  			fmt.Println(err.Error())
   745  		}
   746  		return
   747  	}
   748  
   749  	fmt.Println(result)
   750  }
   751  
   752  // To get a Lambda function's event source mapping
   753  //
   754  // The following example returns and configuration details for version 1 of a function
   755  // named my-function.
   756  func ExampleLambda_GetFunctionConfiguration_shared00() {
   757  	svc := lambda.New(session.New())
   758  	input := &lambda.GetFunctionConfigurationInput{
   759  		FunctionName: aws.String("my-function"),
   760  		Qualifier:    aws.String("1"),
   761  	}
   762  
   763  	result, err := svc.GetFunctionConfiguration(input)
   764  	if err != nil {
   765  		if aerr, ok := err.(awserr.Error); ok {
   766  			switch aerr.Code() {
   767  			case lambda.ErrCodeServiceException:
   768  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   769  			case lambda.ErrCodeResourceNotFoundException:
   770  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   771  			case lambda.ErrCodeTooManyRequestsException:
   772  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   773  			case lambda.ErrCodeInvalidParameterValueException:
   774  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   775  			default:
   776  				fmt.Println(aerr.Error())
   777  			}
   778  		} else {
   779  			// Print the error, cast err to awserr.Error to get the Code and
   780  			// Message from an error.
   781  			fmt.Println(err.Error())
   782  		}
   783  		return
   784  	}
   785  
   786  	fmt.Println(result)
   787  }
   788  
   789  // To get an asynchronous invocation configuration
   790  //
   791  // The following example returns the asynchronous invocation configuration for the BLUE
   792  // alias of a function named my-function.
   793  func ExampleLambda_GetFunctionEventInvokeConfig_shared00() {
   794  	svc := lambda.New(session.New())
   795  	input := &lambda.GetFunctionEventInvokeConfigInput{
   796  		FunctionName: aws.String("my-function"),
   797  		Qualifier:    aws.String("BLUE"),
   798  	}
   799  
   800  	result, err := svc.GetFunctionEventInvokeConfig(input)
   801  	if err != nil {
   802  		if aerr, ok := err.(awserr.Error); ok {
   803  			switch aerr.Code() {
   804  			case lambda.ErrCodeServiceException:
   805  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   806  			case lambda.ErrCodeResourceNotFoundException:
   807  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   808  			case lambda.ErrCodeInvalidParameterValueException:
   809  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   810  			case lambda.ErrCodeTooManyRequestsException:
   811  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   812  			default:
   813  				fmt.Println(aerr.Error())
   814  			}
   815  		} else {
   816  			// Print the error, cast err to awserr.Error to get the Code and
   817  			// Message from an error.
   818  			fmt.Println(err.Error())
   819  		}
   820  		return
   821  	}
   822  
   823  	fmt.Println(result)
   824  }
   825  
   826  // To get information about a Lambda layer version
   827  //
   828  // The following example returns information for version 1 of a layer named my-layer.
   829  func ExampleLambda_GetLayerVersion_shared00() {
   830  	svc := lambda.New(session.New())
   831  	input := &lambda.GetLayerVersionInput{
   832  		LayerName:     aws.String("my-layer"),
   833  		VersionNumber: aws.Int64(1),
   834  	}
   835  
   836  	result, err := svc.GetLayerVersion(input)
   837  	if err != nil {
   838  		if aerr, ok := err.(awserr.Error); ok {
   839  			switch aerr.Code() {
   840  			case lambda.ErrCodeServiceException:
   841  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   842  			case lambda.ErrCodeInvalidParameterValueException:
   843  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   844  			case lambda.ErrCodeTooManyRequestsException:
   845  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   846  			case lambda.ErrCodeResourceNotFoundException:
   847  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   848  			default:
   849  				fmt.Println(aerr.Error())
   850  			}
   851  		} else {
   852  			// Print the error, cast err to awserr.Error to get the Code and
   853  			// Message from an error.
   854  			fmt.Println(err.Error())
   855  		}
   856  		return
   857  	}
   858  
   859  	fmt.Println(result)
   860  }
   861  
   862  // To get information about a Lambda layer version
   863  //
   864  // The following example returns information about the layer version with the specified
   865  // Amazon Resource Name (ARN).
   866  func ExampleLambda_GetLayerVersionByArn_shared00() {
   867  	svc := lambda.New(session.New())
   868  	input := &lambda.GetLayerVersionByArnInput{
   869  		Arn: aws.String("arn:aws:lambda:ca-central-1:123456789012:layer:blank-python-lib:3"),
   870  	}
   871  
   872  	result, err := svc.GetLayerVersionByArn(input)
   873  	if err != nil {
   874  		if aerr, ok := err.(awserr.Error); ok {
   875  			switch aerr.Code() {
   876  			case lambda.ErrCodeServiceException:
   877  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   878  			case lambda.ErrCodeInvalidParameterValueException:
   879  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   880  			case lambda.ErrCodeTooManyRequestsException:
   881  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   882  			case lambda.ErrCodeResourceNotFoundException:
   883  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   884  			default:
   885  				fmt.Println(aerr.Error())
   886  			}
   887  		} else {
   888  			// Print the error, cast err to awserr.Error to get the Code and
   889  			// Message from an error.
   890  			fmt.Println(err.Error())
   891  		}
   892  		return
   893  	}
   894  
   895  	fmt.Println(result)
   896  }
   897  
   898  // To retrieve a Lambda function policy
   899  //
   900  // The following example returns the resource-based policy for version 1 of a Lambda
   901  // function named my-function.
   902  func ExampleLambda_GetPolicy_shared00() {
   903  	svc := lambda.New(session.New())
   904  	input := &lambda.GetPolicyInput{
   905  		FunctionName: aws.String("my-function"),
   906  		Qualifier:    aws.String("1"),
   907  	}
   908  
   909  	result, err := svc.GetPolicy(input)
   910  	if err != nil {
   911  		if aerr, ok := err.(awserr.Error); ok {
   912  			switch aerr.Code() {
   913  			case lambda.ErrCodeServiceException:
   914  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   915  			case lambda.ErrCodeResourceNotFoundException:
   916  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   917  			case lambda.ErrCodeTooManyRequestsException:
   918  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   919  			case lambda.ErrCodeInvalidParameterValueException:
   920  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   921  			default:
   922  				fmt.Println(aerr.Error())
   923  			}
   924  		} else {
   925  			// Print the error, cast err to awserr.Error to get the Code and
   926  			// Message from an error.
   927  			fmt.Println(err.Error())
   928  		}
   929  		return
   930  	}
   931  
   932  	fmt.Println(result)
   933  }
   934  
   935  // To get a provisioned concurrency configuration
   936  //
   937  // The following example returns details for the provisioned concurrency configuration
   938  // for the BLUE alias of the specified function.
   939  func ExampleLambda_GetProvisionedConcurrencyConfig_shared00() {
   940  	svc := lambda.New(session.New())
   941  	input := &lambda.GetProvisionedConcurrencyConfigInput{
   942  		FunctionName: aws.String("my-function"),
   943  		Qualifier:    aws.String("BLUE"),
   944  	}
   945  
   946  	result, err := svc.GetProvisionedConcurrencyConfig(input)
   947  	if err != nil {
   948  		if aerr, ok := err.(awserr.Error); ok {
   949  			switch aerr.Code() {
   950  			case lambda.ErrCodeInvalidParameterValueException:
   951  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   952  			case lambda.ErrCodeResourceNotFoundException:
   953  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   954  			case lambda.ErrCodeTooManyRequestsException:
   955  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   956  			case lambda.ErrCodeServiceException:
   957  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   958  			case lambda.ErrCodeProvisionedConcurrencyConfigNotFoundException:
   959  				fmt.Println(lambda.ErrCodeProvisionedConcurrencyConfigNotFoundException, aerr.Error())
   960  			default:
   961  				fmt.Println(aerr.Error())
   962  			}
   963  		} else {
   964  			// Print the error, cast err to awserr.Error to get the Code and
   965  			// Message from an error.
   966  			fmt.Println(err.Error())
   967  		}
   968  		return
   969  	}
   970  
   971  	fmt.Println(result)
   972  }
   973  
   974  // To view a provisioned concurrency configuration
   975  //
   976  // The following example displays details for the provisioned concurrency configuration
   977  // for the BLUE alias of the specified function.
   978  func ExampleLambda_GetProvisionedConcurrencyConfig_shared01() {
   979  	svc := lambda.New(session.New())
   980  	input := &lambda.GetProvisionedConcurrencyConfigInput{
   981  		FunctionName: aws.String("my-function"),
   982  		Qualifier:    aws.String("BLUE"),
   983  	}
   984  
   985  	result, err := svc.GetProvisionedConcurrencyConfig(input)
   986  	if err != nil {
   987  		if aerr, ok := err.(awserr.Error); ok {
   988  			switch aerr.Code() {
   989  			case lambda.ErrCodeInvalidParameterValueException:
   990  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
   991  			case lambda.ErrCodeResourceNotFoundException:
   992  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
   993  			case lambda.ErrCodeTooManyRequestsException:
   994  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
   995  			case lambda.ErrCodeServiceException:
   996  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
   997  			case lambda.ErrCodeProvisionedConcurrencyConfigNotFoundException:
   998  				fmt.Println(lambda.ErrCodeProvisionedConcurrencyConfigNotFoundException, aerr.Error())
   999  			default:
  1000  				fmt.Println(aerr.Error())
  1001  			}
  1002  		} else {
  1003  			// Print the error, cast err to awserr.Error to get the Code and
  1004  			// Message from an error.
  1005  			fmt.Println(err.Error())
  1006  		}
  1007  		return
  1008  	}
  1009  
  1010  	fmt.Println(result)
  1011  }
  1012  
  1013  // To invoke a Lambda function
  1014  //
  1015  // The following example invokes version 1 of a function named my-function with an empty
  1016  // event payload.
  1017  func ExampleLambda_Invoke_shared00() {
  1018  	svc := lambda.New(session.New())
  1019  	input := &lambda.InvokeInput{
  1020  		FunctionName: aws.String("my-function"),
  1021  		Payload:      []byte("{}"),
  1022  		Qualifier:    aws.String("1"),
  1023  	}
  1024  
  1025  	result, err := svc.Invoke(input)
  1026  	if err != nil {
  1027  		if aerr, ok := err.(awserr.Error); ok {
  1028  			switch aerr.Code() {
  1029  			case lambda.ErrCodeServiceException:
  1030  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1031  			case lambda.ErrCodeResourceNotFoundException:
  1032  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1033  			case lambda.ErrCodeInvalidRequestContentException:
  1034  				fmt.Println(lambda.ErrCodeInvalidRequestContentException, aerr.Error())
  1035  			case lambda.ErrCodeRequestTooLargeException:
  1036  				fmt.Println(lambda.ErrCodeRequestTooLargeException, aerr.Error())
  1037  			case lambda.ErrCodeUnsupportedMediaTypeException:
  1038  				fmt.Println(lambda.ErrCodeUnsupportedMediaTypeException, aerr.Error())
  1039  			case lambda.ErrCodeTooManyRequestsException:
  1040  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1041  			case lambda.ErrCodeInvalidParameterValueException:
  1042  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1043  			case lambda.ErrCodeEC2UnexpectedException:
  1044  				fmt.Println(lambda.ErrCodeEC2UnexpectedException, aerr.Error())
  1045  			case lambda.ErrCodeSubnetIPAddressLimitReachedException:
  1046  				fmt.Println(lambda.ErrCodeSubnetIPAddressLimitReachedException, aerr.Error())
  1047  			case lambda.ErrCodeENILimitReachedException:
  1048  				fmt.Println(lambda.ErrCodeENILimitReachedException, aerr.Error())
  1049  			case lambda.ErrCodeEFSMountConnectivityException:
  1050  				fmt.Println(lambda.ErrCodeEFSMountConnectivityException, aerr.Error())
  1051  			case lambda.ErrCodeEFSMountFailureException:
  1052  				fmt.Println(lambda.ErrCodeEFSMountFailureException, aerr.Error())
  1053  			case lambda.ErrCodeEFSMountTimeoutException:
  1054  				fmt.Println(lambda.ErrCodeEFSMountTimeoutException, aerr.Error())
  1055  			case lambda.ErrCodeEFSIOException:
  1056  				fmt.Println(lambda.ErrCodeEFSIOException, aerr.Error())
  1057  			case lambda.ErrCodeEC2ThrottledException:
  1058  				fmt.Println(lambda.ErrCodeEC2ThrottledException, aerr.Error())
  1059  			case lambda.ErrCodeEC2AccessDeniedException:
  1060  				fmt.Println(lambda.ErrCodeEC2AccessDeniedException, aerr.Error())
  1061  			case lambda.ErrCodeInvalidSubnetIDException:
  1062  				fmt.Println(lambda.ErrCodeInvalidSubnetIDException, aerr.Error())
  1063  			case lambda.ErrCodeInvalidSecurityGroupIDException:
  1064  				fmt.Println(lambda.ErrCodeInvalidSecurityGroupIDException, aerr.Error())
  1065  			case lambda.ErrCodeInvalidZipFileException:
  1066  				fmt.Println(lambda.ErrCodeInvalidZipFileException, aerr.Error())
  1067  			case lambda.ErrCodeKMSDisabledException:
  1068  				fmt.Println(lambda.ErrCodeKMSDisabledException, aerr.Error())
  1069  			case lambda.ErrCodeKMSInvalidStateException:
  1070  				fmt.Println(lambda.ErrCodeKMSInvalidStateException, aerr.Error())
  1071  			case lambda.ErrCodeKMSAccessDeniedException:
  1072  				fmt.Println(lambda.ErrCodeKMSAccessDeniedException, aerr.Error())
  1073  			case lambda.ErrCodeKMSNotFoundException:
  1074  				fmt.Println(lambda.ErrCodeKMSNotFoundException, aerr.Error())
  1075  			case lambda.ErrCodeInvalidRuntimeException:
  1076  				fmt.Println(lambda.ErrCodeInvalidRuntimeException, aerr.Error())
  1077  			case lambda.ErrCodeResourceConflictException:
  1078  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1079  			case lambda.ErrCodeResourceNotReadyException:
  1080  				fmt.Println(lambda.ErrCodeResourceNotReadyException, aerr.Error())
  1081  			default:
  1082  				fmt.Println(aerr.Error())
  1083  			}
  1084  		} else {
  1085  			// Print the error, cast err to awserr.Error to get the Code and
  1086  			// Message from an error.
  1087  			fmt.Println(err.Error())
  1088  		}
  1089  		return
  1090  	}
  1091  
  1092  	fmt.Println(result)
  1093  }
  1094  
  1095  // To invoke a Lambda function asynchronously
  1096  //
  1097  // The following example invokes version 1 of a function named my-function asynchronously.
  1098  func ExampleLambda_Invoke_shared01() {
  1099  	svc := lambda.New(session.New())
  1100  	input := &lambda.InvokeInput{
  1101  		FunctionName:   aws.String("my-function"),
  1102  		InvocationType: aws.String("Event"),
  1103  		Payload:        []byte("{}"),
  1104  		Qualifier:      aws.String("1"),
  1105  	}
  1106  
  1107  	result, err := svc.Invoke(input)
  1108  	if err != nil {
  1109  		if aerr, ok := err.(awserr.Error); ok {
  1110  			switch aerr.Code() {
  1111  			case lambda.ErrCodeServiceException:
  1112  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1113  			case lambda.ErrCodeResourceNotFoundException:
  1114  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1115  			case lambda.ErrCodeInvalidRequestContentException:
  1116  				fmt.Println(lambda.ErrCodeInvalidRequestContentException, aerr.Error())
  1117  			case lambda.ErrCodeRequestTooLargeException:
  1118  				fmt.Println(lambda.ErrCodeRequestTooLargeException, aerr.Error())
  1119  			case lambda.ErrCodeUnsupportedMediaTypeException:
  1120  				fmt.Println(lambda.ErrCodeUnsupportedMediaTypeException, aerr.Error())
  1121  			case lambda.ErrCodeTooManyRequestsException:
  1122  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1123  			case lambda.ErrCodeInvalidParameterValueException:
  1124  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1125  			case lambda.ErrCodeEC2UnexpectedException:
  1126  				fmt.Println(lambda.ErrCodeEC2UnexpectedException, aerr.Error())
  1127  			case lambda.ErrCodeSubnetIPAddressLimitReachedException:
  1128  				fmt.Println(lambda.ErrCodeSubnetIPAddressLimitReachedException, aerr.Error())
  1129  			case lambda.ErrCodeENILimitReachedException:
  1130  				fmt.Println(lambda.ErrCodeENILimitReachedException, aerr.Error())
  1131  			case lambda.ErrCodeEFSMountConnectivityException:
  1132  				fmt.Println(lambda.ErrCodeEFSMountConnectivityException, aerr.Error())
  1133  			case lambda.ErrCodeEFSMountFailureException:
  1134  				fmt.Println(lambda.ErrCodeEFSMountFailureException, aerr.Error())
  1135  			case lambda.ErrCodeEFSMountTimeoutException:
  1136  				fmt.Println(lambda.ErrCodeEFSMountTimeoutException, aerr.Error())
  1137  			case lambda.ErrCodeEFSIOException:
  1138  				fmt.Println(lambda.ErrCodeEFSIOException, aerr.Error())
  1139  			case lambda.ErrCodeEC2ThrottledException:
  1140  				fmt.Println(lambda.ErrCodeEC2ThrottledException, aerr.Error())
  1141  			case lambda.ErrCodeEC2AccessDeniedException:
  1142  				fmt.Println(lambda.ErrCodeEC2AccessDeniedException, aerr.Error())
  1143  			case lambda.ErrCodeInvalidSubnetIDException:
  1144  				fmt.Println(lambda.ErrCodeInvalidSubnetIDException, aerr.Error())
  1145  			case lambda.ErrCodeInvalidSecurityGroupIDException:
  1146  				fmt.Println(lambda.ErrCodeInvalidSecurityGroupIDException, aerr.Error())
  1147  			case lambda.ErrCodeInvalidZipFileException:
  1148  				fmt.Println(lambda.ErrCodeInvalidZipFileException, aerr.Error())
  1149  			case lambda.ErrCodeKMSDisabledException:
  1150  				fmt.Println(lambda.ErrCodeKMSDisabledException, aerr.Error())
  1151  			case lambda.ErrCodeKMSInvalidStateException:
  1152  				fmt.Println(lambda.ErrCodeKMSInvalidStateException, aerr.Error())
  1153  			case lambda.ErrCodeKMSAccessDeniedException:
  1154  				fmt.Println(lambda.ErrCodeKMSAccessDeniedException, aerr.Error())
  1155  			case lambda.ErrCodeKMSNotFoundException:
  1156  				fmt.Println(lambda.ErrCodeKMSNotFoundException, aerr.Error())
  1157  			case lambda.ErrCodeInvalidRuntimeException:
  1158  				fmt.Println(lambda.ErrCodeInvalidRuntimeException, aerr.Error())
  1159  			case lambda.ErrCodeResourceConflictException:
  1160  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1161  			case lambda.ErrCodeResourceNotReadyException:
  1162  				fmt.Println(lambda.ErrCodeResourceNotReadyException, aerr.Error())
  1163  			default:
  1164  				fmt.Println(aerr.Error())
  1165  			}
  1166  		} else {
  1167  			// Print the error, cast err to awserr.Error to get the Code and
  1168  			// Message from an error.
  1169  			fmt.Println(err.Error())
  1170  		}
  1171  		return
  1172  	}
  1173  
  1174  	fmt.Println(result)
  1175  }
  1176  
  1177  // To invoke a Lambda function asynchronously
  1178  //
  1179  // The following example invokes a Lambda function asynchronously
  1180  func ExampleLambda_InvokeAsync_shared00() {
  1181  	svc := lambda.New(session.New())
  1182  	input := &lambda.InvokeAsyncInput{
  1183  		FunctionName: aws.String("my-function"),
  1184  		InvokeArgs:   aws.ReadSeekCloser(strings.NewReader("{}")),
  1185  	}
  1186  
  1187  	result, err := svc.InvokeAsync(input)
  1188  	if err != nil {
  1189  		if aerr, ok := err.(awserr.Error); ok {
  1190  			switch aerr.Code() {
  1191  			case lambda.ErrCodeServiceException:
  1192  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1193  			case lambda.ErrCodeResourceNotFoundException:
  1194  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1195  			case lambda.ErrCodeInvalidRequestContentException:
  1196  				fmt.Println(lambda.ErrCodeInvalidRequestContentException, aerr.Error())
  1197  			case lambda.ErrCodeInvalidRuntimeException:
  1198  				fmt.Println(lambda.ErrCodeInvalidRuntimeException, aerr.Error())
  1199  			case lambda.ErrCodeResourceConflictException:
  1200  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1201  			default:
  1202  				fmt.Println(aerr.Error())
  1203  			}
  1204  		} else {
  1205  			// Print the error, cast err to awserr.Error to get the Code and
  1206  			// Message from an error.
  1207  			fmt.Println(err.Error())
  1208  		}
  1209  		return
  1210  	}
  1211  
  1212  	fmt.Println(result)
  1213  }
  1214  
  1215  // To list a function's aliases
  1216  //
  1217  // The following example returns a list of aliases for a function named my-function.
  1218  func ExampleLambda_ListAliases_shared00() {
  1219  	svc := lambda.New(session.New())
  1220  	input := &lambda.ListAliasesInput{
  1221  		FunctionName: aws.String("my-function"),
  1222  	}
  1223  
  1224  	result, err := svc.ListAliases(input)
  1225  	if err != nil {
  1226  		if aerr, ok := err.(awserr.Error); ok {
  1227  			switch aerr.Code() {
  1228  			case lambda.ErrCodeServiceException:
  1229  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1230  			case lambda.ErrCodeResourceNotFoundException:
  1231  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1232  			case lambda.ErrCodeInvalidParameterValueException:
  1233  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1234  			case lambda.ErrCodeTooManyRequestsException:
  1235  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1236  			default:
  1237  				fmt.Println(aerr.Error())
  1238  			}
  1239  		} else {
  1240  			// Print the error, cast err to awserr.Error to get the Code and
  1241  			// Message from an error.
  1242  			fmt.Println(err.Error())
  1243  		}
  1244  		return
  1245  	}
  1246  
  1247  	fmt.Println(result)
  1248  }
  1249  
  1250  // To list the event source mappings for a function
  1251  //
  1252  // The following example returns a list of the event source mappings for a function
  1253  // named my-function.
  1254  func ExampleLambda_ListEventSourceMappings_shared00() {
  1255  	svc := lambda.New(session.New())
  1256  	input := &lambda.ListEventSourceMappingsInput{
  1257  		FunctionName: aws.String("my-function"),
  1258  	}
  1259  
  1260  	result, err := svc.ListEventSourceMappings(input)
  1261  	if err != nil {
  1262  		if aerr, ok := err.(awserr.Error); ok {
  1263  			switch aerr.Code() {
  1264  			case lambda.ErrCodeServiceException:
  1265  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1266  			case lambda.ErrCodeResourceNotFoundException:
  1267  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1268  			case lambda.ErrCodeInvalidParameterValueException:
  1269  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1270  			case lambda.ErrCodeTooManyRequestsException:
  1271  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1272  			default:
  1273  				fmt.Println(aerr.Error())
  1274  			}
  1275  		} else {
  1276  			// Print the error, cast err to awserr.Error to get the Code and
  1277  			// Message from an error.
  1278  			fmt.Println(err.Error())
  1279  		}
  1280  		return
  1281  	}
  1282  
  1283  	fmt.Println(result)
  1284  }
  1285  
  1286  // To view a list of asynchronous invocation configurations
  1287  //
  1288  // The following example returns a list of asynchronous invocation configurations for
  1289  // a function named my-function.
  1290  func ExampleLambda_ListFunctionEventInvokeConfigs_shared00() {
  1291  	svc := lambda.New(session.New())
  1292  	input := &lambda.ListFunctionEventInvokeConfigsInput{
  1293  		FunctionName: aws.String("my-function"),
  1294  	}
  1295  
  1296  	result, err := svc.ListFunctionEventInvokeConfigs(input)
  1297  	if err != nil {
  1298  		if aerr, ok := err.(awserr.Error); ok {
  1299  			switch aerr.Code() {
  1300  			case lambda.ErrCodeInvalidParameterValueException:
  1301  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1302  			case lambda.ErrCodeResourceNotFoundException:
  1303  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1304  			case lambda.ErrCodeTooManyRequestsException:
  1305  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1306  			case lambda.ErrCodeServiceException:
  1307  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1308  			default:
  1309  				fmt.Println(aerr.Error())
  1310  			}
  1311  		} else {
  1312  			// Print the error, cast err to awserr.Error to get the Code and
  1313  			// Message from an error.
  1314  			fmt.Println(err.Error())
  1315  		}
  1316  		return
  1317  	}
  1318  
  1319  	fmt.Println(result)
  1320  }
  1321  
  1322  // To get a list of Lambda functions
  1323  //
  1324  // This operation returns a list of Lambda functions.
  1325  func ExampleLambda_ListFunctions_shared00() {
  1326  	svc := lambda.New(session.New())
  1327  	input := &lambda.ListFunctionsInput{}
  1328  
  1329  	result, err := svc.ListFunctions(input)
  1330  	if err != nil {
  1331  		if aerr, ok := err.(awserr.Error); ok {
  1332  			switch aerr.Code() {
  1333  			case lambda.ErrCodeServiceException:
  1334  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1335  			case lambda.ErrCodeTooManyRequestsException:
  1336  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1337  			case lambda.ErrCodeInvalidParameterValueException:
  1338  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1339  			default:
  1340  				fmt.Println(aerr.Error())
  1341  			}
  1342  		} else {
  1343  			// Print the error, cast err to awserr.Error to get the Code and
  1344  			// Message from an error.
  1345  			fmt.Println(err.Error())
  1346  		}
  1347  		return
  1348  	}
  1349  
  1350  	fmt.Println(result)
  1351  }
  1352  
  1353  // To list versions of a layer
  1354  //
  1355  // The following example displays information about the versions for the layer named
  1356  // blank-java-lib
  1357  func ExampleLambda_ListLayerVersions_shared00() {
  1358  	svc := lambda.New(session.New())
  1359  	input := &lambda.ListLayerVersionsInput{
  1360  		LayerName: aws.String("blank-java-lib"),
  1361  	}
  1362  
  1363  	result, err := svc.ListLayerVersions(input)
  1364  	if err != nil {
  1365  		if aerr, ok := err.(awserr.Error); ok {
  1366  			switch aerr.Code() {
  1367  			case lambda.ErrCodeServiceException:
  1368  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1369  			case lambda.ErrCodeInvalidParameterValueException:
  1370  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1371  			case lambda.ErrCodeResourceNotFoundException:
  1372  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1373  			case lambda.ErrCodeTooManyRequestsException:
  1374  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1375  			default:
  1376  				fmt.Println(aerr.Error())
  1377  			}
  1378  		} else {
  1379  			// Print the error, cast err to awserr.Error to get the Code and
  1380  			// Message from an error.
  1381  			fmt.Println(err.Error())
  1382  		}
  1383  		return
  1384  	}
  1385  
  1386  	fmt.Println(result)
  1387  }
  1388  
  1389  // To list the layers that are compatible with your function's runtime
  1390  //
  1391  // The following example returns information about layers that are compatible with the
  1392  // Python 3.7 runtime.
  1393  func ExampleLambda_ListLayers_shared00() {
  1394  	svc := lambda.New(session.New())
  1395  	input := &lambda.ListLayersInput{
  1396  		CompatibleRuntime: aws.String("python3.7"),
  1397  	}
  1398  
  1399  	result, err := svc.ListLayers(input)
  1400  	if err != nil {
  1401  		if aerr, ok := err.(awserr.Error); ok {
  1402  			switch aerr.Code() {
  1403  			case lambda.ErrCodeServiceException:
  1404  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1405  			case lambda.ErrCodeInvalidParameterValueException:
  1406  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1407  			case lambda.ErrCodeTooManyRequestsException:
  1408  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1409  			default:
  1410  				fmt.Println(aerr.Error())
  1411  			}
  1412  		} else {
  1413  			// Print the error, cast err to awserr.Error to get the Code and
  1414  			// Message from an error.
  1415  			fmt.Println(err.Error())
  1416  		}
  1417  		return
  1418  	}
  1419  
  1420  	fmt.Println(result)
  1421  }
  1422  
  1423  // To get a list of provisioned concurrency configurations
  1424  //
  1425  // The following example returns a list of provisioned concurrency configurations for
  1426  // a function named my-function.
  1427  func ExampleLambda_ListProvisionedConcurrencyConfigs_shared00() {
  1428  	svc := lambda.New(session.New())
  1429  	input := &lambda.ListProvisionedConcurrencyConfigsInput{
  1430  		FunctionName: aws.String("my-function"),
  1431  	}
  1432  
  1433  	result, err := svc.ListProvisionedConcurrencyConfigs(input)
  1434  	if err != nil {
  1435  		if aerr, ok := err.(awserr.Error); ok {
  1436  			switch aerr.Code() {
  1437  			case lambda.ErrCodeInvalidParameterValueException:
  1438  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1439  			case lambda.ErrCodeResourceNotFoundException:
  1440  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1441  			case lambda.ErrCodeTooManyRequestsException:
  1442  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1443  			case lambda.ErrCodeServiceException:
  1444  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1445  			default:
  1446  				fmt.Println(aerr.Error())
  1447  			}
  1448  		} else {
  1449  			// Print the error, cast err to awserr.Error to get the Code and
  1450  			// Message from an error.
  1451  			fmt.Println(err.Error())
  1452  		}
  1453  		return
  1454  	}
  1455  
  1456  	fmt.Println(result)
  1457  }
  1458  
  1459  // To retrieve the list of tags for a Lambda function
  1460  //
  1461  // The following example displays the tags attached to the my-function Lambda function.
  1462  func ExampleLambda_ListTags_shared00() {
  1463  	svc := lambda.New(session.New())
  1464  	input := &lambda.ListTagsInput{
  1465  		Resource: aws.String("arn:aws:lambda:us-west-2:123456789012:function:my-function"),
  1466  	}
  1467  
  1468  	result, err := svc.ListTags(input)
  1469  	if err != nil {
  1470  		if aerr, ok := err.(awserr.Error); ok {
  1471  			switch aerr.Code() {
  1472  			case lambda.ErrCodeServiceException:
  1473  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1474  			case lambda.ErrCodeResourceNotFoundException:
  1475  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1476  			case lambda.ErrCodeInvalidParameterValueException:
  1477  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1478  			case lambda.ErrCodeTooManyRequestsException:
  1479  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1480  			default:
  1481  				fmt.Println(aerr.Error())
  1482  			}
  1483  		} else {
  1484  			// Print the error, cast err to awserr.Error to get the Code and
  1485  			// Message from an error.
  1486  			fmt.Println(err.Error())
  1487  		}
  1488  		return
  1489  	}
  1490  
  1491  	fmt.Println(result)
  1492  }
  1493  
  1494  // To list versions of a function
  1495  //
  1496  // The following example returns a list of versions of a function named my-function
  1497  func ExampleLambda_ListVersionsByFunction_shared00() {
  1498  	svc := lambda.New(session.New())
  1499  	input := &lambda.ListVersionsByFunctionInput{
  1500  		FunctionName: aws.String("my-function"),
  1501  	}
  1502  
  1503  	result, err := svc.ListVersionsByFunction(input)
  1504  	if err != nil {
  1505  		if aerr, ok := err.(awserr.Error); ok {
  1506  			switch aerr.Code() {
  1507  			case lambda.ErrCodeServiceException:
  1508  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1509  			case lambda.ErrCodeResourceNotFoundException:
  1510  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1511  			case lambda.ErrCodeInvalidParameterValueException:
  1512  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1513  			case lambda.ErrCodeTooManyRequestsException:
  1514  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1515  			default:
  1516  				fmt.Println(aerr.Error())
  1517  			}
  1518  		} else {
  1519  			// Print the error, cast err to awserr.Error to get the Code and
  1520  			// Message from an error.
  1521  			fmt.Println(err.Error())
  1522  		}
  1523  		return
  1524  	}
  1525  
  1526  	fmt.Println(result)
  1527  }
  1528  
  1529  // To create a Lambda layer version
  1530  //
  1531  // The following example creates a new Python library layer version. The command retrieves
  1532  // the layer content a file named layer.zip in the specified S3 bucket.
  1533  func ExampleLambda_PublishLayerVersion_shared00() {
  1534  	svc := lambda.New(session.New())
  1535  	input := &lambda.PublishLayerVersionInput{
  1536  		CompatibleRuntimes: []*string{
  1537  			aws.String("python3.6"),
  1538  			aws.String("python3.7"),
  1539  		},
  1540  		Content: &lambda.LayerVersionContentInput{
  1541  			S3Bucket: aws.String("lambda-layers-us-west-2-123456789012"),
  1542  			S3Key:    aws.String("layer.zip"),
  1543  		},
  1544  		Description: aws.String("My Python layer"),
  1545  		LayerName:   aws.String("my-layer"),
  1546  		LicenseInfo: aws.String("MIT"),
  1547  	}
  1548  
  1549  	result, err := svc.PublishLayerVersion(input)
  1550  	if err != nil {
  1551  		if aerr, ok := err.(awserr.Error); ok {
  1552  			switch aerr.Code() {
  1553  			case lambda.ErrCodeServiceException:
  1554  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1555  			case lambda.ErrCodeResourceNotFoundException:
  1556  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1557  			case lambda.ErrCodeTooManyRequestsException:
  1558  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1559  			case lambda.ErrCodeInvalidParameterValueException:
  1560  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1561  			case lambda.ErrCodeCodeStorageExceededException:
  1562  				fmt.Println(lambda.ErrCodeCodeStorageExceededException, aerr.Error())
  1563  			default:
  1564  				fmt.Println(aerr.Error())
  1565  			}
  1566  		} else {
  1567  			// Print the error, cast err to awserr.Error to get the Code and
  1568  			// Message from an error.
  1569  			fmt.Println(err.Error())
  1570  		}
  1571  		return
  1572  	}
  1573  
  1574  	fmt.Println(result)
  1575  }
  1576  
  1577  // To publish a version of a Lambda function
  1578  //
  1579  // This operation publishes a version of a Lambda function
  1580  func ExampleLambda_PublishVersion_shared00() {
  1581  	svc := lambda.New(session.New())
  1582  	input := &lambda.PublishVersionInput{
  1583  		CodeSha256:   aws.String(""),
  1584  		Description:  aws.String(""),
  1585  		FunctionName: aws.String("myFunction"),
  1586  	}
  1587  
  1588  	result, err := svc.PublishVersion(input)
  1589  	if err != nil {
  1590  		if aerr, ok := err.(awserr.Error); ok {
  1591  			switch aerr.Code() {
  1592  			case lambda.ErrCodeServiceException:
  1593  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1594  			case lambda.ErrCodeResourceNotFoundException:
  1595  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1596  			case lambda.ErrCodeInvalidParameterValueException:
  1597  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1598  			case lambda.ErrCodeTooManyRequestsException:
  1599  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1600  			case lambda.ErrCodeCodeStorageExceededException:
  1601  				fmt.Println(lambda.ErrCodeCodeStorageExceededException, aerr.Error())
  1602  			case lambda.ErrCodePreconditionFailedException:
  1603  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
  1604  			case lambda.ErrCodeResourceConflictException:
  1605  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  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 configure a reserved concurrency limit for a function
  1621  //
  1622  // The following example configures 100 reserved concurrent executions for the my-function
  1623  // function.
  1624  func ExampleLambda_PutFunctionConcurrency_shared00() {
  1625  	svc := lambda.New(session.New())
  1626  	input := &lambda.PutFunctionConcurrencyInput{
  1627  		FunctionName:                 aws.String("my-function"),
  1628  		ReservedConcurrentExecutions: aws.Int64(100),
  1629  	}
  1630  
  1631  	result, err := svc.PutFunctionConcurrency(input)
  1632  	if err != nil {
  1633  		if aerr, ok := err.(awserr.Error); ok {
  1634  			switch aerr.Code() {
  1635  			case lambda.ErrCodeServiceException:
  1636  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1637  			case lambda.ErrCodeInvalidParameterValueException:
  1638  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1639  			case lambda.ErrCodeResourceNotFoundException:
  1640  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1641  			case lambda.ErrCodeTooManyRequestsException:
  1642  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1643  			case lambda.ErrCodeResourceConflictException:
  1644  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1645  			default:
  1646  				fmt.Println(aerr.Error())
  1647  			}
  1648  		} else {
  1649  			// Print the error, cast err to awserr.Error to get the Code and
  1650  			// Message from an error.
  1651  			fmt.Println(err.Error())
  1652  		}
  1653  		return
  1654  	}
  1655  
  1656  	fmt.Println(result)
  1657  }
  1658  
  1659  // To configure error handling for asynchronous invocation
  1660  //
  1661  // The following example sets a maximum event age of one hour and disables retries for
  1662  // the specified function.
  1663  func ExampleLambda_PutFunctionEventInvokeConfig_shared00() {
  1664  	svc := lambda.New(session.New())
  1665  	input := &lambda.PutFunctionEventInvokeConfigInput{
  1666  		FunctionName:             aws.String("my-function"),
  1667  		MaximumEventAgeInSeconds: aws.Int64(3600),
  1668  		MaximumRetryAttempts:     aws.Int64(0),
  1669  	}
  1670  
  1671  	result, err := svc.PutFunctionEventInvokeConfig(input)
  1672  	if err != nil {
  1673  		if aerr, ok := err.(awserr.Error); ok {
  1674  			switch aerr.Code() {
  1675  			case lambda.ErrCodeServiceException:
  1676  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1677  			case lambda.ErrCodeResourceNotFoundException:
  1678  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1679  			case lambda.ErrCodeInvalidParameterValueException:
  1680  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1681  			case lambda.ErrCodeTooManyRequestsException:
  1682  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1683  			default:
  1684  				fmt.Println(aerr.Error())
  1685  			}
  1686  		} else {
  1687  			// Print the error, cast err to awserr.Error to get the Code and
  1688  			// Message from an error.
  1689  			fmt.Println(err.Error())
  1690  		}
  1691  		return
  1692  	}
  1693  
  1694  	fmt.Println(result)
  1695  }
  1696  
  1697  // To allocate provisioned concurrency
  1698  //
  1699  // The following example allocates 100 provisioned concurrency for the BLUE alias of
  1700  // the specified function.
  1701  func ExampleLambda_PutProvisionedConcurrencyConfig_shared00() {
  1702  	svc := lambda.New(session.New())
  1703  	input := &lambda.PutProvisionedConcurrencyConfigInput{
  1704  		FunctionName:                    aws.String("my-function"),
  1705  		ProvisionedConcurrentExecutions: aws.Int64(100),
  1706  		Qualifier:                       aws.String("BLUE"),
  1707  	}
  1708  
  1709  	result, err := svc.PutProvisionedConcurrencyConfig(input)
  1710  	if err != nil {
  1711  		if aerr, ok := err.(awserr.Error); ok {
  1712  			switch aerr.Code() {
  1713  			case lambda.ErrCodeInvalidParameterValueException:
  1714  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1715  			case lambda.ErrCodeResourceNotFoundException:
  1716  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1717  			case lambda.ErrCodeResourceConflictException:
  1718  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1719  			case lambda.ErrCodeTooManyRequestsException:
  1720  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1721  			case lambda.ErrCodeServiceException:
  1722  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1723  			default:
  1724  				fmt.Println(aerr.Error())
  1725  			}
  1726  		} else {
  1727  			// Print the error, cast err to awserr.Error to get the Code and
  1728  			// Message from an error.
  1729  			fmt.Println(err.Error())
  1730  		}
  1731  		return
  1732  	}
  1733  
  1734  	fmt.Println(result)
  1735  }
  1736  
  1737  // To delete layer-version permissions
  1738  //
  1739  // The following example deletes permission for an account to configure a layer version.
  1740  func ExampleLambda_RemoveLayerVersionPermission_shared00() {
  1741  	svc := lambda.New(session.New())
  1742  	input := &lambda.RemoveLayerVersionPermissionInput{
  1743  		LayerName:     aws.String("my-layer"),
  1744  		StatementId:   aws.String("xaccount"),
  1745  		VersionNumber: aws.Int64(1),
  1746  	}
  1747  
  1748  	result, err := svc.RemoveLayerVersionPermission(input)
  1749  	if err != nil {
  1750  		if aerr, ok := err.(awserr.Error); ok {
  1751  			switch aerr.Code() {
  1752  			case lambda.ErrCodeServiceException:
  1753  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1754  			case lambda.ErrCodeResourceNotFoundException:
  1755  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1756  			case lambda.ErrCodeInvalidParameterValueException:
  1757  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1758  			case lambda.ErrCodeTooManyRequestsException:
  1759  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1760  			case lambda.ErrCodePreconditionFailedException:
  1761  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
  1762  			default:
  1763  				fmt.Println(aerr.Error())
  1764  			}
  1765  		} else {
  1766  			// Print the error, cast err to awserr.Error to get the Code and
  1767  			// Message from an error.
  1768  			fmt.Println(err.Error())
  1769  		}
  1770  		return
  1771  	}
  1772  
  1773  	fmt.Println(result)
  1774  }
  1775  
  1776  // To remove a Lambda function's permissions
  1777  //
  1778  // The following example removes a permissions statement named xaccount from the PROD
  1779  // alias of a function named my-function.
  1780  func ExampleLambda_RemovePermission_shared00() {
  1781  	svc := lambda.New(session.New())
  1782  	input := &lambda.RemovePermissionInput{
  1783  		FunctionName: aws.String("my-function"),
  1784  		Qualifier:    aws.String("PROD"),
  1785  		StatementId:  aws.String("xaccount"),
  1786  	}
  1787  
  1788  	result, err := svc.RemovePermission(input)
  1789  	if err != nil {
  1790  		if aerr, ok := err.(awserr.Error); ok {
  1791  			switch aerr.Code() {
  1792  			case lambda.ErrCodeServiceException:
  1793  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1794  			case lambda.ErrCodeResourceNotFoundException:
  1795  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1796  			case lambda.ErrCodeInvalidParameterValueException:
  1797  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1798  			case lambda.ErrCodeTooManyRequestsException:
  1799  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1800  			case lambda.ErrCodePreconditionFailedException:
  1801  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
  1802  			default:
  1803  				fmt.Println(aerr.Error())
  1804  			}
  1805  		} else {
  1806  			// Print the error, cast err to awserr.Error to get the Code and
  1807  			// Message from an error.
  1808  			fmt.Println(err.Error())
  1809  		}
  1810  		return
  1811  	}
  1812  
  1813  	fmt.Println(result)
  1814  }
  1815  
  1816  // To add tags to an existing Lambda function
  1817  //
  1818  // The following example adds a tag with the key name DEPARTMENT and a value of 'Department
  1819  // A' to the specified Lambda function.
  1820  func ExampleLambda_TagResource_shared00() {
  1821  	svc := lambda.New(session.New())
  1822  	input := &lambda.TagResourceInput{
  1823  		Resource: aws.String("arn:aws:lambda:us-west-2:123456789012:function:my-function"),
  1824  		Tags: map[string]*string{
  1825  			"DEPARTMENT": aws.String("Department A"),
  1826  		},
  1827  	}
  1828  
  1829  	result, err := svc.TagResource(input)
  1830  	if err != nil {
  1831  		if aerr, ok := err.(awserr.Error); ok {
  1832  			switch aerr.Code() {
  1833  			case lambda.ErrCodeServiceException:
  1834  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1835  			case lambda.ErrCodeResourceNotFoundException:
  1836  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1837  			case lambda.ErrCodeInvalidParameterValueException:
  1838  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1839  			case lambda.ErrCodeTooManyRequestsException:
  1840  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1841  			case lambda.ErrCodeResourceConflictException:
  1842  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1843  			default:
  1844  				fmt.Println(aerr.Error())
  1845  			}
  1846  		} else {
  1847  			// Print the error, cast err to awserr.Error to get the Code and
  1848  			// Message from an error.
  1849  			fmt.Println(err.Error())
  1850  		}
  1851  		return
  1852  	}
  1853  
  1854  	fmt.Println(result)
  1855  }
  1856  
  1857  // To remove tags from an existing Lambda function
  1858  //
  1859  // The following example removes the tag with the key name DEPARTMENT tag from the my-function
  1860  // Lambda function.
  1861  func ExampleLambda_UntagResource_shared00() {
  1862  	svc := lambda.New(session.New())
  1863  	input := &lambda.UntagResourceInput{
  1864  		Resource: aws.String("arn:aws:lambda:us-west-2:123456789012:function:my-function"),
  1865  		TagKeys: []*string{
  1866  			aws.String("DEPARTMENT"),
  1867  		},
  1868  	}
  1869  
  1870  	result, err := svc.UntagResource(input)
  1871  	if err != nil {
  1872  		if aerr, ok := err.(awserr.Error); ok {
  1873  			switch aerr.Code() {
  1874  			case lambda.ErrCodeServiceException:
  1875  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1876  			case lambda.ErrCodeResourceNotFoundException:
  1877  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1878  			case lambda.ErrCodeInvalidParameterValueException:
  1879  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1880  			case lambda.ErrCodeTooManyRequestsException:
  1881  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1882  			case lambda.ErrCodeResourceConflictException:
  1883  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1884  			default:
  1885  				fmt.Println(aerr.Error())
  1886  			}
  1887  		} else {
  1888  			// Print the error, cast err to awserr.Error to get the Code and
  1889  			// Message from an error.
  1890  			fmt.Println(err.Error())
  1891  		}
  1892  		return
  1893  	}
  1894  
  1895  	fmt.Println(result)
  1896  }
  1897  
  1898  // To update a function alias
  1899  //
  1900  // The following example updates the alias named BLUE to send 30% of traffic to version
  1901  // 2 and 70% to version 1.
  1902  func ExampleLambda_UpdateAlias_shared00() {
  1903  	svc := lambda.New(session.New())
  1904  	input := &lambda.UpdateAliasInput{
  1905  		FunctionName:    aws.String("my-function"),
  1906  		FunctionVersion: aws.String("2"),
  1907  		Name:            aws.String("BLUE"),
  1908  		RoutingConfig: &lambda.AliasRoutingConfiguration{
  1909  			AdditionalVersionWeights: map[string]*float64{
  1910  				"1": aws.Float64(0.700000),
  1911  			},
  1912  		},
  1913  	}
  1914  
  1915  	result, err := svc.UpdateAlias(input)
  1916  	if err != nil {
  1917  		if aerr, ok := err.(awserr.Error); ok {
  1918  			switch aerr.Code() {
  1919  			case lambda.ErrCodeServiceException:
  1920  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1921  			case lambda.ErrCodeResourceNotFoundException:
  1922  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1923  			case lambda.ErrCodeInvalidParameterValueException:
  1924  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1925  			case lambda.ErrCodeTooManyRequestsException:
  1926  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1927  			case lambda.ErrCodePreconditionFailedException:
  1928  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
  1929  			case lambda.ErrCodeResourceConflictException:
  1930  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1931  			default:
  1932  				fmt.Println(aerr.Error())
  1933  			}
  1934  		} else {
  1935  			// Print the error, cast err to awserr.Error to get the Code and
  1936  			// Message from an error.
  1937  			fmt.Println(err.Error())
  1938  		}
  1939  		return
  1940  	}
  1941  
  1942  	fmt.Println(result)
  1943  }
  1944  
  1945  // To update a Lambda function event source mapping
  1946  //
  1947  // This operation updates a Lambda function event source mapping
  1948  func ExampleLambda_UpdateEventSourceMapping_shared00() {
  1949  	svc := lambda.New(session.New())
  1950  	input := &lambda.UpdateEventSourceMappingInput{
  1951  		BatchSize:    aws.Int64(123),
  1952  		Enabled:      aws.Bool(true),
  1953  		FunctionName: aws.String("myFunction"),
  1954  		UUID:         aws.String("1234xCy789012"),
  1955  	}
  1956  
  1957  	result, err := svc.UpdateEventSourceMapping(input)
  1958  	if err != nil {
  1959  		if aerr, ok := err.(awserr.Error); ok {
  1960  			switch aerr.Code() {
  1961  			case lambda.ErrCodeServiceException:
  1962  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  1963  			case lambda.ErrCodeResourceNotFoundException:
  1964  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  1965  			case lambda.ErrCodeInvalidParameterValueException:
  1966  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  1967  			case lambda.ErrCodeTooManyRequestsException:
  1968  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  1969  			case lambda.ErrCodeResourceConflictException:
  1970  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  1971  			case lambda.ErrCodeResourceInUseException:
  1972  				fmt.Println(lambda.ErrCodeResourceInUseException, aerr.Error())
  1973  			default:
  1974  				fmt.Println(aerr.Error())
  1975  			}
  1976  		} else {
  1977  			// Print the error, cast err to awserr.Error to get the Code and
  1978  			// Message from an error.
  1979  			fmt.Println(err.Error())
  1980  		}
  1981  		return
  1982  	}
  1983  
  1984  	fmt.Println(result)
  1985  }
  1986  
  1987  // To update a Lambda function's code
  1988  //
  1989  // The following example replaces the code of the unpublished ($LATEST) version of a
  1990  // function named my-function with the contents of the specified zip file in Amazon
  1991  // S3.
  1992  func ExampleLambda_UpdateFunctionCode_shared00() {
  1993  	svc := lambda.New(session.New())
  1994  	input := &lambda.UpdateFunctionCodeInput{
  1995  		FunctionName: aws.String("my-function"),
  1996  		S3Bucket:     aws.String("my-bucket-1xpuxmplzrlbh"),
  1997  		S3Key:        aws.String("function.zip"),
  1998  	}
  1999  
  2000  	result, err := svc.UpdateFunctionCode(input)
  2001  	if err != nil {
  2002  		if aerr, ok := err.(awserr.Error); ok {
  2003  			switch aerr.Code() {
  2004  			case lambda.ErrCodeServiceException:
  2005  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  2006  			case lambda.ErrCodeResourceNotFoundException:
  2007  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  2008  			case lambda.ErrCodeInvalidParameterValueException:
  2009  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  2010  			case lambda.ErrCodeTooManyRequestsException:
  2011  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  2012  			case lambda.ErrCodeCodeStorageExceededException:
  2013  				fmt.Println(lambda.ErrCodeCodeStorageExceededException, aerr.Error())
  2014  			case lambda.ErrCodePreconditionFailedException:
  2015  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
  2016  			case lambda.ErrCodeResourceConflictException:
  2017  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  2018  			case lambda.ErrCodeCodeVerificationFailedException:
  2019  				fmt.Println(lambda.ErrCodeCodeVerificationFailedException, aerr.Error())
  2020  			case lambda.ErrCodeInvalidCodeSignatureException:
  2021  				fmt.Println(lambda.ErrCodeInvalidCodeSignatureException, aerr.Error())
  2022  			case lambda.ErrCodeCodeSigningConfigNotFoundException:
  2023  				fmt.Println(lambda.ErrCodeCodeSigningConfigNotFoundException, aerr.Error())
  2024  			default:
  2025  				fmt.Println(aerr.Error())
  2026  			}
  2027  		} else {
  2028  			// Print the error, cast err to awserr.Error to get the Code and
  2029  			// Message from an error.
  2030  			fmt.Println(err.Error())
  2031  		}
  2032  		return
  2033  	}
  2034  
  2035  	fmt.Println(result)
  2036  }
  2037  
  2038  // To update a Lambda function's configuration
  2039  //
  2040  // The following example modifies the memory size to be 256 MB for the unpublished ($LATEST)
  2041  // version of a function named my-function.
  2042  func ExampleLambda_UpdateFunctionConfiguration_shared00() {
  2043  	svc := lambda.New(session.New())
  2044  	input := &lambda.UpdateFunctionConfigurationInput{
  2045  		FunctionName: aws.String("my-function"),
  2046  		MemorySize:   aws.Int64(256),
  2047  	}
  2048  
  2049  	result, err := svc.UpdateFunctionConfiguration(input)
  2050  	if err != nil {
  2051  		if aerr, ok := err.(awserr.Error); ok {
  2052  			switch aerr.Code() {
  2053  			case lambda.ErrCodeServiceException:
  2054  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  2055  			case lambda.ErrCodeResourceNotFoundException:
  2056  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  2057  			case lambda.ErrCodeInvalidParameterValueException:
  2058  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  2059  			case lambda.ErrCodeTooManyRequestsException:
  2060  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  2061  			case lambda.ErrCodeResourceConflictException:
  2062  				fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
  2063  			case lambda.ErrCodePreconditionFailedException:
  2064  				fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
  2065  			case lambda.ErrCodeCodeVerificationFailedException:
  2066  				fmt.Println(lambda.ErrCodeCodeVerificationFailedException, aerr.Error())
  2067  			case lambda.ErrCodeInvalidCodeSignatureException:
  2068  				fmt.Println(lambda.ErrCodeInvalidCodeSignatureException, aerr.Error())
  2069  			case lambda.ErrCodeCodeSigningConfigNotFoundException:
  2070  				fmt.Println(lambda.ErrCodeCodeSigningConfigNotFoundException, aerr.Error())
  2071  			default:
  2072  				fmt.Println(aerr.Error())
  2073  			}
  2074  		} else {
  2075  			// Print the error, cast err to awserr.Error to get the Code and
  2076  			// Message from an error.
  2077  			fmt.Println(err.Error())
  2078  		}
  2079  		return
  2080  	}
  2081  
  2082  	fmt.Println(result)
  2083  }
  2084  
  2085  // To update an asynchronous invocation configuration
  2086  //
  2087  // The following example adds an on-failure destination to the existing asynchronous
  2088  // invocation configuration for a function named my-function.
  2089  func ExampleLambda_UpdateFunctionEventInvokeConfig_shared00() {
  2090  	svc := lambda.New(session.New())
  2091  	input := &lambda.UpdateFunctionEventInvokeConfigInput{
  2092  		DestinationConfig: &lambda.DestinationConfig{
  2093  			OnFailure: &lambda.OnFailure{
  2094  				Destination: aws.String("arn:aws:sqs:us-east-2:123456789012:destination"),
  2095  			},
  2096  		},
  2097  		FunctionName: aws.String("my-function"),
  2098  	}
  2099  
  2100  	result, err := svc.UpdateFunctionEventInvokeConfig(input)
  2101  	if err != nil {
  2102  		if aerr, ok := err.(awserr.Error); ok {
  2103  			switch aerr.Code() {
  2104  			case lambda.ErrCodeServiceException:
  2105  				fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
  2106  			case lambda.ErrCodeResourceNotFoundException:
  2107  				fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
  2108  			case lambda.ErrCodeInvalidParameterValueException:
  2109  				fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
  2110  			case lambda.ErrCodeTooManyRequestsException:
  2111  				fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
  2112  			default:
  2113  				fmt.Println(aerr.Error())
  2114  			}
  2115  		} else {
  2116  			// Print the error, cast err to awserr.Error to get the Code and
  2117  			// Message from an error.
  2118  			fmt.Println(err.Error())
  2119  		}
  2120  		return
  2121  	}
  2122  
  2123  	fmt.Println(result)
  2124  }