本文整理汇总了Golang中github.com/aws/aws-sdk-go/service/lambda.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: addToLambda
func addToLambda(dir string) error {
desc, err := util.ReadTestDescription(dir)
if err != nil {
return err
}
var zipContents []byte
if desc.Runtime == "java8" {
zipContents, err = ioutil.ReadFile(filepath.Join(dir, "test-build.jar"))
if err != nil {
return err
}
} else {
zipContents, err = makeZip(dir)
if err != nil {
return err
}
}
s := session.New(&aws.Config{Region: aws.String("us-east-1"), Credentials: credentials.NewEnvCredentials()})
l := lambda.New(s)
err = createLambdaFunction(l, zipContents, desc.Runtime, lambdaRole, desc.Name, desc.Handler, desc.Timeout)
return err
}
开发者ID:iron-io,项目名称:lambda,代码行数:26,代码来源:main.go
示例2: ExampleLambda_UpdateFunctionCode
func ExampleLambda_UpdateFunctionCode() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.UpdateFunctionCodeInput{
FunctionName: aws.String("FunctionName"), // Required
Publish: aws.Bool(true),
S3Bucket: aws.String("S3Bucket"),
S3Key: aws.String("S3Key"),
S3ObjectVersion: aws.String("S3ObjectVersion"),
ZipFile: []byte("PAYLOAD"),
}
resp, err := svc.UpdateFunctionCode(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:29,代码来源:examples_test.go
示例3: ExampleLambda_InvokeAsync
func ExampleLambda_InvokeAsync() {
svc := lambda.New(nil)
params := &lambda.InvokeAsyncInput{
FunctionName: aws.String("FunctionName"), // Required
InvokeArgs: bytes.NewReader([]byte("PAYLOAD")), // Required
}
resp, err := svc.InvokeAsync(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS Error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
开发者ID:jasonmoo,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go
示例4: InvokeLambda
func (s *Service) InvokeLambda(payload *bridge.Request) (br bridge.Response) {
if s.lamdbaSvc == nil {
// Setup the AWS Creds.
c := aws.NewConfig().WithCredentials(credentials.NewStaticCredentials(s.AWS.AccessKey, s.AWS.SecretKey, "")).WithRegion(s.AWS.Region)
s.lamdbaSvc = lambda.New(session.New(c))
}
params := &lambda.InvokeInput{
FunctionName: aws.String(s.FunctionName),
Payload: payload.JSON(),
}
resp, err := s.lamdbaSvc.Invoke(params)
if err != nil {
return bridge.ErrorResponse(fmt.Sprintf("lambda invoke error %v", err))
}
// Pretty-print the response data.
log.Println("lambda response", string(resp.Payload))
err = json.Unmarshal(resp.Payload, &br)
if err != nil {
log.Println("failed to unmarshal response", err)
return bridge.ErrorResponse("failed to unmarshal response")
}
return
}
开发者ID:acksin,项目名称:bridge,代码行数:28,代码来源:service.go
示例5: ExampleLambda_UpdateAlias
func ExampleLambda_UpdateAlias() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.UpdateAliasInput{
FunctionName: aws.String("FunctionName"), // Required
Name: aws.String("Alias"), // Required
Description: aws.String("Description"),
FunctionVersion: aws.String("Version"),
}
resp, err := svc.UpdateAlias(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:27,代码来源:examples_test.go
示例6: ExampleLambda_ListFunctions
func ExampleLambda_ListFunctions() {
svc := lambda.New(nil)
params := &lambda.ListFunctionsInput{
Marker: aws.String("String"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListFunctions(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
开发者ID:Talos208,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go
示例7: ExampleLambda_AddPermission
func ExampleLambda_AddPermission() {
svc := lambda.New(session.New())
params := &lambda.AddPermissionInput{
Action: aws.String("Action"), // Required
FunctionName: aws.String("FunctionName"), // Required
Principal: aws.String("Principal"), // Required
StatementId: aws.String("StatementId"), // Required
EventSourceToken: aws.String("EventSourceToken"),
Qualifier: aws.String("Qualifier"),
SourceAccount: aws.String("SourceOwner"),
SourceArn: aws.String("Arn"),
}
resp, err := svc.AddPermission(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:ColourboxDevelopment,项目名称:aws-sdk-go,代码行数:25,代码来源:examples_test.go
示例8: CreateLambda
func (b *Build) CreateLambda() error {
zipBytes, err := ioutil.ReadFile(b.Directory + ".zip")
if err != nil {
return err
}
svc := lambda.New(&aws.Config{Region: aws.String("us-east-1")})
params := &lambda.CreateFunctionInput{
Code: &lambda.FunctionCode{
ZipFile: zipBytes,
},
FunctionName: aws.String(b.Directory), // Required
Handler: aws.String("handler_example.handler"), // Required
Role: aws.String("arn:aws:iam::651778473396:role/lambda_basic_execution"), // Required
Runtime: aws.String("nodejs"), // Required
// Description: aws.String("nodejs"),
MemorySize: aws.Int64(150),
Timeout: aws.Int64(3),
}
resp, err := svc.CreateFunction(params)
_ = resp
if err != nil {
return err
}
return nil
}
开发者ID:maxmcd,项目名称:gitbao,代码行数:28,代码来源:builder.go
示例9: ExampleLambda_UpdateFunctionConfiguration
func ExampleLambda_UpdateFunctionConfiguration() {
svc := lambda.New(nil)
params := &lambda.UpdateFunctionConfigurationInput{
FunctionName: aws.String("FunctionName"), // Required
Description: aws.String("Description"),
Handler: aws.String("Handler"),
MemorySize: aws.Int64(1),
Role: aws.String("RoleArn"),
Timeout: aws.Int64(1),
}
resp, err := svc.UpdateFunctionConfiguration(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
开发者ID:Talos208,项目名称:aws-sdk-go,代码行数:31,代码来源:examples_test.go
示例10: ExampleLambda_RemovePermission
func ExampleLambda_RemovePermission() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.RemovePermissionInput{
FunctionName: aws.String("FunctionName"), // Required
StatementId: aws.String("StatementId"), // Required
Qualifier: aws.String("Qualifier"),
}
resp, err := svc.RemovePermission(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:examples_test.go
示例11: ExampleLambda_RemovePermission
func ExampleLambda_RemovePermission() {
svc := lambda.New(nil)
params := &lambda.RemovePermissionInput{
FunctionName: aws.String("FunctionName"), // Required
StatementID: aws.String("StatementId"), // Required
}
resp, err := svc.RemovePermission(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
开发者ID:Talos208,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go
示例12: ExampleLambda_InvokeAsync
func ExampleLambda_InvokeAsync() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.InvokeAsyncInput{
FunctionName: aws.String("FunctionName"), // Required
InvokeArgs: bytes.NewReader([]byte("PAYLOAD")), // Required
}
resp, err := svc.InvokeAsync(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:25,代码来源:examples_test.go
示例13: ExampleLambda_ListVersionsByFunction
func ExampleLambda_ListVersionsByFunction() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.ListVersionsByFunctionInput{
FunctionName: aws.String("FunctionName"), // Required
Marker: aws.String("String"),
MaxItems: aws.Int64(1),
}
resp, err := svc.ListVersionsByFunction(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:26,代码来源:examples_test.go
示例14: ExampleLambda_Invoke
func ExampleLambda_Invoke() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.InvokeInput{
FunctionName: aws.String("FunctionName"), // Required
ClientContext: aws.String("String"),
InvocationType: aws.String("InvocationType"),
LogType: aws.String("LogType"),
Payload: []byte("PAYLOAD"),
Qualifier: aws.String("Qualifier"),
}
resp, err := svc.Invoke(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:29,代码来源:examples_test.go
示例15: ExampleLambda_CreateEventSourceMapping
func ExampleLambda_CreateEventSourceMapping() {
svc := lambda.New(nil)
params := &lambda.CreateEventSourceMappingInput{
EventSourceARN: aws.String("Arn"), // Required
FunctionName: aws.String("FunctionName"), // Required
StartingPosition: aws.String("EventSourcePosition"), // Required
BatchSize: aws.Int64(1),
Enabled: aws.Bool(true),
}
resp, err := svc.CreateEventSourceMapping(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
开发者ID:Talos208,项目名称:aws-sdk-go,代码行数:30,代码来源:examples_test.go
示例16: preRun
func (pv *PersistentValues) preRun(c *cobra.Command, args []string) {
if l, err := log.ParseLevel(pv.LogLevel); err == nil {
log.SetLevel(l)
}
pv.session = session.New(aws.NewConfig())
pv.project = &project.Project{
Log: log.Log,
Path: ".",
}
if pv.DryRun {
log.SetLevel(log.WarnLevel)
pv.project.Service = dryrun.New(pv.session)
pv.project.Concurrency = 1
} else {
pv.project.Service = lambda.New(pv.session)
}
if pv.Chdir != "" {
if err := os.Chdir(pv.Chdir); err != nil {
log.Fatalf("error: %s", err)
}
}
if err := pv.project.Open(); err != nil {
log.Fatalf("error opening project: %s", err)
}
}
开发者ID:pilwon,项目名称:apex,代码行数:30,代码来源:persistent.go
示例17: ExampleLambda_UpdateFunctionConfiguration
func ExampleLambda_UpdateFunctionConfiguration() {
svc := lambda.New(session.New())
params := &lambda.UpdateFunctionConfigurationInput{
FunctionName: aws.String("FunctionName"), // Required
Description: aws.String("Description"),
Handler: aws.String("Handler"),
MemorySize: aws.Int64(1),
Role: aws.String("RoleArn"),
Runtime: aws.String("Runtime"),
Timeout: aws.Int64(1),
VpcConfig: &lambda.VpcConfig{
SecurityGroupIds: []*string{
aws.String("SecurityGroupId"), // Required
// More values...
},
SubnetIds: []*string{
aws.String("SubnetId"), // Required
// More values...
},
},
}
resp, err := svc.UpdateFunctionConfiguration(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:ColourboxDevelopment,项目名称:aws-sdk-go,代码行数:34,代码来源:examples_test.go
示例18: ExampleLambda_DeleteEventSourceMapping
func ExampleLambda_DeleteEventSourceMapping() {
svc := lambda.New(nil)
params := &lambda.DeleteEventSourceMappingInput{
UUID: aws.String("String"), // Required
}
resp, err := svc.DeleteEventSourceMapping(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.StringValue(resp))
}
开发者ID:reyco,项目名称:aws-sdk-go,代码行数:26,代码来源:examples_test.go
示例19: ExampleLambda_CreateEventSourceMapping
func ExampleLambda_CreateEventSourceMapping() {
sess, err := session.NewSession()
if err != nil {
fmt.Println("failed to create session,", err)
return
}
svc := lambda.New(sess)
params := &lambda.CreateEventSourceMappingInput{
EventSourceArn: aws.String("Arn"), // Required
FunctionName: aws.String("FunctionName"), // Required
StartingPosition: aws.String("EventSourcePosition"), // Required
BatchSize: aws.Int64(1),
Enabled: aws.Bool(true),
}
resp, err := svc.CreateEventSourceMapping(params)
if err != nil {
// Print the error, cast err to awserr.Error to get the Code and
// Message from an error.
fmt.Println(err.Error())
return
}
// Pretty-print the response data.
fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:28,代码来源:examples_test.go
示例20: ExampleLambda_Invoke
func ExampleLambda_Invoke() {
svc := lambda.New(nil)
params := &lambda.InvokeInput{
FunctionName: aws.String("FunctionName"), // Required
ClientContext: aws.String("String"),
InvocationType: aws.String("InvocationType"),
LogType: aws.String("LogType"),
Payload: []byte("PAYLOAD"),
}
resp, err := svc.Invoke(params)
if err != nil {
if awsErr, ok := err.(awserr.Error); ok {
// Generic AWS error with Code, Message, and original error (if any)
fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
if reqErr, ok := err.(awserr.RequestFailure); ok {
// A service error occurred
fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
}
} else {
// This case should never be hit, the SDK should always return an
// error which satisfies the awserr.Error interface.
fmt.Println(err.Error())
}
}
// Pretty-print the response data.
fmt.Println(awsutil.Prettify(resp))
}
开发者ID:Talos208,项目名称:aws-sdk-go,代码行数:30,代码来源:examples_test.go
注:本文中的github.com/aws/aws-sdk-go/service/lambda.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论