2017-05-11 16:39:54 +02:00
|
|
|
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
|
|
|
|
|
|
|
|
package lambda_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2017-07-23 09:51:42 +02:00
|
|
|
"strings"
|
2017-05-11 16:39:54 +02:00
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/aws/aws-sdk-go/aws"
|
2017-07-23 09:51:42 +02:00
|
|
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
2017-05-11 16:39:54 +02:00
|
|
|
"github.com/aws/aws-sdk-go/aws/session"
|
|
|
|
"github.com/aws/aws-sdk-go/service/lambda"
|
|
|
|
)
|
|
|
|
|
|
|
|
var _ time.Duration
|
2017-07-23 09:51:42 +02:00
|
|
|
var _ strings.Reader
|
|
|
|
var _ aws.Config
|
2017-05-11 16:39:54 +02:00
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
func parseTime(layout, value string) *time.Time {
|
|
|
|
t, err := time.Parse(layout, value)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
panic(err)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
2017-07-23 09:51:42 +02:00
|
|
|
return &t
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// add-permission
|
|
|
|
//
|
|
|
|
// This example adds a permission for an S3 bucket to invoke a Lambda function.
|
|
|
|
func ExampleLambda_AddPermission_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.AddPermissionInput{
|
|
|
|
Action: aws.String("lambda:InvokeFunction"),
|
|
|
|
FunctionName: aws.String("MyFunction"),
|
|
|
|
Principal: aws.String("s3.amazonaws.com"),
|
|
|
|
SourceAccount: aws.String("123456789012"),
|
|
|
|
SourceArn: aws.String("arn:aws:s3:::examplebucket/*"),
|
|
|
|
StatementId: aws.String("ID-1"),
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := svc.AddPermission(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceConflictException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodePolicyLengthExceededException:
|
|
|
|
fmt.Println(lambda.ErrCodePolicyLengthExceededException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
2018-03-19 16:51:38 +01:00
|
|
|
case lambda.ErrCodePreconditionFailedException:
|
|
|
|
fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
|
2017-07-23 09:51:42 +02:00
|
|
|
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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// create-function
|
|
|
|
//
|
|
|
|
// This example creates a Lambda function.
|
|
|
|
func ExampleLambda_CreateFunction_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.CreateFunctionInput{
|
|
|
|
Code: &lambda.FunctionCode{},
|
|
|
|
Description: aws.String(""),
|
|
|
|
FunctionName: aws.String("MyFunction"),
|
|
|
|
Handler: aws.String("souce_file.handler_name"),
|
|
|
|
MemorySize: aws.Int64(128),
|
|
|
|
Publish: aws.Bool(true),
|
|
|
|
Role: aws.String("arn:aws:iam::123456789012:role/service-role/role-name"),
|
|
|
|
Runtime: aws.String("nodejs4.3"),
|
|
|
|
Timeout: aws.Int64(15),
|
|
|
|
VpcConfig: &lambda.VpcConfig{},
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := svc.CreateFunction(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceConflictException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeCodeStorageExceededException:
|
|
|
|
fmt.Println(lambda.ErrCodeCodeStorageExceededException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To delete a Lambda function alias
|
|
|
|
//
|
|
|
|
// This operation deletes a Lambda function alias
|
|
|
|
func ExampleLambda_DeleteAlias_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.DeleteAliasInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Name: aws.String("alias"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.DeleteAlias(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To delete a Lambda function event source mapping
|
|
|
|
//
|
|
|
|
// This operation deletes a Lambda function event source mapping
|
|
|
|
func ExampleLambda_DeleteEventSourceMapping_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.DeleteEventSourceMappingInput{
|
|
|
|
UUID: aws.String("12345kxodurf3443"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.DeleteEventSourceMapping(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To delete a Lambda function
|
|
|
|
//
|
|
|
|
// This operation deletes a Lambda function
|
|
|
|
func ExampleLambda_DeleteFunction_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.DeleteFunctionInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Qualifier: aws.String("1"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.DeleteFunction(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceConflictException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceConflictException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieves a Lambda customer's account settings
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda customer's account settings
|
|
|
|
func ExampleLambda_GetAccountSettings_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.GetAccountSettingsInput{}
|
2017-05-11 16:39:54 +02:00
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetAccountSettings(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a Lambda function alias
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function alias
|
|
|
|
func ExampleLambda_GetAlias_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.GetAliasInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Name: aws.String("myFunctionAlias"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetAlias(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a Lambda function's event source mapping
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function's event source mapping
|
|
|
|
func ExampleLambda_GetEventSourceMapping_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.GetEventSourceMappingInput{
|
|
|
|
UUID: aws.String("123489-xxxxx-kdla8d89d7"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetEventSourceMapping(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a Lambda function's event source mapping
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function's event source mapping
|
|
|
|
func ExampleLambda_GetFunction_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.GetFunctionInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Qualifier: aws.String("1"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetFunction(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a Lambda function's event source mapping
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function's event source mapping
|
|
|
|
func ExampleLambda_GetFunctionConfiguration_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.GetFunctionConfigurationInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Qualifier: aws.String("1"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetFunctionConfiguration(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a Lambda function policy
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function policy
|
|
|
|
func ExampleLambda_GetPolicy_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.GetPolicyInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Qualifier: aws.String("1"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.GetPolicy(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To invoke a Lambda function
|
|
|
|
//
|
|
|
|
// This operation invokes a Lambda function
|
|
|
|
func ExampleLambda_Invoke_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.InvokeInput{
|
|
|
|
ClientContext: aws.String("MyApp"),
|
|
|
|
FunctionName: aws.String("MyFunction"),
|
|
|
|
InvocationType: aws.String("Event"),
|
|
|
|
LogType: aws.String("Tail"),
|
|
|
|
Payload: []byte("fileb://file-path/input.json"),
|
|
|
|
Qualifier: aws.String("1"),
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := svc.Invoke(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidRequestContentException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidRequestContentException, aerr.Error())
|
|
|
|
case lambda.ErrCodeRequestTooLargeException:
|
|
|
|
fmt.Println(lambda.ErrCodeRequestTooLargeException, aerr.Error())
|
|
|
|
case lambda.ErrCodeUnsupportedMediaTypeException:
|
|
|
|
fmt.Println(lambda.ErrCodeUnsupportedMediaTypeException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeEC2UnexpectedException:
|
|
|
|
fmt.Println(lambda.ErrCodeEC2UnexpectedException, aerr.Error())
|
|
|
|
case lambda.ErrCodeSubnetIPAddressLimitReachedException:
|
|
|
|
fmt.Println(lambda.ErrCodeSubnetIPAddressLimitReachedException, aerr.Error())
|
|
|
|
case lambda.ErrCodeENILimitReachedException:
|
|
|
|
fmt.Println(lambda.ErrCodeENILimitReachedException, aerr.Error())
|
|
|
|
case lambda.ErrCodeEC2ThrottledException:
|
|
|
|
fmt.Println(lambda.ErrCodeEC2ThrottledException, aerr.Error())
|
|
|
|
case lambda.ErrCodeEC2AccessDeniedException:
|
|
|
|
fmt.Println(lambda.ErrCodeEC2AccessDeniedException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidSubnetIDException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidSubnetIDException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidSecurityGroupIDException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidSecurityGroupIDException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidZipFileException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidZipFileException, aerr.Error())
|
|
|
|
case lambda.ErrCodeKMSDisabledException:
|
|
|
|
fmt.Println(lambda.ErrCodeKMSDisabledException, aerr.Error())
|
|
|
|
case lambda.ErrCodeKMSInvalidStateException:
|
|
|
|
fmt.Println(lambda.ErrCodeKMSInvalidStateException, aerr.Error())
|
|
|
|
case lambda.ErrCodeKMSAccessDeniedException:
|
|
|
|
fmt.Println(lambda.ErrCodeKMSAccessDeniedException, aerr.Error())
|
|
|
|
case lambda.ErrCodeKMSNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeKMSNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidRuntimeException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidRuntimeException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To invoke a Lambda function asynchronously
|
|
|
|
//
|
|
|
|
// This operation invokes a Lambda function asynchronously
|
|
|
|
func ExampleLambda_InvokeAsync_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.InvokeAsyncInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
InvokeArgs: aws.ReadSeekCloser(strings.NewReader("fileb://file-path/input.json")),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.InvokeAsync(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidRequestContentException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidRequestContentException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidRuntimeException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidRuntimeException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a Lambda function aliases
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function's aliases
|
|
|
|
func ExampleLambda_ListAliases_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.ListAliasesInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
FunctionVersion: aws.String("1"),
|
|
|
|
Marker: aws.String(""),
|
|
|
|
MaxItems: aws.Int64(123),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.ListAliases(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a list of Lambda functions
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda functions
|
|
|
|
func ExampleLambda_ListFunctions_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.ListFunctionsInput{
|
|
|
|
Marker: aws.String(""),
|
|
|
|
MaxItems: aws.Int64(123),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.ListFunctions(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To retrieve a list of Lambda function versions
|
|
|
|
//
|
|
|
|
// This operation retrieves a Lambda function versions
|
|
|
|
func ExampleLambda_ListVersionsByFunction_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.ListVersionsByFunctionInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Marker: aws.String(""),
|
|
|
|
MaxItems: aws.Int64(123),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.ListVersionsByFunction(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To publish a version of a Lambda function
|
|
|
|
//
|
|
|
|
// This operation publishes a version of a Lambda function
|
|
|
|
func ExampleLambda_PublishVersion_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.PublishVersionInput{
|
|
|
|
CodeSha256: aws.String(""),
|
|
|
|
Description: aws.String(""),
|
|
|
|
FunctionName: aws.String("myFunction"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.PublishVersion(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeCodeStorageExceededException:
|
|
|
|
fmt.Println(lambda.ErrCodeCodeStorageExceededException, aerr.Error())
|
2018-03-19 16:51:38 +01:00
|
|
|
case lambda.ErrCodePreconditionFailedException:
|
|
|
|
fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
|
2017-07-23 09:51:42 +02:00
|
|
|
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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To remove a Lambda function's permissions
|
|
|
|
//
|
|
|
|
// This operation removes a Lambda function's permissions
|
|
|
|
func ExampleLambda_RemovePermission_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.RemovePermissionInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Qualifier: aws.String("1"),
|
|
|
|
StatementId: aws.String("role-statement-id"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.RemovePermission(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
2018-03-19 16:51:38 +01:00
|
|
|
case lambda.ErrCodePreconditionFailedException:
|
|
|
|
fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
|
2017-07-23 09:51:42 +02:00
|
|
|
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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To update a Lambda function alias
|
|
|
|
//
|
|
|
|
// This operation updates a Lambda function alias
|
|
|
|
func ExampleLambda_UpdateAlias_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.UpdateAliasInput{
|
|
|
|
Description: aws.String(""),
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
FunctionVersion: aws.String("1"),
|
|
|
|
Name: aws.String("functionAlias"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.UpdateAlias(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
2018-03-19 16:51:38 +01:00
|
|
|
case lambda.ErrCodePreconditionFailedException:
|
|
|
|
fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
|
2017-07-23 09:51:42 +02:00
|
|
|
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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To update a Lambda function event source mapping
|
|
|
|
//
|
|
|
|
// This operation updates a Lambda function event source mapping
|
|
|
|
func ExampleLambda_UpdateEventSourceMapping_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.UpdateEventSourceMappingInput{
|
|
|
|
BatchSize: aws.Int64(123),
|
2017-05-11 16:39:54 +02:00
|
|
|
Enabled: aws.Bool(true),
|
2017-07-23 09:51:42 +02:00
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
UUID: aws.String("1234xCy789012"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.UpdateEventSourceMapping(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceConflictException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceConflictException, 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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To update a Lambda function's code
|
|
|
|
//
|
|
|
|
// This operation updates a Lambda function's code
|
|
|
|
func ExampleLambda_UpdateFunctionCode_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.UpdateFunctionCodeInput{
|
|
|
|
FunctionName: aws.String("myFunction"),
|
2017-05-11 16:39:54 +02:00
|
|
|
Publish: aws.Bool(true),
|
2017-07-23 09:51:42 +02:00
|
|
|
S3Bucket: aws.String("myBucket"),
|
|
|
|
S3Key: aws.String("myKey"),
|
|
|
|
S3ObjectVersion: aws.String("1"),
|
|
|
|
ZipFile: []byte("fileb://file-path/file.zip"),
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
result, err := svc.UpdateFunctionCode(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeCodeStorageExceededException:
|
|
|
|
fmt.Println(lambda.ErrCodeCodeStorageExceededException, aerr.Error())
|
2018-03-19 16:51:38 +01:00
|
|
|
case lambda.ErrCodePreconditionFailedException:
|
|
|
|
fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
|
2017-07-23 09:51:42 +02:00
|
|
|
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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
// To update a Lambda function's configuration
|
|
|
|
//
|
|
|
|
// This operation updates a Lambda function's configuration
|
|
|
|
func ExampleLambda_UpdateFunctionConfiguration_shared00() {
|
|
|
|
svc := lambda.New(session.New())
|
|
|
|
input := &lambda.UpdateFunctionConfigurationInput{
|
|
|
|
Description: aws.String(""),
|
|
|
|
FunctionName: aws.String("myFunction"),
|
|
|
|
Handler: aws.String("index.handler"),
|
|
|
|
MemorySize: aws.Int64(128),
|
|
|
|
Role: aws.String("arn:aws:iam::123456789012:role/lambda_basic_execution"),
|
|
|
|
Runtime: aws.String("python2.7"),
|
|
|
|
Timeout: aws.Int64(123),
|
|
|
|
VpcConfig: &lambda.VpcConfig{},
|
|
|
|
}
|
|
|
|
|
|
|
|
result, err := svc.UpdateFunctionConfiguration(input)
|
2017-05-11 16:39:54 +02:00
|
|
|
if err != nil {
|
2017-07-23 09:51:42 +02:00
|
|
|
if aerr, ok := err.(awserr.Error); ok {
|
|
|
|
switch aerr.Code() {
|
|
|
|
case lambda.ErrCodeServiceException:
|
|
|
|
fmt.Println(lambda.ErrCodeServiceException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceNotFoundException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceNotFoundException, aerr.Error())
|
|
|
|
case lambda.ErrCodeInvalidParameterValueException:
|
|
|
|
fmt.Println(lambda.ErrCodeInvalidParameterValueException, aerr.Error())
|
|
|
|
case lambda.ErrCodeTooManyRequestsException:
|
|
|
|
fmt.Println(lambda.ErrCodeTooManyRequestsException, aerr.Error())
|
|
|
|
case lambda.ErrCodeResourceConflictException:
|
|
|
|
fmt.Println(lambda.ErrCodeResourceConflictException, aerr.Error())
|
2018-03-19 16:51:38 +01:00
|
|
|
case lambda.ErrCodePreconditionFailedException:
|
|
|
|
fmt.Println(lambda.ErrCodePreconditionFailedException, aerr.Error())
|
2017-07-23 09:51:42 +02:00
|
|
|
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())
|
|
|
|
}
|
2017-05-11 16:39:54 +02:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-07-23 09:51:42 +02:00
|
|
|
fmt.Println(result)
|
2017-05-11 16:39:54 +02:00
|
|
|
}
|