lambdabuilders

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 27, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Utilities for building AWS Lambda Functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildGoArgs

type BuildGoArgs struct {
	// Lambda function architecture to build for. Valid values are `"x86_64"` and `"arm64"`. Default is `"x86_64"`.
	Architecture *string `pulumi:"architecture"`
	// The path to the go code to build
	Code *string `pulumi:"code"`
}

type BuildGoOutputArgs

type BuildGoOutputArgs struct {
	// Lambda function architecture to build for. Valid values are `"x86_64"` and `"arm64"`. Default is `"x86_64"`.
	Architecture pulumi.StringPtrInput `pulumi:"architecture"`
	// The path to the go code to build
	Code pulumi.StringPtrInput `pulumi:"code"`
}

func (BuildGoOutputArgs) ElementType

func (BuildGoOutputArgs) ElementType() reflect.Type

type BuildGoResult

type BuildGoResult struct {
	// The archive that contains the golang binary that will be deployed to the Lambda Function.
	Asset pulumi.Archive `pulumi:"asset"`
}

func BuildGo

func BuildGo(ctx *pulumi.Context, args *BuildGoArgs, opts ...pulumi.InvokeOption) (*BuildGoResult, error)

Builds a Golang Lambda Function into a Pulumi Asset that can be deployed.

The below example uses a folder structure like this:

The output of `buildGo` produces an asset that can be passed to the `aws.Lambda` `Code` property.

## Example Usage

Basic usage:

```go package main

import (

"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/iam"
"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/lambda"
lambdabuilders "github.com/pulumi/pulumi-lambda-builders/sdk/go/lambda-builders"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"

)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		builder, err := lambdabuilders.BuildGo(ctx, &lambdabuilders.BuildGoArgs{
			Architecture: pulumi.StringRef("arm64"),
			Code:         pulumi.StringRef("cmd/simple"),
		}, nil)
		if err != nil {
			return err
		}
		lambdaRolePolicy, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
			Statements: []iam.GetPolicyDocumentStatement{
				{
					Actions: []string{
						"sts:AssumeRole",
					},
					Principals: []iam.GetPolicyDocumentStatementPrincipal{
						{
							Type: "Service",
							Identifiers: []string{
								"lambda.amazonaws.com",
							},
						},
					},
				},
			},
		}, nil)
		if err != nil {
			return err
		}
		role, err := iam.NewRole(ctx, "role", &iam.RoleArgs{
			AssumeRolePolicy: pulumi.String(lambdaRolePolicy.Json),
		})
		if err != nil {
			return err
		}
		_, err = lambda.NewFunction(ctx, "function", &lambda.FunctionArgs{
			Code: builder.Asset,
			Architectures: pulumi.StringArray{
		pulumi.String("arm64"),
	},
			Handler: pulumi.String("bootstrap"),
			Role:    role.Arn,
			Runtime: pulumi.String(lambda.RuntimeCustomAL2023),
		})
		if err != nil {
			return err
		}
		return nil
	})
}

```

type BuildGoResultOutput

type BuildGoResultOutput struct{ *pulumi.OutputState }

func (BuildGoResultOutput) Asset

The archive that contains the golang binary that will be deployed to the Lambda Function.

func (BuildGoResultOutput) ElementType

func (BuildGoResultOutput) ElementType() reflect.Type

func (BuildGoResultOutput) ToBuildGoResultOutput

func (o BuildGoResultOutput) ToBuildGoResultOutput() BuildGoResultOutput

func (BuildGoResultOutput) ToBuildGoResultOutputWithContext

func (o BuildGoResultOutput) ToBuildGoResultOutputWithContext(ctx context.Context) BuildGoResultOutput

type Provider

type Provider struct {
	pulumi.ProviderResourceState
}

func NewProvider

func NewProvider(ctx *pulumi.Context,
	name string, args *ProviderArgs, opts ...pulumi.ResourceOption) (*Provider, error)

NewProvider registers a new resource with the given unique name, arguments, and options.

func (*Provider) ElementType

func (*Provider) ElementType() reflect.Type

func (*Provider) ToProviderOutput

func (i *Provider) ToProviderOutput() ProviderOutput

func (*Provider) ToProviderOutputWithContext

func (i *Provider) ToProviderOutputWithContext(ctx context.Context) ProviderOutput

type ProviderArgs

type ProviderArgs struct {
}

The set of arguments for constructing a Provider resource.

func (ProviderArgs) ElementType

func (ProviderArgs) ElementType() reflect.Type

type ProviderInput

type ProviderInput interface {
	pulumi.Input

	ToProviderOutput() ProviderOutput
	ToProviderOutputWithContext(ctx context.Context) ProviderOutput
}

type ProviderOutput

type ProviderOutput struct{ *pulumi.OutputState }

func (ProviderOutput) ElementType

func (ProviderOutput) ElementType() reflect.Type

func (ProviderOutput) ToProviderOutput

func (o ProviderOutput) ToProviderOutput() ProviderOutput

func (ProviderOutput) ToProviderOutputWithContext

func (o ProviderOutput) ToProviderOutputWithContext(ctx context.Context) ProviderOutput

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL