From c54af8f63f1d373071e11e0d051698cacb9b612a Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Thu, 7 Apr 2022 01:46:36 -0400 Subject: [PATCH 01/18] WIP: lambda releaser w/ function url --- builtin/aws/lambda/lambda.go | 3 +- builtin/aws/lambda/platform.go | 26 +++ builtin/aws/lambda/plugin.pb.go | 211 +++++++++++++++++++- builtin/aws/lambda/plugin.proto | 17 ++ builtin/aws/lambda/release.go | 7 + builtin/aws/lambda/releaser.go | 328 ++++++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 5 +- 8 files changed, 587 insertions(+), 12 deletions(-) create mode 100644 builtin/aws/lambda/release.go create mode 100644 builtin/aws/lambda/releaser.go diff --git a/builtin/aws/lambda/lambda.go b/builtin/aws/lambda/lambda.go index 52eda483e06..ea9b1e67957 100644 --- a/builtin/aws/lambda/lambda.go +++ b/builtin/aws/lambda/lambda.go @@ -5,10 +5,11 @@ import ( sdk "github.com/hashicorp/waypoint-plugin-sdk" ) -//go:generate protoc -I ../../../.. --go_opt=plugins=grpc --go_out=../../../.. waypoint/builtin/aws/lambda/plugin.proto +//go:generate protoc -I ../../../.. -I ../../../thirdparty/proto/opaqueany --go_out=../../../.. waypoint/builtin/aws/lambda/plugin.proto // Options are the SDK options to use for instantiation for // the Google Cloud Run plugin. var Options = []sdk.Option{ sdk.WithComponents(&Platform{}), + sdk.WithComponents(&Releaser{}), } diff --git a/builtin/aws/lambda/platform.go b/builtin/aws/lambda/platform.go index f695e328571..505d8fe9def 100644 --- a/builtin/aws/lambda/platform.go +++ b/builtin/aws/lambda/platform.go @@ -712,6 +712,32 @@ func (p *Platform) Destroy( FunctionName: aws.String(deployment.FuncArn), Qualifier: aws.String(deployment.Version), }) + if err != nil { + // older lambda version fail to delete if they have aliases + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case lambda.ErrCodeResourceConflictException: + log.Warn("error deleting lambda function", "error", aerr.Error()) + st.Step(terminal.StatusWarn, "Error deleting function..."+aerr.Message()) + st.Step(terminal.StatusWarn, "Attempting to delete function alias...") + + _, err = lamSvc.DeleteAlias(&lambda.DeleteAliasInput{ + FunctionName: aws.String(deployment.FuncArn), + Name: aws.String("Alias_" + deployment.Version), + }) + if err != nil { + // todo logs + return err + } + st.Step(terminal.StatusOK, "Deleted alias: "+"Alias_"+deployment.Version) + st.Update("Attempting to delete again...") + _, err = lamSvc.DeleteFunction(&lambda.DeleteFunctionInput{ + FunctionName: aws.String(deployment.FuncArn), + Qualifier: aws.String(deployment.Version), + }) + } + } + } } st.Step(terminal.StatusOK, "Deleted Lambda function version") diff --git a/builtin/aws/lambda/plugin.pb.go b/builtin/aws/lambda/plugin.pb.go index d93856a8589..53a14dd79af 100644 --- a/builtin/aws/lambda/plugin.pb.go +++ b/builtin/aws/lambda/plugin.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-go. DO NOT EDIT. // versions: // protoc-gen-go v1.27.1 -// protoc v3.17.3 +// protoc v3.19.4 // source: waypoint/builtin/aws/lambda/plugin.proto package lambda @@ -113,6 +113,156 @@ func (x *Deployment) GetVersion() string { return "" } +type Release struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The function's public url + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + FuncArn string `protobuf:"bytes,2,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` + VerArn string `protobuf:"bytes,3,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` // opaqueany.Any resource_state = 4; +} + +func (x *Release) Reset() { + *x = Release{} + if protoimpl.UnsafeEnabled { + mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Release) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Release) ProtoMessage() {} + +func (x *Release) ProtoReflect() protoreflect.Message { + mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Release.ProtoReflect.Descriptor instead. +func (*Release) Descriptor() ([]byte, []int) { + return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP(), []int{1} +} + +func (x *Release) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *Release) GetFuncArn() string { + if x != nil { + return x.FuncArn + } + return "" +} + +func (x *Release) GetVerArn() string { + if x != nil { + return x.VerArn + } + return "" +} + +// Resource contains the internal resource states. +type Resource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Resource) Reset() { + *x = Resource{} + if protoimpl.UnsafeEnabled { + mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP(), []int{2} +} + +type Resource_FunctionUrl struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` +} + +func (x *Resource_FunctionUrl) Reset() { + *x = Resource_FunctionUrl{} + if protoimpl.UnsafeEnabled { + mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[3] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource_FunctionUrl) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource_FunctionUrl) ProtoMessage() {} + +func (x *Resource_FunctionUrl) ProtoReflect() protoreflect.Message { + mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[3] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Resource_FunctionUrl.ProtoReflect.Descriptor instead. +func (*Resource_FunctionUrl) Descriptor() ([]byte, []int) { + return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP(), []int{2, 0} +} + +func (x *Resource_FunctionUrl) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + var File_waypoint_builtin_aws_lambda_plugin_proto protoreflect.FileDescriptor var file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc = []byte{ @@ -130,9 +280,17 @@ var file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc = []byte{ 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, - 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, - 0x6d, 0x62, 0x64, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x4f, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, + 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, + 0x72, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, + 0x07, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x76, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x22, 0x2b, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, + 0x63, 0x65, 0x1a, 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, + 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, + 0x75, 0x72, 0x6c, 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, + 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, + 0x64, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -147,9 +305,12 @@ func file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP() []byte { return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescData } -var file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 1) +var file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 4) var file_waypoint_builtin_aws_lambda_plugin_proto_goTypes = []interface{}{ - (*Deployment)(nil), // 0: aws.lambda.Deployment + (*Deployment)(nil), // 0: aws.lambda.Deployment + (*Release)(nil), // 1: aws.lambda.Release + (*Resource)(nil), // 2: aws.lambda.Resource + (*Resource_FunctionUrl)(nil), // 3: aws.lambda.Resource.FunctionUrl } var file_waypoint_builtin_aws_lambda_plugin_proto_depIdxs = []int32{ 0, // [0:0] is the sub-list for method output_type @@ -177,6 +338,42 @@ func file_waypoint_builtin_aws_lambda_plugin_proto_init() { return nil } } + file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Release); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resource); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resource_FunctionUrl); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } } type x struct{} out := protoimpl.TypeBuilder{ @@ -184,7 +381,7 @@ func file_waypoint_builtin_aws_lambda_plugin_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc, NumEnums: 0, - NumMessages: 1, + NumMessages: 4, NumExtensions: 0, NumServices: 0, }, diff --git a/builtin/aws/lambda/plugin.proto b/builtin/aws/lambda/plugin.proto index 8a9374a6443..0c1f0a35538 100644 --- a/builtin/aws/lambda/plugin.proto +++ b/builtin/aws/lambda/plugin.proto @@ -4,6 +4,8 @@ package aws.lambda; option go_package = "waypoint/builtin/aws/lambda"; +// import "opaqueany/any.proto"; + message Deployment { // Identifier for the deployment, required by Waypoint string id = 1; @@ -23,3 +25,18 @@ message Deployment { // The version identifier AWS uses for this version (basically a serial increasing number) string version = 7; } + +message Release { + // The function's public url + string url = 1; + string func_arn = 2; + string ver_arn = 3; + // opaqueany.Any resource_state = 4; +} + +// Resource contains the internal resource states. +message Resource { + message FunctionUrl { + string url = 1; + } +} \ No newline at end of file diff --git a/builtin/aws/lambda/release.go b/builtin/aws/lambda/release.go new file mode 100644 index 00000000000..8d3d3afc2a1 --- /dev/null +++ b/builtin/aws/lambda/release.go @@ -0,0 +1,7 @@ +package lambda + +import "github.com/hashicorp/waypoint-plugin-sdk/component" + +func (r *Release) URL() string { return r.Url } + +var _ component.Release = (*Release)(nil) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go new file mode 100644 index 00000000000..fd656c1f7a2 --- /dev/null +++ b/builtin/aws/lambda/releaser.go @@ -0,0 +1,328 @@ +package lambda + +import ( + "context" + + "github.com/aws/aws-sdk-go/aws" + "github.com/aws/aws-sdk-go/aws/awserr" + "github.com/aws/aws-sdk-go/aws/session" + "github.com/aws/aws-sdk-go/service/lambda" + "github.com/hashicorp/go-hclog" + "github.com/hashicorp/waypoint-plugin-sdk/component" + "github.com/hashicorp/waypoint-plugin-sdk/docs" + "github.com/hashicorp/waypoint-plugin-sdk/framework/resource" + sdk "github.com/hashicorp/waypoint-plugin-sdk/proto/gen" + "github.com/hashicorp/waypoint-plugin-sdk/terminal" + "github.com/hashicorp/waypoint/builtin/aws/utils" + "google.golang.org/grpc/codes" + "google.golang.org/grpc/status" + "google.golang.org/protobuf/types/known/timestamppb" +) + +type Releaser struct { + config ReleaserConfig +} + +// Config implements Configurable +func (r *Releaser) Config() (interface{}, error) { + return &r.config, nil +} + +// ReleaseFunc implements component.ReleaseManager +func (r *Releaser) ReleaseFunc() interface{} { + return r.Release +} + +// StatusFunc implements component.Status +func (r *Releaser) StatusFunc() interface{} { + return r.Status +} + +// DestroyFunc implements component.Destroyer +func (r *Releaser) DestroyFunc() interface{} { + return r.Destroy +} + +func (r *Releaser) resourceManager(log hclog.Logger) *resource.Manager { + return resource.NewManager( + resource.WithLogger(log.Named("resource_manager")), + resource.WithValueProvider(r.getSession), + + resource.WithResource(resource.NewResource( + resource.WithName("function_url"), + // WithState is needed for `rm.Resource("function_url").State()` to succeed + resource.WithState(&Resource_FunctionUrl{}), + resource.WithCreate(r.resourceFunctionUrlCreate), + resource.WithDestroy(r.resourceFunctionUrlDestroy), + )), + ) +} + +func (r *Releaser) getSession( + _ context.Context, + log hclog.Logger, +) (*session.Session, error) { + return utils.GetSession(&utils.SessionConfig{ + Logger: log, + }) +} + +func (r *Releaser) resourceFunctionUrlCreate( + ctx context.Context, + log hclog.Logger, + sess *session.Session, + sg terminal.StepGroup, + ui terminal.UI, + dep *Deployment, +) error { + log.Info("Creating Lambda URL...", "VerArn", dep.VerArn, "FuncArn", dep.FuncArn) + + lambdasrv := lambda.New(sess) + + log.Info("Creating alias...") + log.Info("Version: " + dep.Version) + log.Info("FuncArn: " + dep.FuncArn) + // create a function alias so that we can create a function url + // https://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html + qualifier := "Alias_" + dep.Version + a, err := lambdasrv.CreateAlias(&lambda.CreateAliasInput{ + // Alias name cannot be numeric-only + Name: aws.String(qualifier), + Description: aws.String("Waypoint Lambda Alias"), + FunctionName: aws.String(dep.FuncArn), + FunctionVersion: aws.String(dep.Version), + }) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + log.Error("Error creating alias", "error", aerr.Code(), "message", aerr.Message()) + } + return err + } + log.Info("Created alias", "alias", *a.AliasArn) + + // create permissions prior to creating function url + // https://us-east-1.console.aws.amazon.com/lambda/services/ajax?operation=addPermission&locale=en + log.Info("Creating permission...") + p, err := lambdasrv.AddPermission(&lambda.AddPermissionInput{ + FunctionUrlAuthType: aws.String(lambda.FunctionUrlAuthTypeNone), + FunctionName: a.AliasArn, + Action: aws.String("lambda:InvokeFunctionUrl"), + Principal: aws.String("*"), + Qualifier: aws.String(qualifier), + StatementId: aws.String("FunctionURLAllowPublicAccess"), + }) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + log.Error("Error creating permission", "error", aerr.Code(), "message", aerr.Message()) + } + } + log.Info("Created permission", "permission", *p.Statement) + + // https://us-east-1.console.aws.amazon.com/lambda/services/ajax?operation=createFunctionUrlConfig&locale=en + o, err := lambdasrv.CreateFunctionUrlConfig(&lambda.CreateFunctionUrlConfigInput{ + // When you choose auth type NONE, Lambda [DASHBOARD OPERATION ONLY] automatically creates the + // following resource-based policy and attaches it to your function. + // This policy makes your function public to anyone with the function URL. + // You can edit the policy later. To limit access to authenticated IAM users and roles, choose auth type AWS_IAM. + AuthType: aws.String(lambda.FunctionUrlAuthTypeNone), + FunctionName: a.AliasArn, + Cors: &lambda.Cors{}, + }) + if err != nil { + if aerr, ok := err.(awserr.Error); ok { + log.Error("Error creating function url config", "error", aerr.Code(), "message", aerr.Message()) + } + return err + } + log.Info("Created function url config", "url", *o.FunctionUrl) + + return nil +} + +func (r *Releaser) resourceFunctionUrlDestroy( + ctx context.Context, + sess *session.Session, + sg terminal.StepGroup, + // state *Resource_LoadBalancer, +) error { + step := sg.Add("Destroying Lambda URL...") + step.Update("Destroyed Lambda URL...") + step.Done() + return nil +} + +func (r *Releaser) Release( + ctx context.Context, + log hclog.Logger, + src *component.Source, + ui terminal.UI, + // waypoint automatically injects the previous component's output + // - https://www.waypointproject.io/docs/extending-waypoint/passing-values + dep *Deployment, +) (*Release, error) { + sg := ui.StepGroup() + defer sg.Wait() + + log.Info("Creating Function URL...") + log.Info("Deployment details", "deployment", dep) + log.Info("Deployment details", "FuncArn", dep.FuncArn, "VerArn", dep.VerArn) + + // Create our resource manager and create + rm := r.resourceManager(log) + if err := rm.CreateAll( + ctx, log, sg, ui, src, + dep, + ); err != nil { + log.Info("Error creating resources", "error", err) + return nil, err + } + + // Get our function url state to verify + fnUrlState := rm.Resource("function_url").State().(*Resource_FunctionUrl) + log.Info("Function URL state", "url", fnUrlState.Url) + if fnUrlState == nil { + return nil, status.Errorf(codes.Internal, "function url state is nil, this should never happen") + } + + return &Release{ + Url: fnUrlState.Url, + FuncArn: dep.FuncArn, + VerArn: dep.VerArn, + }, nil +} + +// Destroy will modify or delete Listeners, so that the platform can destroy the +// target groups +func (r *Releaser) Destroy( + ctx context.Context, + log hclog.Logger, + release *Release, + ui terminal.UI, +) error { + sg := ui.StepGroup() + defer sg.Wait() + sess, err := utils.GetSession(&utils.SessionConfig{ + Logger: log, + }) + if err != nil { + return err + } + + rm := r.resourceManager(log) + + // Destroy All + return rm.DestroyAll(ctx, log, sg, ui, sess) +} + +// ReleaserConfig is the configuration structure for the Releaser. +type ReleaserConfig struct { + // "AWS_IAM" or "NONE" + AuthType string `hcl:"auth_type,optional"` + // todo(kevinwang): CORS +} + +func (r *Releaser) Status( + ctx context.Context, + log hclog.Logger, + release *Release, + ui terminal.UI, +) (*sdk.StatusReport, error) { + var report sdk.StatusReport + report.External = true + defer func() { + report.GeneratedTime = timestamppb.Now() + }() + return &report, nil +} + +func (r *Releaser) Documentation() (*docs.Documentation, error) { + doc, err := docs.New(docs.FromConfig(&ReleaserConfig{})) + if err != nil { + return nil, err + } + + doc.Description("TODO: Add description") + + // doc.Input("alb.TargetGroup") + // doc.Output("alb.Release") + // doc.AddMapper( + // "ec2.Deployment", + // "alb.TargetGroup", + // "Allow EC2 Deployments to be hooked up to an ALB", + // ) + + // doc.AddMapper( + // "lambda.Deployment", + // "alb.TargetGroup", + // "Allow Lambda Deployments to be hooked up to an ALB", + // ) + + // doc.SetField( + // "name", + // "the name to assign the ALB", + // docs.Summary( + // "names have to be unique per region", + // ), + // docs.Default("derived from application name"), + // ) + + // doc.SetField( + // "port", + // "the TCP port to configure the ALB to listen on", + // docs.Default("80 for HTTP, 443 for HTTPS"), + // ) + + // doc.SetField( + // "subnets", + // "the subnet ids to allow the ALB to run in", + // docs.Default("public subnets in the account default VPC"), + // ) + + // doc.SetField( + // "certificate", + // "ARN for the certificate to install on the ALB listener", + // docs.Summary( + // "when this is set, the port automatically changes to 443 unless", + // "overriden in this configuration", + // ), + // ) + + // doc.SetField( + // "zone_id", + // "Route53 ZoneID to create a DNS record into", + // docs.Summary( + // "set along with domain_name to have DNS automatically setup for the ALB", + // ), + // ) + + // doc.SetField( + // "domain_name", + // "Fully qualified domain name to set for the ALB", + // docs.Summary( + // "set along with zone_id to have DNS automatically setup for the ALB.", + // "this value should include the full hostname and domain name, for instance", + // "app.example.com", + // ), + // ) + + // doc.SetField( + // "listener_arn", + // "the ARN on an existing ALB to configure", + // docs.Summary( + // "when this is set, no ALB or Listener is created. Instead the application is", + // "configured by manipulating this existing Listener. This allows users to", + // "configure their ALB outside waypoint but still have waypoint hook the application", + // "to that ALB", + // ), + // ) + + return doc, nil +} + +var ( + _ component.ReleaseManager = (*Releaser)(nil) + _ component.Configurable = (*Releaser)(nil) + _ component.Destroyer = (*Releaser)(nil) + _ component.Documented = (*Releaser)(nil) + _ component.Status = (*Releaser)(nil) +) diff --git a/go.mod b/go.mod index b528ca497a4..73d1ed27bb9 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/DataDog/opencensus-go-exporter-datadog v0.0.0-20210527074920-9baf37265e83 github.com/adrg/xdg v0.2.1 github.com/armon/circbuf v0.0.0-20190214190532-5111143e8da2 - github.com/aws/aws-sdk-go v1.43.0 + github.com/aws/aws-sdk-go v1.43.34 github.com/bmatcuk/doublestar v1.1.5 github.com/buildpacks/pack v0.20.0 github.com/cenkalti/backoff/v4 v4.1.1 diff --git a/go.sum b/go.sum index 95f131e4fbd..8961953c135 100644 --- a/go.sum +++ b/go.sum @@ -286,8 +286,8 @@ github.com/aws/aws-sdk-go v1.31.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU github.com/aws/aws-sdk-go v1.31.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.33.6/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= github.com/aws/aws-sdk-go v1.34.9/go.mod h1:5zCpMtNQVjRREroY7sYe8lOMRSxkhG6MZveU8YkpAk0= -github.com/aws/aws-sdk-go v1.43.0 h1:y4UrPbxU/mIL08qksVPE/nwH9IXuC1udjOaNyhEe+pI= -github.com/aws/aws-sdk-go v1.43.0/go.mod h1:OGr6lGMAKGlG9CVrYnWYDKIyb829c6EVBRjxqjmPepc= +github.com/aws/aws-sdk-go v1.43.34 h1:8+P+773CDgQqN1eLH1QHT6XgXHUbME3sAbDGszzjajY= +github.com/aws/aws-sdk-go v1.43.34/go.mod h1:y4AeaBuwd2Lk+GepC1E9v0qOiTws0MIWAX4oIKwKHZo= github.com/aybabtme/rgbterm v0.0.0-20170906152045-cc83f3b3ce59/go.mod h1:q/89r3U2H7sSsE2t6Kca0lfwTK8JdoNGS/yzM/4iH5I= github.com/baiyubin/aliyun-sts-go-sdk v0.0.0-20180326062324-cfa1a18b161f/go.mod h1:AuiFmCCPBSrqvVMvuqFuk0qogytodnVFVSN5CeJB8Gc= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= @@ -2127,7 +2127,6 @@ golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96b golang.org/x/net v0.0.0-20210428140749-89ef3d95e781/go.mod h1:OJAsFXCWl8Ukc7SiCT/9KSuxbyM7479/AVlXFRxuMCk= golang.org/x/net v0.0.0-20210510120150-4163338589ed/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20210520170846-37e1c6afe023/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20211216030914-fe4d6282115f/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd h1:O7DYs+zxREGLKzKoMQrtrEacpb0ZVXA5rIwylE2Xchk= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= golang.org/x/oauth2 v0.0.0-20180724155351-3d292e4d0cdc/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= From d256eb59eada12c22bc29cafdfeb1bd8ffd738cf Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Thu, 7 Apr 2022 09:46:18 -0400 Subject: [PATCH 02/18] chore: comment --- builtin/aws/lambda/releaser.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index fd656c1f7a2..f4468fec724 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -118,12 +118,8 @@ func (r *Releaser) resourceFunctionUrlCreate( } log.Info("Created permission", "permission", *p.Statement) - // https://us-east-1.console.aws.amazon.com/lambda/services/ajax?operation=createFunctionUrlConfig&locale=en o, err := lambdasrv.CreateFunctionUrlConfig(&lambda.CreateFunctionUrlConfigInput{ - // When you choose auth type NONE, Lambda [DASHBOARD OPERATION ONLY] automatically creates the - // following resource-based policy and attaches it to your function. - // This policy makes your function public to anyone with the function URL. - // You can edit the policy later. To limit access to authenticated IAM users and roles, choose auth type AWS_IAM. + // Todo: make AuthType configurable via HCL AuthType: aws.String(lambda.FunctionUrlAuthTypeNone), FunctionName: a.AliasArn, Cors: &lambda.Cors{}, @@ -143,7 +139,6 @@ func (r *Releaser) resourceFunctionUrlDestroy( ctx context.Context, sess *session.Session, sg terminal.StepGroup, - // state *Resource_LoadBalancer, ) error { step := sg.Add("Destroying Lambda URL...") step.Update("Destroyed Lambda URL...") From 0010acafcefd68590b6afebb7d21c4306d0a4b16 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 8 Apr 2022 02:21:11 -0400 Subject: [PATCH 03/18] chore: re-generate proto --- builtin/aws/lambda/lambda.go | 2 +- builtin/aws/lambda/plugin.pb.go | 74 ++++++++++++++++++++------------- builtin/aws/lambda/plugin.proto | 4 +- 3 files changed, 48 insertions(+), 32 deletions(-) diff --git a/builtin/aws/lambda/lambda.go b/builtin/aws/lambda/lambda.go index ea9b1e67957..31f1ec88e74 100644 --- a/builtin/aws/lambda/lambda.go +++ b/builtin/aws/lambda/lambda.go @@ -5,7 +5,7 @@ import ( sdk "github.com/hashicorp/waypoint-plugin-sdk" ) -//go:generate protoc -I ../../../.. -I ../../../thirdparty/proto/opaqueany --go_out=../../../.. waypoint/builtin/aws/lambda/plugin.proto +//go:generate protoc -I ../../../.. -I ../../../thirdparty/proto --go_out=../../../.. waypoint/builtin/aws/lambda/plugin.proto // Options are the SDK options to use for instantiation for // the Google Cloud Run plugin. diff --git a/builtin/aws/lambda/plugin.pb.go b/builtin/aws/lambda/plugin.pb.go index 53a14dd79af..5ea2c6729d6 100644 --- a/builtin/aws/lambda/plugin.pb.go +++ b/builtin/aws/lambda/plugin.pb.go @@ -7,6 +7,7 @@ package lambda import ( + opaqueany "github.com/hashicorp/opaqueany" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -119,9 +120,10 @@ type Release struct { unknownFields protoimpl.UnknownFields // The function's public url - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` - FuncArn string `protobuf:"bytes,2,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` - VerArn string `protobuf:"bytes,3,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` // opaqueany.Any resource_state = 4; + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + FuncArn string `protobuf:"bytes,2,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` + VerArn string `protobuf:"bytes,3,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` + ResourceState *opaqueany.Any `protobuf:"bytes,4,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` } func (x *Release) Reset() { @@ -177,6 +179,13 @@ func (x *Release) GetVerArn() string { return "" } +func (x *Release) GetResourceState() *opaqueany.Any { + if x != nil { + return x.ResourceState + } + return nil +} + // Resource contains the internal resource states. type Resource struct { state protoimpl.MessageState @@ -269,28 +278,33 @@ var file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc = []byte{ 0x0a, 0x28, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x61, 0x77, 0x73, 0x2e, - 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x22, 0xac, 0x01, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x6c, 0x6f, - 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, - 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, - 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x5f, - 0x61, 0x72, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, 0x72, 0x41, 0x72, - 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x67, 0x72, 0x6f, 0x75, - 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, - 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, - 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x4f, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, - 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, - 0x72, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, + 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x1a, 0x13, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, + 0x79, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xac, 0x01, 0x0a, 0x0a, + 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, + 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, + 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, + 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x76, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x22, 0x2b, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, - 0x63, 0x65, 0x1a, 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, - 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, - 0x75, 0x72, 0x6c, 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, - 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, - 0x64, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x07, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, + 0x76, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, + 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, + 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, + 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x86, 0x01, 0x0a, 0x07, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, + 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, + 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, + 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x12, 0x35, 0x0a, 0x0e, + 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, + 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, + 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x74, + 0x61, 0x74, 0x65, 0x22, 0x2b, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, + 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x10, + 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, + 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, + 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -311,13 +325,15 @@ var file_waypoint_builtin_aws_lambda_plugin_proto_goTypes = []interface{}{ (*Release)(nil), // 1: aws.lambda.Release (*Resource)(nil), // 2: aws.lambda.Resource (*Resource_FunctionUrl)(nil), // 3: aws.lambda.Resource.FunctionUrl + (*opaqueany.Any)(nil), // 4: opaqueany.Any } var file_waypoint_builtin_aws_lambda_plugin_proto_depIdxs = []int32{ - 0, // [0:0] is the sub-list for method output_type - 0, // [0:0] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name + 4, // 0: aws.lambda.Release.resource_state:type_name -> opaqueany.Any + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name } func init() { file_waypoint_builtin_aws_lambda_plugin_proto_init() } diff --git a/builtin/aws/lambda/plugin.proto b/builtin/aws/lambda/plugin.proto index 0c1f0a35538..3798afccb05 100644 --- a/builtin/aws/lambda/plugin.proto +++ b/builtin/aws/lambda/plugin.proto @@ -4,7 +4,7 @@ package aws.lambda; option go_package = "waypoint/builtin/aws/lambda"; -// import "opaqueany/any.proto"; +import "opaqueany/any.proto"; message Deployment { // Identifier for the deployment, required by Waypoint @@ -31,7 +31,7 @@ message Release { string url = 1; string func_arn = 2; string ver_arn = 3; - // opaqueany.Any resource_state = 4; + opaqueany.Any resource_state = 4; } // Resource contains the internal resource states. From 20eb8489e21dd7a2f6a514658b7ad08fcca90ab5 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sat, 9 Apr 2022 15:38:50 -0400 Subject: [PATCH 04/18] chore: revert Platform.destroy --- builtin/aws/lambda/platform.go | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/builtin/aws/lambda/platform.go b/builtin/aws/lambda/platform.go index 505d8fe9def..f695e328571 100644 --- a/builtin/aws/lambda/platform.go +++ b/builtin/aws/lambda/platform.go @@ -712,32 +712,6 @@ func (p *Platform) Destroy( FunctionName: aws.String(deployment.FuncArn), Qualifier: aws.String(deployment.Version), }) - if err != nil { - // older lambda version fail to delete if they have aliases - if aerr, ok := err.(awserr.Error); ok { - switch aerr.Code() { - case lambda.ErrCodeResourceConflictException: - log.Warn("error deleting lambda function", "error", aerr.Error()) - st.Step(terminal.StatusWarn, "Error deleting function..."+aerr.Message()) - st.Step(terminal.StatusWarn, "Attempting to delete function alias...") - - _, err = lamSvc.DeleteAlias(&lambda.DeleteAliasInput{ - FunctionName: aws.String(deployment.FuncArn), - Name: aws.String("Alias_" + deployment.Version), - }) - if err != nil { - // todo logs - return err - } - st.Step(terminal.StatusOK, "Deleted alias: "+"Alias_"+deployment.Version) - st.Update("Attempting to delete again...") - _, err = lamSvc.DeleteFunction(&lambda.DeleteFunctionInput{ - FunctionName: aws.String(deployment.FuncArn), - Qualifier: aws.String(deployment.Version), - }) - } - } - } } st.Step(terminal.StatusOK, "Deleted Lambda function version") From 1193fd45bc92856ad22a47eebb6351e9f675978b Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sun, 10 Apr 2022 01:36:25 -0400 Subject: [PATCH 05/18] chore: cleanup releaser implementation --- builtin/aws/lambda/releaser.go | 256 +++++++++++++++------------------ 1 file changed, 119 insertions(+), 137 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index f4468fec724..9cc2c569c4b 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -2,6 +2,7 @@ package lambda import ( "context" + "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" @@ -50,10 +51,8 @@ func (r *Releaser) resourceManager(log hclog.Logger) *resource.Manager { resource.WithResource(resource.NewResource( resource.WithName("function_url"), - // WithState is needed for `rm.Resource("function_url").State()` to succeed resource.WithState(&Resource_FunctionUrl{}), resource.WithCreate(r.resourceFunctionUrlCreate), - resource.WithDestroy(r.resourceFunctionUrlDestroy), )), ) } @@ -67,6 +66,10 @@ func (r *Releaser) getSession( }) } +var ( + DefaultFunctionUrlAuthType = lambda.FunctionUrlAuthTypeNone +) + func (r *Releaser) resourceFunctionUrlCreate( ctx context.Context, log hclog.Logger, @@ -74,75 +77,95 @@ func (r *Releaser) resourceFunctionUrlCreate( sg terminal.StepGroup, ui terminal.UI, dep *Deployment, + state *Resource_FunctionUrl, ) error { - log.Info("Creating Lambda URL...", "VerArn", dep.VerArn, "FuncArn", dep.FuncArn) - lambdasrv := lambda.New(sess) - log.Info("Creating alias...") - log.Info("Version: " + dep.Version) - log.Info("FuncArn: " + dep.FuncArn) - // create a function alias so that we can create a function url - // https://docs.aws.amazon.com/lambda/latest/dg/API_CreateAlias.html - qualifier := "Alias_" + dep.Version - a, err := lambdasrv.CreateAlias(&lambda.CreateAliasInput{ - // Alias name cannot be numeric-only - Name: aws.String(qualifier), - Description: aws.String("Waypoint Lambda Alias"), - FunctionName: aws.String(dep.FuncArn), - FunctionVersion: aws.String(dep.Version), - }) - if err != nil { - if aerr, ok := err.(awserr.Error); ok { - log.Error("Error creating alias", "error", aerr.Code(), "message", aerr.Message()) - } - return err + functionUrlAuthType := DefaultFunctionUrlAuthType + if r.config.AuthType != "" { + functionUrlAuthType = strings.ToUpper(r.config.AuthType) } - log.Info("Created alias", "alias", *a.AliasArn) - - // create permissions prior to creating function url - // https://us-east-1.console.aws.amazon.com/lambda/services/ajax?operation=addPermission&locale=en - log.Info("Creating permission...") - p, err := lambdasrv.AddPermission(&lambda.AddPermissionInput{ - FunctionUrlAuthType: aws.String(lambda.FunctionUrlAuthTypeNone), - FunctionName: a.AliasArn, + + // TODO(thiskevinwang): source cors from HCL config + cors := lambda.Cors{} + + addPermissionInput := lambda.AddPermissionInput{ Action: aws.String("lambda:InvokeFunctionUrl"), + FunctionUrlAuthType: aws.String(functionUrlAuthType), + FunctionName: aws.String(dep.FuncArn), Principal: aws.String("*"), - Qualifier: aws.String(qualifier), StatementId: aws.String("FunctionURLAllowPublicAccess"), - }) + } + + createFunctionUrlConfigInput := lambda.CreateFunctionUrlConfigInput{ + AuthType: aws.String(functionUrlAuthType), + FunctionName: &dep.FuncArn, + // TODO(thiskevinwang): make Cors configurable via HCL + Cors: &cors, + } + + step := sg.Add("Creating permissions for public access to the lambda URL...") + defer step.Abort() + + // Grant public/anonymous access to the lambda URL + _, err := lambdasrv.AddPermission(&addPermissionInput) if err != nil { + log.Error("Error creating permission", "error", err) if aerr, ok := err.(awserr.Error); ok { - log.Error("Error creating permission", "error", aerr.Code(), "message", aerr.Message()) + switch aerr.Code() { + case "ResourceConflictException": + // permissions already exist. likely safe to continue + step.Update("Permissions for public access access already exist") + default: + step.Update("Error creating permissions: %q, %q", aerr.Code(), aerr.Message()) + return err + } + } else { + return err } + } else { + step.Update("Created permissions for public access access to the lambda URL") } - log.Info("Created permission", "permission", *p.Statement) + step.Done() - o, err := lambdasrv.CreateFunctionUrlConfig(&lambda.CreateFunctionUrlConfigInput{ - // Todo: make AuthType configurable via HCL - AuthType: aws.String(lambda.FunctionUrlAuthTypeNone), - FunctionName: a.AliasArn, - Cors: &lambda.Cors{}, - }) + step = sg.Add("Creating Lambda URL...") + defer step.Abort() + + cfo, err := lambdasrv.CreateFunctionUrlConfig(&createFunctionUrlConfigInput) if err != nil { + log.Error("Error creating function url config", "error", err) if aerr, ok := err.(awserr.Error); ok { - log.Error("Error creating function url config", "error", aerr.Code(), "message", aerr.Message()) + switch aerr.Code() { + case "ResourceConflictException": + // function url config already exists. get it. maybe safe to continue + step.Update("Function url config already exists") + + // retrieve existing function url to update state + if gfc, err := lambdasrv.GetFunctionUrlConfig(&lambda.GetFunctionUrlConfigInput{ + FunctionName: aws.String(dep.FuncArn), + }); err != nil { + // this should not realistically occur + log.Error("Error getting function url config", "error", err) + return err + } else { + state.Url = *gfc.FunctionUrl + step.Update("Reusing existing Lambda URL: %q", state.Url) + } + default: + step.Update("Error creating function url config: %q, %q", aerr.Code(), aerr.Message()) + return err + } + } else { + return err } - return err + } else { + // update state + state.Url = *cfo.FunctionUrl + step.Update("Created Lambda URL: %q", state.Url) } - log.Info("Created function url config", "url", *o.FunctionUrl) - return nil -} - -func (r *Releaser) resourceFunctionUrlDestroy( - ctx context.Context, - sess *session.Session, - sg terminal.StepGroup, -) error { - step := sg.Add("Destroying Lambda URL...") - step.Update("Destroyed Lambda URL...") step.Done() + return nil } @@ -151,17 +174,11 @@ func (r *Releaser) Release( log hclog.Logger, src *component.Source, ui terminal.UI, - // waypoint automatically injects the previous component's output - // - https://www.waypointproject.io/docs/extending-waypoint/passing-values dep *Deployment, ) (*Release, error) { sg := ui.StepGroup() defer sg.Wait() - log.Info("Creating Function URL...") - log.Info("Deployment details", "deployment", dep) - log.Info("Deployment details", "FuncArn", dep.FuncArn, "VerArn", dep.VerArn) - // Create our resource manager and create rm := r.resourceManager(log) if err := rm.CreateAll( @@ -180,14 +197,13 @@ func (r *Releaser) Release( } return &Release{ - Url: fnUrlState.Url, - FuncArn: dep.FuncArn, - VerArn: dep.VerArn, + Url: fnUrlState.Url, + FuncArn: dep.FuncArn, + VerArn: dep.VerArn, + ResourceState: rm.State(), }, nil } -// Destroy will modify or delete Listeners, so that the platform can destroy the -// target groups func (r *Releaser) Destroy( ctx context.Context, log hclog.Logger, @@ -222,11 +238,19 @@ func (r *Releaser) Status( release *Release, ui terminal.UI, ) (*sdk.StatusReport, error) { - var report sdk.StatusReport - report.External = true - defer func() { - report.GeneratedTime = timestamppb.Now() - }() + sg := ui.StepGroup() + defer sg.Wait() + + s := sg.Add("Gathering health report for lambda url deployment: %q", release.Url) + defer s.Done() + + report := sdk.StatusReport{ + External: true, + Health: sdk.StatusReport_READY, + GeneratedTime: timestamppb.Now(), + HealthMessage: "Lambda URL deployment health report not implemented", + } + return &report, nil } @@ -236,79 +260,37 @@ func (r *Releaser) Documentation() (*docs.Documentation, error) { return nil, err } - doc.Description("TODO: Add description") - - // doc.Input("alb.TargetGroup") - // doc.Output("alb.Release") - // doc.AddMapper( - // "ec2.Deployment", - // "alb.TargetGroup", - // "Allow EC2 Deployments to be hooked up to an ALB", - // ) - - // doc.AddMapper( - // "lambda.Deployment", - // "alb.TargetGroup", - // "Allow Lambda Deployments to be hooked up to an ALB", - // ) - - // doc.SetField( - // "name", - // "the name to assign the ALB", - // docs.Summary( - // "names have to be unique per region", - // ), - // docs.Default("derived from application name"), - // ) - - // doc.SetField( - // "port", - // "the TCP port to configure the ALB to listen on", - // docs.Default("80 for HTTP, 443 for HTTPS"), - // ) - - // doc.SetField( - // "subnets", - // "the subnet ids to allow the ALB to run in", - // docs.Default("public subnets in the account default VPC"), - // ) - - // doc.SetField( - // "certificate", - // "ARN for the certificate to install on the ALB listener", - // docs.Summary( - // "when this is set, the port automatically changes to 443 unless", - // "overriden in this configuration", - // ), - // ) + doc.Description("Create an AWS Lambda function URL") - // doc.SetField( - // "zone_id", - // "Route53 ZoneID to create a DNS record into", - // docs.Summary( - // "set along with domain_name to have DNS automatically setup for the ALB", - // ), - // ) - - // doc.SetField( - // "domain_name", - // "Fully qualified domain name to set for the ALB", - // docs.Summary( - // "set along with zone_id to have DNS automatically setup for the ALB.", - // "this value should include the full hostname and domain name, for instance", - // "app.example.com", - // ), - // ) + doc.Example( + ` +release { + use "aws-lambda" { + auth_type = "NONE" + } +} +`) + + doc.Input("lambda.Deployment") + doc.Output("lambda.Release") + + doc.SetField( + "auth_type", + "the Lambda function URL auth type", + docs.Summary( + "The AuthType parameter determines how Lambda authenticates or authorizes requests to your function URL. Must be either `AWS_IAM` or `NONE`.", + ), + docs.Default("NONE"), + ) + // todo(thiskevinwang): CORS // doc.SetField( - // "listener_arn", - // "the ARN on an existing ALB to configure", + // "cors", + // "the CORS configuration for the Lambda function URL", // docs.Summary( - // "when this is set, no ALB or Listener is created. Instead the application is", - // "configured by manipulating this existing Listener. This allows users to", - // "configure their ALB outside waypoint but still have waypoint hook the application", - // "to that ALB", + // "Use CORS to allow access to your function URL from any domain. You can also use CORS to control access for specific HTTP headers and methods in requests to your function URL", // ), + // docs.Default("{}"), // ) return doc, nil From e17c41d39bfb8fae96277a686e7b7215ddfa7079 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Mon, 11 Apr 2022 08:48:46 -0400 Subject: [PATCH 06/18] chore: changelog + generate docs - run `make gen/website-mdx`; remove diff from autoformatting --- .changelog/3187.txt | 3 +++ .../components/releasemanager-aws-lambda.mdx | 27 ++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) create mode 100644 .changelog/3187.txt diff --git a/.changelog/3187.txt b/.changelog/3187.txt new file mode 100644 index 00000000000..4f4190d7080 --- /dev/null +++ b/.changelog/3187.txt @@ -0,0 +1,3 @@ +```release-note:feature +plugin/aws-lambda: add `releaser` component. This leverages Lambda URLs. +``` diff --git a/website/content/partials/components/releasemanager-aws-lambda.mdx b/website/content/partials/components/releasemanager-aws-lambda.mdx index 2d3dd833e04..46075aa1b39 100644 --- a/website/content/partials/components/releasemanager-aws-lambda.mdx +++ b/website/content/partials/components/releasemanager-aws-lambda.mdx @@ -1,11 +1,36 @@ ## aws-lambda (releasemanager) +Create an AWS Lambda function URL. + ### Interface +- Input: **lambda.Deployment** +- Output: **lambda.Release** + +### Examples + +```hcl +release { + use "aws-lambda" { + auth_type = "NONE" + } +} +``` + ### Required Parameters This plugin has no required parameters. ### Optional Parameters -This plugin has no optional parameters. +These parameters are used in the [`use` stanza](/docs/waypoint-hcl/use) for this plugin. + +#### auth_type + +The Lambda function URL auth type. + +The AuthType parameter determines how Lambda authenticates or authorizes requests to your function URL. Must be either `AWS_IAM` or `NONE`. + +- Type: **string** +- **Optional** +- Default: NONE From eb6ba0584043b5a3623c2d00511ca5025f5ed573 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Tue, 12 Apr 2022 20:45:14 -0400 Subject: [PATCH 07/18] chore: remove status `GeneratedTime` --- builtin/aws/lambda/releaser.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index 9cc2c569c4b..265c4da222e 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -17,7 +17,6 @@ import ( "github.com/hashicorp/waypoint/builtin/aws/utils" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" - "google.golang.org/protobuf/types/known/timestamppb" ) type Releaser struct { @@ -247,7 +246,6 @@ func (r *Releaser) Status( report := sdk.StatusReport{ External: true, Health: sdk.StatusReport_READY, - GeneratedTime: timestamppb.Now(), HealthMessage: "Lambda URL deployment health report not implemented", } From c2c3e8b5c62c2d35af0e49f3d5a6c6010b355dd6 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Wed, 13 Apr 2022 09:44:24 -0400 Subject: [PATCH 08/18] check function URL in Status() --- builtin/aws/lambda/releaser.go | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index 265c4da222e..58d17193ade 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -2,6 +2,8 @@ package lambda import ( "context" + "fmt" + "net/http" "strings" "github.com/aws/aws-sdk-go/aws" @@ -107,8 +109,7 @@ func (r *Releaser) resourceFunctionUrlCreate( defer step.Abort() // Grant public/anonymous access to the lambda URL - _, err := lambdasrv.AddPermission(&addPermissionInput) - if err != nil { + if _, err := lambdasrv.AddPermission(&addPermissionInput); err != nil { log.Error("Error creating permission", "error", err) if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { @@ -244,9 +245,28 @@ func (r *Releaser) Status( defer s.Done() report := sdk.StatusReport{ - External: true, - Health: sdk.StatusReport_READY, - HealthMessage: "Lambda URL deployment health report not implemented", + External: true, + } + + // check the function url status + log.Info("Checking function url status...", "url", release.Url) + if resp, err := http.Get(release.Url); err != nil { + log.Error("Failed to get a response from the Lambda URL: %s", err) + report.Health = sdk.StatusReport_UNKNOWN + report.HealthMessage = "Failed to get a response from the Lambda URL" + } else { + switch resp.StatusCode { + case http.StatusOK: + log.Info("Lambda URL returned a 200") + report.Health = sdk.StatusReport_READY + report.HealthMessage = "Lambda URL appears to be healthy" + break + default: + log.Error("Lambda URL returned a non-200 response: %d", resp.StatusCode) + report.Health = sdk.StatusReport_DOWN + report.HealthMessage = fmt.Sprintf("Lambda URL returned a non-200 response: %d", resp.StatusCode) + break + } } return &report, nil From 0153d2904e82cefc0a33987dcdfb361586a3778a Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Wed, 13 Apr 2022 10:22:59 -0400 Subject: [PATCH 09/18] chore: fix step group message --- builtin/aws/lambda/releaser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index 58d17193ade..48897c4aea8 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -115,7 +115,7 @@ func (r *Releaser) resourceFunctionUrlCreate( switch aerr.Code() { case "ResourceConflictException": // permissions already exist. likely safe to continue - step.Update("Permissions for public access access already exist") + step.Update("Permissions for public access already exist") default: step.Update("Error creating permissions: %q, %q", aerr.Code(), aerr.Message()) return err @@ -124,7 +124,7 @@ func (r *Releaser) resourceFunctionUrlCreate( return err } } else { - step.Update("Created permissions for public access access to the lambda URL") + step.Update("Created permissions for public access to the lambda URL") } step.Done() From 4ecbec9c4d4a23841e5f4efc2e24ef2ea997af8d Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 15 Apr 2022 08:34:04 -0400 Subject: [PATCH 10/18] remove redundant `break` --- builtin/aws/lambda/releaser.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index 48897c4aea8..e47e68a13ef 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -260,12 +260,10 @@ func (r *Releaser) Status( log.Info("Lambda URL returned a 200") report.Health = sdk.StatusReport_READY report.HealthMessage = "Lambda URL appears to be healthy" - break default: log.Error("Lambda URL returned a non-200 response: %d", resp.StatusCode) report.Health = sdk.StatusReport_DOWN report.HealthMessage = fmt.Sprintf("Lambda URL returned a non-200 response: %d", resp.StatusCode) - break } } From 53cdd75ac362034b938cd98cab0a0d48946793a6 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Fri, 15 Apr 2022 09:29:02 -0400 Subject: [PATCH 11/18] extract `resourceFunctionPermissionCreate` --- builtin/aws/lambda/releaser.go | 263 ++++++++++++++++++++++++++++----- 1 file changed, 229 insertions(+), 34 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index e47e68a13ef..c58fb7ff595 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -2,14 +2,17 @@ package lambda import ( "context" + "encoding/json" "fmt" "net/http" + "reflect" "strings" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/lambda" + validation "github.com/go-ozzo/ozzo-validation/v4" "github.com/hashicorp/go-hclog" "github.com/hashicorp/waypoint-plugin-sdk/component" "github.com/hashicorp/waypoint-plugin-sdk/docs" @@ -25,11 +28,57 @@ type Releaser struct { config ReleaserConfig } +// Lambda GetPolicy() returns a JSON string of its IAM policy, so +// we need to unmarshal it into this struct in order to use it. +// +// See https://github.com/aws/aws-sdk-go/issues/127 +// and https://github.com/aws/aws-sdk-go-v2/issues/225 +type IAMPolicy struct { + Version string `json:"Version"` + ID string `json:"Id"` + Statement []struct { + Sid string `json:"Sid"` + Effect string `json:"Effect"` + // Principal can be either a string, like "*", or a struct + // like { "AWS": "arn:aws:iam::123456789012:root" } + Principal interface{} `json:"Principal"` + Action string `json:"Action"` + Resource string `json:"Resource"` + Condition struct { + StringEquals struct { + LambdaFunctionURLAuthType string `json:"lambda:FunctionUrlAuthType"` + } `json:"StringEquals"` + } `json:"Condition"` + } `json:"Statement"` +} + // Config implements Configurable func (r *Releaser) Config() (interface{}, error) { return &r.config, nil } +// ConfigSet is called after a configuration has been decoded +// we can use this to validate the config +func (r *Releaser) ConfigSet(config interface{}) error { + rc, ok := config.(*ReleaserConfig) + if !ok { + // this should never happen + return fmt.Errorf("Invalid configuration, expected *lambda.ReleaserConfig, got %s", reflect.TypeOf(config)) + } + + err := utils.Error(validation.ValidateStruct(rc, + validation.Field(&rc.Principal, + validation.Empty.When(rc.AuthType != "" && rc.AuthType != lambda.FunctionUrlAuthTypeAwsIam).Error("principal requires auth_type to be set to \"AWS_IAM\""), + ), + )) + + if err != nil { + return err + } + + return nil +} + // ReleaseFunc implements component.ReleaseManager func (r *Releaser) ReleaseFunc() interface{} { return r.Release @@ -50,6 +99,11 @@ func (r *Releaser) resourceManager(log hclog.Logger) *resource.Manager { resource.WithLogger(log.Named("resource_manager")), resource.WithValueProvider(r.getSession), + resource.WithResource(resource.NewResource( + resource.WithName("function_permission"), + resource.WithCreate(r.resourceFunctionPermissionCreate), + )), + resource.WithResource(resource.NewResource( resource.WithName("function_url"), resource.WithState(&Resource_FunctionUrl{}), @@ -68,69 +122,190 @@ func (r *Releaser) getSession( } var ( + // If auth_type is not set we'll default to "NONE", allowing public access to the function URL DefaultFunctionUrlAuthType = lambda.FunctionUrlAuthTypeNone + // If principal is not set we'll allow any authenticated AWS user to invoke the function URL + DefaultPrincipal = "*" ) -func (r *Releaser) resourceFunctionUrlCreate( +func (r *Releaser) resourceFunctionPermissionCreate( ctx context.Context, log hclog.Logger, sess *session.Session, sg terminal.StepGroup, ui terminal.UI, dep *Deployment, - state *Resource_FunctionUrl, ) error { + step := sg.Add("Checking function permission...") + defer step.Abort() + lambdasrv := lambda.New(sess) - functionUrlAuthType := DefaultFunctionUrlAuthType - if r.config.AuthType != "" { - functionUrlAuthType = strings.ToUpper(r.config.AuthType) - } + var reset bool + var revisionId string - // TODO(thiskevinwang): source cors from HCL config - cors := lambda.Cors{} + // use a single StatementId for now + statementId := "waypoint-function-url-access" - addPermissionInput := lambda.AddPermissionInput{ - Action: aws.String("lambda:InvokeFunctionUrl"), - FunctionUrlAuthType: aws.String(functionUrlAuthType), - FunctionName: aws.String(dep.FuncArn), - Principal: aws.String("*"), - StatementId: aws.String("FunctionURLAllowPublicAccess"), + authtype := strings.ToUpper(r.config.AuthType) + if authtype == "" { + authtype = DefaultFunctionUrlAuthType } - - createFunctionUrlConfigInput := lambda.CreateFunctionUrlConfigInput{ - AuthType: aws.String(functionUrlAuthType), - FunctionName: &dep.FuncArn, - // TODO(thiskevinwang): make Cors configurable via HCL - Cors: &cors, + principal := r.config.Principal + if principal == "" { + principal = DefaultPrincipal } - step := sg.Add("Creating permissions for public access to the lambda URL...") - defer step.Abort() - - // Grant public/anonymous access to the lambda URL - if _, err := lambdasrv.AddPermission(&addPermissionInput); err != nil { - log.Error("Error creating permission", "error", err) + // check if principal or auth type have changed + if gpo, err := lambdasrv.GetPolicy(&lambda.GetPolicyInput{ + FunctionName: aws.String(dep.FuncArn), + }); err != nil { if aerr, ok := err.(awserr.Error); ok { switch aerr.Code() { - case "ResourceConflictException": - // permissions already exist. likely safe to continue - step.Update("Permissions for public access already exist") + // noop if ResourceNotFoundException + // This will likely happen if the function has 0 permissions + case lambda.ErrCodeResourceNotFoundException: + step.Update("No permissions found. Creating one...") + reset = true default: - step.Update("Error creating permissions: %q, %q", aerr.Code(), aerr.Message()) + step.Update("Failed to get policy: %s", err) return err } } else { return err } } else { - step.Update("Created permissions for public access to the lambda URL") + policy := IAMPolicy{} + revisionId = *gpo.RevisionId + if err := json.Unmarshal([]byte(*gpo.Policy), &policy); err != nil { + // failed to unmarshal policy, this should never happen + log.Info("Failed to unmarshal policy: %s", err) + return err + } + + statementFound := false + // determine if we should update permissions + // find the statement + for _, st := range policy.Statement { + if st.Sid == statementId { + // found the previous statement, check if the principal has changed + statementFound = true + pType := reflect.TypeOf(st.Principal) + + switch pType { + case reflect.TypeOf(""): + if st.Principal != principal { + // principal has changed, we should update permissions + reset = true + } + case reflect.TypeOf(map[string]interface{}{}): + fmt.Println("3") + if st.Principal.(map[string]interface{})["AWS"].(string) != principal { + // principal has changed, we should update permissions + reset = true + } + default: + // this should never happen + return status.Errorf(codes.Unknown, "Unknown principal type from AWS policy: %s", pType) + } + + if st.Condition.StringEquals.LambdaFunctionURLAuthType != authtype { + // auth type has changed, we should update permissions + reset = true + } + } + } + if !statementFound { + // statement not found, we should create permissions + reset = true + } } + + if reset { + step.Update("Updating permissions to invoke lambda URL...") + + // attempt to remove the old permission + if _, err := lambdasrv.RemovePermission(&lambda.RemovePermissionInput{ + FunctionName: aws.String(dep.FuncArn), + RevisionId: aws.String(revisionId), + StatementId: aws.String(statementId), + }); err != nil { + // no-op if there is no permission + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case "ResourceNotFoundException": + // Non-fatal + log.Warn("Failed to remove permission", "error", err) + default: + log.Error("Failed to remove permission", "error", err) + return err + } + } + } + + // add new permission + if _, err := lambdasrv.AddPermission(&lambda.AddPermissionInput{ + Action: aws.String("lambda:InvokeFunctionUrl"), + FunctionUrlAuthType: aws.String(authtype), + FunctionName: aws.String(dep.FuncArn), + Principal: aws.String(principal), + StatementId: aws.String(statementId), + }); err != nil { + log.Error("Error creating permission", "error", err) + if aerr, ok := err.(awserr.Error); ok { + switch aerr.Code() { + case "ResourceConflictException": + // permissions already exist. This should not happen since we remove the permission first + step.Update("Permissions to invoke lambda URL access already exist") + default: + step.Update("Error creating permissions: %s", err) + return err + } + } else { + return err + } + } else { + step.Update("Updated permissions to invoke lambda URL") + } + } else { + step.Update("No permissions need to be updated") + } + step.Done() + return nil +} + +func (r *Releaser) resourceFunctionUrlCreate( + ctx context.Context, + log hclog.Logger, + sess *session.Session, + sg terminal.StepGroup, + ui terminal.UI, + dep *Deployment, + state *Resource_FunctionUrl, +) error { + lambdasrv := lambda.New(sess) + + functionUrlAuthType := DefaultFunctionUrlAuthType + if r.config.AuthType != "" { + functionUrlAuthType = strings.ToUpper(r.config.AuthType) + } + + // TODO(thiskevinwang): source cors from HCL config + cors := lambda.Cors{} - step = sg.Add("Creating Lambda URL...") + step := sg.Add("Creating Lambda URL...") defer step.Abort() + createFunctionUrlConfigInput := lambda.CreateFunctionUrlConfigInput{ + AuthType: aws.String(functionUrlAuthType), + FunctionName: aws.String(dep.FuncArn), + // TODO(thiskevinwang): make Cors configurable via HCL + Cors: &cors, + } + + // Create or Update the lambda URL + shouldUpdate := false cfo, err := lambdasrv.CreateFunctionUrlConfig(&createFunctionUrlConfigInput) if err != nil { log.Error("Error creating function url config", "error", err) @@ -148,8 +323,13 @@ func (r *Releaser) resourceFunctionUrlCreate( log.Error("Error getting function url config", "error", err) return err } else { - state.Url = *gfc.FunctionUrl - step.Update("Reusing existing Lambda URL: %q", state.Url) + // compare remote config to incoming config + if functionUrlAuthType != *gfc.AuthType { + shouldUpdate = true + } else { + step.Update("Reusing existing Lambda URL: %q", *gfc.FunctionUrl) + state.Url = *gfc.FunctionUrl + } } default: step.Update("Error creating function url config: %q, %q", aerr.Code(), aerr.Message()) @@ -164,6 +344,19 @@ func (r *Releaser) resourceFunctionUrlCreate( step.Update("Created Lambda URL: %q", state.Url) } + if shouldUpdate { + step.Update("Updating Lambda UR ConfigL...") + if ufc, err := lambdasrv.UpdateFunctionUrlConfig(&lambda.UpdateFunctionUrlConfigInput{ + AuthType: aws.String(functionUrlAuthType), + FunctionName: aws.String(dep.FuncArn), + Cors: &cors, + }); err != nil { + } else { + state.Url = *ufc.FunctionUrl + step.Update("Updated Lambda URL ConfigL: %q", state.Url) + } + } + step.Done() return nil @@ -229,6 +422,8 @@ func (r *Releaser) Destroy( type ReleaserConfig struct { // "AWS_IAM" or "NONE" AuthType string `hcl:"auth_type,optional"` + // Only permitted if AuthType is "AWS_IAM" otherwise defaults to "*" + Principal string `hcl:"principal,optional"` // todo(kevinwang): CORS } From 8697ecdb63c98576ab6aeaa1b49f1f81f424b678 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sat, 16 Apr 2022 00:17:24 -0400 Subject: [PATCH 12/18] typo --- builtin/aws/lambda/releaser.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index c58fb7ff595..a3be88fdb59 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -345,7 +345,7 @@ func (r *Releaser) resourceFunctionUrlCreate( } if shouldUpdate { - step.Update("Updating Lambda UR ConfigL...") + step.Update("Updating Lambda URL Config...") if ufc, err := lambdasrv.UpdateFunctionUrlConfig(&lambda.UpdateFunctionUrlConfigInput{ AuthType: aws.String(functionUrlAuthType), FunctionName: aws.String(dep.FuncArn), @@ -353,7 +353,7 @@ func (r *Releaser) resourceFunctionUrlCreate( }); err != nil { } else { state.Url = *ufc.FunctionUrl - step.Update("Updated Lambda URL ConfigL: %q", state.Url) + step.Update("Updated Lambda URL Config: %q", state.Url) } } From 43a76770c4ad5bdb6626774d4dc7bb55b33d12a4 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sat, 16 Apr 2022 01:35:24 -0400 Subject: [PATCH 13/18] update status report to WaitUntilFunctionActiveV2 - update docs - update proto --- builtin/aws/lambda/plugin.pb.go | 48 ++++++++++++++++++++------------- builtin/aws/lambda/plugin.proto | 14 +++++++--- builtin/aws/lambda/releaser.go | 47 +++++++++++++++++++------------- 3 files changed, 70 insertions(+), 39 deletions(-) diff --git a/builtin/aws/lambda/plugin.pb.go b/builtin/aws/lambda/plugin.pb.go index 5ea2c6729d6..5847658b35a 100644 --- a/builtin/aws/lambda/plugin.pb.go +++ b/builtin/aws/lambda/plugin.pb.go @@ -120,10 +120,14 @@ type Release struct { unknownFields protoimpl.UnknownFields // The function's public url - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` - FuncArn string `protobuf:"bytes,2,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` - VerArn string `protobuf:"bytes,3,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` - ResourceState *opaqueany.Any `protobuf:"bytes,4,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + // The AWS region the function is deployed in + Region string `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"` + // The ARN for the Lambda function itself. + FuncArn string `protobuf:"bytes,3,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` + // The ARN for the version of the Lambda function this deployment uses. + VerArn string `protobuf:"bytes,4,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` + ResourceState *opaqueany.Any `protobuf:"bytes,5,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` } func (x *Release) Reset() { @@ -165,6 +169,13 @@ func (x *Release) GetUrl() string { return "" } +func (x *Release) GetRegion() string { + if x != nil { + return x.Region + } + return "" +} + func (x *Release) GetFuncArn() string { if x != nil { return x.FuncArn @@ -290,21 +301,22 @@ var file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc = []byte{ 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x86, 0x01, 0x0a, 0x07, 0x52, + 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9e, 0x01, 0x0a, 0x07, 0x52, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, - 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, - 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x12, 0x35, 0x0a, 0x0e, - 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, - 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x74, - 0x61, 0x74, 0x65, 0x22, 0x2b, 0x0a, 0x08, 0x52, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, - 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x10, - 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, - 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, - 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x62, - 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, + 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, + 0x72, 0x41, 0x72, 0x6e, 0x12, 0x35, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, + 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x2b, 0x0a, 0x08, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, + 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( diff --git a/builtin/aws/lambda/plugin.proto b/builtin/aws/lambda/plugin.proto index 3798afccb05..87e5d377b1c 100644 --- a/builtin/aws/lambda/plugin.proto +++ b/builtin/aws/lambda/plugin.proto @@ -29,9 +29,17 @@ message Deployment { message Release { // The function's public url string url = 1; - string func_arn = 2; - string ver_arn = 3; - opaqueany.Any resource_state = 4; + + // The AWS region the function is deployed in + string region = 2; + + // The ARN for the Lambda function itself. + string func_arn = 3; + + // The ARN for the version of the Lambda function this deployment uses. + string ver_arn = 4; + + opaqueany.Any resource_state = 5; } // Resource contains the internal resource states. diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/releaser.go index a3be88fdb59..3766977be94 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/releaser.go @@ -4,7 +4,6 @@ import ( "context" "encoding/json" "fmt" - "net/http" "reflect" "strings" @@ -436,30 +435,33 @@ func (r *Releaser) Status( sg := ui.StepGroup() defer sg.Wait() - s := sg.Add("Gathering health report for lambda url deployment: %q", release.Url) + s := sg.Add("Gathering health report for lambda: %q", release.Url) defer s.Done() report := sdk.StatusReport{ External: true, } - // check the function url status - log.Info("Checking function url status...", "url", release.Url) - if resp, err := http.Get(release.Url); err != nil { - log.Error("Failed to get a response from the Lambda URL: %s", err) - report.Health = sdk.StatusReport_UNKNOWN - report.HealthMessage = "Failed to get a response from the Lambda URL" + sess, err := utils.GetSession(&utils.SessionConfig{ + Region: release.Region, + Logger: log, + }) + if err != nil { + return nil, err + } + + log.Info("Checking function status...", "url", release.Url) + lambdasrv := lambda.New(sess) + if err := lambdasrv.WaitUntilFunctionActiveV2(&lambda.GetFunctionInput{ + FunctionName: aws.String(release.FuncArn), + }); err != nil { + log.Error("Error waiting for function to become active", "error", err) + report.Health = sdk.StatusReport_DOWN + report.HealthMessage = "Failed to wait for function to become active" } else { - switch resp.StatusCode { - case http.StatusOK: - log.Info("Lambda URL returned a 200") - report.Health = sdk.StatusReport_READY - report.HealthMessage = "Lambda URL appears to be healthy" - default: - log.Error("Lambda URL returned a non-200 response: %d", resp.StatusCode) - report.Health = sdk.StatusReport_DOWN - report.HealthMessage = fmt.Sprintf("Lambda URL returned a non-200 response: %d", resp.StatusCode) - } + log.Info("Function is active") + report.Health = sdk.StatusReport_READY + report.HealthMessage = "Function is active" } return &report, nil @@ -494,6 +496,15 @@ release { docs.Default("NONE"), ) + doc.SetField( + "principal", + "the principal to use when auth_type is `AWS_IAM`", + docs.Summary( + "The Principal parameter specifies the principal that is allowed to invoke the function.", + ), + docs.Default("*"), + ) + // todo(thiskevinwang): CORS // doc.SetField( // "cors", From d4e09abe90a4e88a3b12f6c41897a2dbd9d9c906 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Sat, 16 Apr 2022 01:36:56 -0400 Subject: [PATCH 14/18] generate docs --- .../partials/components/releasemanager-aws-lambda.mdx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/website/content/partials/components/releasemanager-aws-lambda.mdx b/website/content/partials/components/releasemanager-aws-lambda.mdx index 46075aa1b39..d989e4a55ea 100644 --- a/website/content/partials/components/releasemanager-aws-lambda.mdx +++ b/website/content/partials/components/releasemanager-aws-lambda.mdx @@ -34,3 +34,13 @@ The AuthType parameter determines how Lambda authenticates or authorizes request - Type: **string** - **Optional** - Default: NONE + +#### principal + +The principal to use when auth_type is `AWS_IAM`. + +The Principal parameter specifies the principal that is allowed to invoke the function. + +- Type: **string** +- **Optional** +- Default: * From 00e106d07210cbdd33e4de332e16d9dbd6da5717 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Wed, 27 Apr 2022 23:42:31 -0400 Subject: [PATCH 15/18] feat: `lambda-function-url` plugin --- .changelog/3187.txt | 2 +- builtin/aws/lambda/function_url/plugin.go | 12 + builtin/aws/lambda/function_url/plugin.pb.go | 309 ++++++++++++++++++ builtin/aws/lambda/function_url/plugin.proto | 30 ++ .../aws/lambda/{ => function_url}/release.go | 2 +- .../aws/lambda/{ => function_url}/releaser.go | 10 +- builtin/aws/lambda/lambda.go | 1 - builtin/aws/lambda/plugin.pb.go | 269 ++------------- builtin/aws/lambda/plugin.proto | 25 -- internal/plugin/plugin.go | 2 + .../builder-lambda-function-url.mdx | 11 + .../configsourcer-lambda-function-url.mdx | 9 + .../platform-lambda-function-url.mdx | 11 + .../registry-lambda-function-url.mdx | 11 + .../components/releasemanager-aws-lambda.mdx | 37 +-- .../releasemanager-lambda-function-url.mdx | 46 +++ .../components/task-lambda-function-url.mdx | 11 + 17 files changed, 483 insertions(+), 315 deletions(-) create mode 100644 builtin/aws/lambda/function_url/plugin.go create mode 100644 builtin/aws/lambda/function_url/plugin.pb.go create mode 100644 builtin/aws/lambda/function_url/plugin.proto rename builtin/aws/lambda/{ => function_url}/release.go (87%) rename builtin/aws/lambda/{ => function_url}/releaser.go (98%) create mode 100644 website/content/partials/components/builder-lambda-function-url.mdx create mode 100644 website/content/partials/components/configsourcer-lambda-function-url.mdx create mode 100644 website/content/partials/components/platform-lambda-function-url.mdx create mode 100644 website/content/partials/components/registry-lambda-function-url.mdx create mode 100644 website/content/partials/components/releasemanager-lambda-function-url.mdx create mode 100644 website/content/partials/components/task-lambda-function-url.mdx diff --git a/.changelog/3187.txt b/.changelog/3187.txt index 4f4190d7080..e785ab757af 100644 --- a/.changelog/3187.txt +++ b/.changelog/3187.txt @@ -1,3 +1,3 @@ ```release-note:feature -plugin/aws-lambda: add `releaser` component. This leverages Lambda URLs. +plugin/lambda-function-url: Adds a new plugin and `releaser` component. This leverages Lambda URLs. ``` diff --git a/builtin/aws/lambda/function_url/plugin.go b/builtin/aws/lambda/function_url/plugin.go new file mode 100644 index 00000000000..8e307e09ece --- /dev/null +++ b/builtin/aws/lambda/function_url/plugin.go @@ -0,0 +1,12 @@ +package function_url + +import ( + sdk "github.com/hashicorp/waypoint-plugin-sdk" +) + +//go:generate protoc -I ../../../../.. -I ../../../../thirdparty/proto --go_out=../../../../.. waypoint/builtin/aws/lambda/function_url/plugin.proto + +// Options are the SDK options to use for instantiation for the plugin. +var Options = []sdk.Option{ + sdk.WithComponents(&Releaser{}), +} diff --git a/builtin/aws/lambda/function_url/plugin.pb.go b/builtin/aws/lambda/function_url/plugin.pb.go new file mode 100644 index 00000000000..c4b259b5f20 --- /dev/null +++ b/builtin/aws/lambda/function_url/plugin.pb.go @@ -0,0 +1,309 @@ +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.27.1 +// protoc v3.19.4 +// source: waypoint/builtin/aws/lambda/function_url/plugin.proto + +package function_url + +import ( + opaqueany "github.com/hashicorp/opaqueany" + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +type Release struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + // The function's public url + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` + // The AWS region the function is deployed in + Region string `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"` + // The ARN for the Lambda function itself. + FuncArn string `protobuf:"bytes,3,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` + // The ARN for the version of the Lambda function this deployment uses. + VerArn string `protobuf:"bytes,4,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` + ResourceState *opaqueany.Any `protobuf:"bytes,5,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` +} + +func (x *Release) Reset() { + *x = Release{} + if protoimpl.UnsafeEnabled { + mi := &file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Release) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Release) ProtoMessage() {} + +func (x *Release) ProtoReflect() protoreflect.Message { + mi := &file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Release.ProtoReflect.Descriptor instead. +func (*Release) Descriptor() ([]byte, []int) { + return file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescGZIP(), []int{0} +} + +func (x *Release) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +func (x *Release) GetRegion() string { + if x != nil { + return x.Region + } + return "" +} + +func (x *Release) GetFuncArn() string { + if x != nil { + return x.FuncArn + } + return "" +} + +func (x *Release) GetVerArn() string { + if x != nil { + return x.VerArn + } + return "" +} + +func (x *Release) GetResourceState() *opaqueany.Any { + if x != nil { + return x.ResourceState + } + return nil +} + +// Resource contains the internal resource states. +type Resource struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *Resource) Reset() { + *x = Resource{} + if protoimpl.UnsafeEnabled { + mi := &file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource) ProtoMessage() {} + +func (x *Resource) ProtoReflect() protoreflect.Message { + mi := &file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Resource.ProtoReflect.Descriptor instead. +func (*Resource) Descriptor() ([]byte, []int) { + return file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescGZIP(), []int{1} +} + +type Resource_FunctionUrl struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` +} + +func (x *Resource_FunctionUrl) Reset() { + *x = Resource_FunctionUrl{} + if protoimpl.UnsafeEnabled { + mi := &file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[2] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *Resource_FunctionUrl) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*Resource_FunctionUrl) ProtoMessage() {} + +func (x *Resource_FunctionUrl) ProtoReflect() protoreflect.Message { + mi := &file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[2] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use Resource_FunctionUrl.ProtoReflect.Descriptor instead. +func (*Resource_FunctionUrl) Descriptor() ([]byte, []int) { + return file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescGZIP(), []int{1, 0} +} + +func (x *Resource_FunctionUrl) GetUrl() string { + if x != nil { + return x.Url + } + return "" +} + +var File_waypoint_builtin_aws_lambda_function_url_plugin_proto protoreflect.FileDescriptor + +var file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDesc = []byte{ + 0x0a, 0x35, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, + 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x2f, 0x66, 0x75, + 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, + 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0c, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, + 0x6e, 0x5f, 0x75, 0x72, 0x6c, 0x1a, 0x13, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, + 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0x9e, 0x01, 0x0a, 0x07, 0x52, + 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, + 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, + 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, + 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, + 0x72, 0x41, 0x72, 0x6e, 0x12, 0x35, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, + 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, + 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, 0x65, + 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x2b, 0x0a, 0x08, 0x52, + 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, + 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, + 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x42, 0x2a, 0x5a, 0x28, 0x77, 0x61, 0x79, 0x70, + 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, + 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x2f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, + 0x5f, 0x75, 0x72, 0x6c, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescOnce sync.Once + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescData = file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDesc +) + +func file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescGZIP() []byte { + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescOnce.Do(func() { + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescData = protoimpl.X.CompressGZIP(file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescData) + }) + return file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDescData +} + +var file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 3) +var file_waypoint_builtin_aws_lambda_function_url_plugin_proto_goTypes = []interface{}{ + (*Release)(nil), // 0: function_url.Release + (*Resource)(nil), // 1: function_url.Resource + (*Resource_FunctionUrl)(nil), // 2: function_url.Resource.FunctionUrl + (*opaqueany.Any)(nil), // 3: opaqueany.Any +} +var file_waypoint_builtin_aws_lambda_function_url_plugin_proto_depIdxs = []int32{ + 3, // 0: function_url.Release.resource_state:type_name -> opaqueany.Any + 1, // [1:1] is the sub-list for method output_type + 1, // [1:1] is the sub-list for method input_type + 1, // [1:1] is the sub-list for extension type_name + 1, // [1:1] is the sub-list for extension extendee + 0, // [0:1] is the sub-list for field type_name +} + +func init() { file_waypoint_builtin_aws_lambda_function_url_plugin_proto_init() } +func file_waypoint_builtin_aws_lambda_function_url_plugin_proto_init() { + if File_waypoint_builtin_aws_lambda_function_url_plugin_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Release); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resource); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*Resource_FunctionUrl); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDesc, + NumEnums: 0, + NumMessages: 3, + NumExtensions: 0, + NumServices: 0, + }, + GoTypes: file_waypoint_builtin_aws_lambda_function_url_plugin_proto_goTypes, + DependencyIndexes: file_waypoint_builtin_aws_lambda_function_url_plugin_proto_depIdxs, + MessageInfos: file_waypoint_builtin_aws_lambda_function_url_plugin_proto_msgTypes, + }.Build() + File_waypoint_builtin_aws_lambda_function_url_plugin_proto = out.File + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_rawDesc = nil + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_goTypes = nil + file_waypoint_builtin_aws_lambda_function_url_plugin_proto_depIdxs = nil +} diff --git a/builtin/aws/lambda/function_url/plugin.proto b/builtin/aws/lambda/function_url/plugin.proto new file mode 100644 index 00000000000..a5093815549 --- /dev/null +++ b/builtin/aws/lambda/function_url/plugin.proto @@ -0,0 +1,30 @@ +syntax = "proto3"; + +package function_url; + +option go_package = "waypoint/builtin/aws/lambda/function_url"; + +import "opaqueany/any.proto"; + +message Release { + // The function's public url + string url = 1; + + // The AWS region the function is deployed in + string region = 2; + + // The ARN for the Lambda function itself. + string func_arn = 3; + + // The ARN for the version of the Lambda function this deployment uses. + string ver_arn = 4; + + opaqueany.Any resource_state = 5; + } + + // Resource contains the internal resource states. + message Resource { + message FunctionUrl { + string url = 1; + } + } \ No newline at end of file diff --git a/builtin/aws/lambda/release.go b/builtin/aws/lambda/function_url/release.go similarity index 87% rename from builtin/aws/lambda/release.go rename to builtin/aws/lambda/function_url/release.go index 8d3d3afc2a1..543f22025be 100644 --- a/builtin/aws/lambda/release.go +++ b/builtin/aws/lambda/function_url/release.go @@ -1,4 +1,4 @@ -package lambda +package function_url import "github.com/hashicorp/waypoint-plugin-sdk/component" diff --git a/builtin/aws/lambda/releaser.go b/builtin/aws/lambda/function_url/releaser.go similarity index 98% rename from builtin/aws/lambda/releaser.go rename to builtin/aws/lambda/function_url/releaser.go index 3766977be94..f074722289f 100644 --- a/builtin/aws/lambda/releaser.go +++ b/builtin/aws/lambda/function_url/releaser.go @@ -1,4 +1,4 @@ -package lambda +package function_url import ( "context" @@ -7,6 +7,8 @@ import ( "reflect" "strings" + lambdaplugin "github.com/hashicorp/waypoint/builtin/aws/lambda" + "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/awserr" "github.com/aws/aws-sdk-go/aws/session" @@ -133,7 +135,7 @@ func (r *Releaser) resourceFunctionPermissionCreate( sess *session.Session, sg terminal.StepGroup, ui terminal.UI, - dep *Deployment, + dep *lambdaplugin.Deployment, ) error { step := sg.Add("Checking function permission...") defer step.Abort() @@ -280,7 +282,7 @@ func (r *Releaser) resourceFunctionUrlCreate( sess *session.Session, sg terminal.StepGroup, ui terminal.UI, - dep *Deployment, + dep *lambdaplugin.Deployment, state *Resource_FunctionUrl, ) error { lambdasrv := lambda.New(sess) @@ -366,7 +368,7 @@ func (r *Releaser) Release( log hclog.Logger, src *component.Source, ui terminal.UI, - dep *Deployment, + dep *lambdaplugin.Deployment, ) (*Release, error) { sg := ui.StepGroup() defer sg.Wait() diff --git a/builtin/aws/lambda/lambda.go b/builtin/aws/lambda/lambda.go index 31f1ec88e74..20331b9eb04 100644 --- a/builtin/aws/lambda/lambda.go +++ b/builtin/aws/lambda/lambda.go @@ -11,5 +11,4 @@ import ( // the Google Cloud Run plugin. var Options = []sdk.Option{ sdk.WithComponents(&Platform{}), - sdk.WithComponents(&Releaser{}), } diff --git a/builtin/aws/lambda/plugin.pb.go b/builtin/aws/lambda/plugin.pb.go index 5847658b35a..20e2a68a58f 100644 --- a/builtin/aws/lambda/plugin.pb.go +++ b/builtin/aws/lambda/plugin.pb.go @@ -7,7 +7,6 @@ package lambda import ( - opaqueany "github.com/hashicorp/opaqueany" protoreflect "google.golang.org/protobuf/reflect/protoreflect" protoimpl "google.golang.org/protobuf/runtime/protoimpl" reflect "reflect" @@ -114,209 +113,26 @@ func (x *Deployment) GetVersion() string { return "" } -type Release struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - // The function's public url - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` - // The AWS region the function is deployed in - Region string `protobuf:"bytes,2,opt,name=region,proto3" json:"region,omitempty"` - // The ARN for the Lambda function itself. - FuncArn string `protobuf:"bytes,3,opt,name=func_arn,json=funcArn,proto3" json:"func_arn,omitempty"` - // The ARN for the version of the Lambda function this deployment uses. - VerArn string `protobuf:"bytes,4,opt,name=ver_arn,json=verArn,proto3" json:"ver_arn,omitempty"` - ResourceState *opaqueany.Any `protobuf:"bytes,5,opt,name=resource_state,json=resourceState,proto3" json:"resource_state,omitempty"` -} - -func (x *Release) Reset() { - *x = Release{} - if protoimpl.UnsafeEnabled { - mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Release) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Release) ProtoMessage() {} - -func (x *Release) ProtoReflect() protoreflect.Message { - mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Release.ProtoReflect.Descriptor instead. -func (*Release) Descriptor() ([]byte, []int) { - return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP(), []int{1} -} - -func (x *Release) GetUrl() string { - if x != nil { - return x.Url - } - return "" -} - -func (x *Release) GetRegion() string { - if x != nil { - return x.Region - } - return "" -} - -func (x *Release) GetFuncArn() string { - if x != nil { - return x.FuncArn - } - return "" -} - -func (x *Release) GetVerArn() string { - if x != nil { - return x.VerArn - } - return "" -} - -func (x *Release) GetResourceState() *opaqueany.Any { - if x != nil { - return x.ResourceState - } - return nil -} - -// Resource contains the internal resource states. -type Resource struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *Resource) Reset() { - *x = Resource{} - if protoimpl.UnsafeEnabled { - mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Resource) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Resource) ProtoMessage() {} - -func (x *Resource) ProtoReflect() protoreflect.Message { - mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Resource.ProtoReflect.Descriptor instead. -func (*Resource) Descriptor() ([]byte, []int) { - return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP(), []int{2} -} - -type Resource_FunctionUrl struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Url string `protobuf:"bytes,1,opt,name=url,proto3" json:"url,omitempty"` -} - -func (x *Resource_FunctionUrl) Reset() { - *x = Resource_FunctionUrl{} - if protoimpl.UnsafeEnabled { - mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *Resource_FunctionUrl) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*Resource_FunctionUrl) ProtoMessage() {} - -func (x *Resource_FunctionUrl) ProtoReflect() protoreflect.Message { - mi := &file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use Resource_FunctionUrl.ProtoReflect.Descriptor instead. -func (*Resource_FunctionUrl) Descriptor() ([]byte, []int) { - return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP(), []int{2, 0} -} - -func (x *Resource_FunctionUrl) GetUrl() string { - if x != nil { - return x.Url - } - return "" -} - var File_waypoint_builtin_aws_lambda_plugin_proto protoreflect.FileDescriptor var file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc = []byte{ 0x0a, 0x28, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x2f, 0x70, 0x6c, 0x75, 0x67, 0x69, 0x6e, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x61, 0x77, 0x73, 0x2e, - 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x1a, 0x13, 0x6f, 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, - 0x79, 0x2f, 0x61, 0x6e, 0x79, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22, 0xac, 0x01, 0x0a, 0x0a, - 0x44, 0x65, 0x70, 0x6c, 0x6f, 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, - 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, - 0x67, 0x69, 0x6f, 0x6e, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, - 0x6f, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, - 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, - 0x07, 0x76, 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, - 0x76, 0x65, 0x72, 0x41, 0x72, 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, - 0x5f, 0x67, 0x72, 0x6f, 0x75, 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, - 0x52, 0x0e, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, - 0x12, 0x18, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, - 0x09, 0x52, 0x07, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x22, 0x9e, 0x01, 0x0a, 0x07, 0x52, - 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, - 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, - 0x12, 0x19, 0x0a, 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x03, 0x20, 0x01, - 0x28, 0x09, 0x52, 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, - 0x65, 0x72, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, - 0x72, 0x41, 0x72, 0x6e, 0x12, 0x35, 0x0a, 0x0e, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, - 0x5f, 0x73, 0x74, 0x61, 0x74, 0x65, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x0e, 0x2e, 0x6f, - 0x70, 0x61, 0x71, 0x75, 0x65, 0x61, 0x6e, 0x79, 0x2e, 0x41, 0x6e, 0x79, 0x52, 0x0d, 0x72, 0x65, - 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x74, 0x61, 0x74, 0x65, 0x22, 0x2b, 0x0a, 0x08, 0x52, - 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x1a, 0x1f, 0x0a, 0x0b, 0x46, 0x75, 0x6e, 0x63, 0x74, - 0x69, 0x6f, 0x6e, 0x55, 0x72, 0x6c, 0x12, 0x10, 0x0a, 0x03, 0x75, 0x72, 0x6c, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x09, 0x52, 0x03, 0x75, 0x72, 0x6c, 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, - 0x6f, 0x69, 0x6e, 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, - 0x2f, 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x6c, 0x61, 0x6d, 0x62, 0x64, 0x61, 0x22, 0xac, 0x01, 0x0a, 0x0a, 0x44, 0x65, 0x70, 0x6c, 0x6f, + 0x79, 0x6d, 0x65, 0x6e, 0x74, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, + 0x09, 0x52, 0x02, 0x69, 0x64, 0x12, 0x16, 0x0a, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x18, + 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x72, 0x65, 0x67, 0x69, 0x6f, 0x6e, 0x12, 0x19, 0x0a, + 0x08, 0x66, 0x75, 0x6e, 0x63, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x66, 0x75, 0x6e, 0x63, 0x41, 0x72, 0x6e, 0x12, 0x17, 0x0a, 0x07, 0x76, 0x65, 0x72, 0x5f, + 0x61, 0x72, 0x6e, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x76, 0x65, 0x72, 0x41, 0x72, + 0x6e, 0x12, 0x28, 0x0a, 0x10, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x67, 0x72, 0x6f, 0x75, + 0x70, 0x5f, 0x61, 0x72, 0x6e, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0e, 0x74, 0x61, 0x72, + 0x67, 0x65, 0x74, 0x47, 0x72, 0x6f, 0x75, 0x70, 0x41, 0x72, 0x6e, 0x12, 0x18, 0x0a, 0x07, 0x76, + 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x18, 0x07, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x76, 0x65, + 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x42, 0x1d, 0x5a, 0x1b, 0x77, 0x61, 0x79, 0x70, 0x6f, 0x69, 0x6e, + 0x74, 0x2f, 0x62, 0x75, 0x69, 0x6c, 0x74, 0x69, 0x6e, 0x2f, 0x61, 0x77, 0x73, 0x2f, 0x6c, 0x61, + 0x6d, 0x62, 0x64, 0x61, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -331,21 +147,16 @@ func file_waypoint_builtin_aws_lambda_plugin_proto_rawDescGZIP() []byte { return file_waypoint_builtin_aws_lambda_plugin_proto_rawDescData } -var file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 4) +var file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes = make([]protoimpl.MessageInfo, 1) var file_waypoint_builtin_aws_lambda_plugin_proto_goTypes = []interface{}{ - (*Deployment)(nil), // 0: aws.lambda.Deployment - (*Release)(nil), // 1: aws.lambda.Release - (*Resource)(nil), // 2: aws.lambda.Resource - (*Resource_FunctionUrl)(nil), // 3: aws.lambda.Resource.FunctionUrl - (*opaqueany.Any)(nil), // 4: opaqueany.Any + (*Deployment)(nil), // 0: aws.lambda.Deployment } var file_waypoint_builtin_aws_lambda_plugin_proto_depIdxs = []int32{ - 4, // 0: aws.lambda.Release.resource_state:type_name -> opaqueany.Any - 1, // [1:1] is the sub-list for method output_type - 1, // [1:1] is the sub-list for method input_type - 1, // [1:1] is the sub-list for extension type_name - 1, // [1:1] is the sub-list for extension extendee - 0, // [0:1] is the sub-list for field type_name + 0, // [0:0] is the sub-list for method output_type + 0, // [0:0] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name } func init() { file_waypoint_builtin_aws_lambda_plugin_proto_init() } @@ -366,42 +177,6 @@ func file_waypoint_builtin_aws_lambda_plugin_proto_init() { return nil } } - file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Release); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Resource); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_waypoint_builtin_aws_lambda_plugin_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*Resource_FunctionUrl); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } } type x struct{} out := protoimpl.TypeBuilder{ @@ -409,7 +184,7 @@ func file_waypoint_builtin_aws_lambda_plugin_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_waypoint_builtin_aws_lambda_plugin_proto_rawDesc, NumEnums: 0, - NumMessages: 4, + NumMessages: 1, NumExtensions: 0, NumServices: 0, }, diff --git a/builtin/aws/lambda/plugin.proto b/builtin/aws/lambda/plugin.proto index 87e5d377b1c..1f7588e6e14 100644 --- a/builtin/aws/lambda/plugin.proto +++ b/builtin/aws/lambda/plugin.proto @@ -4,8 +4,6 @@ package aws.lambda; option go_package = "waypoint/builtin/aws/lambda"; -import "opaqueany/any.proto"; - message Deployment { // Identifier for the deployment, required by Waypoint string id = 1; @@ -24,27 +22,4 @@ message Deployment { // The version identifier AWS uses for this version (basically a serial increasing number) string version = 7; -} - -message Release { - // The function's public url - string url = 1; - - // The AWS region the function is deployed in - string region = 2; - - // The ARN for the Lambda function itself. - string func_arn = 3; - - // The ARN for the version of the Lambda function this deployment uses. - string ver_arn = 4; - - opaqueany.Any resource_state = 5; -} - -// Resource contains the internal resource states. -message Resource { - message FunctionUrl { - string url = 1; - } } \ No newline at end of file diff --git a/internal/plugin/plugin.go b/internal/plugin/plugin.go index b7cea577e81..e97dc3f01b6 100644 --- a/internal/plugin/plugin.go +++ b/internal/plugin/plugin.go @@ -11,6 +11,7 @@ import ( "github.com/hashicorp/waypoint/builtin/aws/ecr" "github.com/hashicorp/waypoint/builtin/aws/ecs" "github.com/hashicorp/waypoint/builtin/aws/lambda" + lambdaFunctionUrl "github.com/hashicorp/waypoint/builtin/aws/lambda/function_url" "github.com/hashicorp/waypoint/builtin/aws/ssm" "github.com/hashicorp/waypoint/builtin/azure/aci" "github.com/hashicorp/waypoint/builtin/docker" @@ -53,6 +54,7 @@ var ( "aws-alb": alb.Options, "aws-ssm": ssm.Options, "aws-lambda": lambda.Options, + "lambda-function-url": lambdaFunctionUrl.Options, "vault": vault.Options, "terraform-cloud": tfc.Options, "null": null.Options, diff --git a/website/content/partials/components/builder-lambda-function-url.mdx b/website/content/partials/components/builder-lambda-function-url.mdx new file mode 100644 index 00000000000..974321aee0e --- /dev/null +++ b/website/content/partials/components/builder-lambda-function-url.mdx @@ -0,0 +1,11 @@ +## lambda-function-url (builder) + +### Interface + +### Required Parameters + +This plugin has no required parameters. + +### Optional Parameters + +This plugin has no optional parameters. diff --git a/website/content/partials/components/configsourcer-lambda-function-url.mdx b/website/content/partials/components/configsourcer-lambda-function-url.mdx new file mode 100644 index 00000000000..e6da3da53af --- /dev/null +++ b/website/content/partials/components/configsourcer-lambda-function-url.mdx @@ -0,0 +1,9 @@ +## lambda-function-url (configsourcer) + +### Required Parameters + +This plugin has no required parameters. + +### Optional Parameters + +This plugin has no optional parameters. diff --git a/website/content/partials/components/platform-lambda-function-url.mdx b/website/content/partials/components/platform-lambda-function-url.mdx new file mode 100644 index 00000000000..45776d959f1 --- /dev/null +++ b/website/content/partials/components/platform-lambda-function-url.mdx @@ -0,0 +1,11 @@ +## lambda-function-url (platform) + +### Interface + +### Required Parameters + +This plugin has no required parameters. + +### Optional Parameters + +This plugin has no optional parameters. diff --git a/website/content/partials/components/registry-lambda-function-url.mdx b/website/content/partials/components/registry-lambda-function-url.mdx new file mode 100644 index 00000000000..ba329a9d37f --- /dev/null +++ b/website/content/partials/components/registry-lambda-function-url.mdx @@ -0,0 +1,11 @@ +## lambda-function-url (registry) + +### Interface + +### Required Parameters + +This plugin has no required parameters. + +### Optional Parameters + +This plugin has no optional parameters. diff --git a/website/content/partials/components/releasemanager-aws-lambda.mdx b/website/content/partials/components/releasemanager-aws-lambda.mdx index d989e4a55ea..2d3dd833e04 100644 --- a/website/content/partials/components/releasemanager-aws-lambda.mdx +++ b/website/content/partials/components/releasemanager-aws-lambda.mdx @@ -1,46 +1,11 @@ ## aws-lambda (releasemanager) -Create an AWS Lambda function URL. - ### Interface -- Input: **lambda.Deployment** -- Output: **lambda.Release** - -### Examples - -```hcl -release { - use "aws-lambda" { - auth_type = "NONE" - } -} -``` - ### Required Parameters This plugin has no required parameters. ### Optional Parameters -These parameters are used in the [`use` stanza](/docs/waypoint-hcl/use) for this plugin. - -#### auth_type - -The Lambda function URL auth type. - -The AuthType parameter determines how Lambda authenticates or authorizes requests to your function URL. Must be either `AWS_IAM` or `NONE`. - -- Type: **string** -- **Optional** -- Default: NONE - -#### principal - -The principal to use when auth_type is `AWS_IAM`. - -The Principal parameter specifies the principal that is allowed to invoke the function. - -- Type: **string** -- **Optional** -- Default: * +This plugin has no optional parameters. diff --git a/website/content/partials/components/releasemanager-lambda-function-url.mdx b/website/content/partials/components/releasemanager-lambda-function-url.mdx new file mode 100644 index 00000000000..c07074dfc3e --- /dev/null +++ b/website/content/partials/components/releasemanager-lambda-function-url.mdx @@ -0,0 +1,46 @@ +## lambda-function-url (releasemanager) + +Create an AWS Lambda function URL. + +### Interface + +- Input: **lambda.Deployment** +- Output: **lambda.Release** + +### Examples + +```hcl +release { + use "aws-lambda" { + auth_type = "NONE" + } +} +``` + +### Required Parameters + +This plugin has no required parameters. + +### Optional Parameters + +These parameters are used in the [`use` stanza](/docs/waypoint-hcl/use) for this plugin. + +#### auth_type + +The Lambda function URL auth type. + +The AuthType parameter determines how Lambda authenticates or authorizes requests to your function URL. Must be either `AWS_IAM` or `NONE`. + +- Type: **string** +- **Optional** +- Default: NONE + +#### principal + +The principal to use when auth_type is `AWS_IAM`. + +The Principal parameter specifies the principal that is allowed to invoke the function. + +- Type: **string** +- **Optional** +- Default: * diff --git a/website/content/partials/components/task-lambda-function-url.mdx b/website/content/partials/components/task-lambda-function-url.mdx new file mode 100644 index 00000000000..3222193975c --- /dev/null +++ b/website/content/partials/components/task-lambda-function-url.mdx @@ -0,0 +1,11 @@ +## lambda-function-url (task) + +### Interface + +### Required Parameters + +This plugin has no required parameters. + +### Optional Parameters + +This plugin has no optional parameters. From c9cc1c1a529cee58a3203853ae4317527969b8d3 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Thu, 28 Apr 2022 10:23:42 -0400 Subject: [PATCH 16/18] chore: fix doc --- builtin/aws/lambda/function_url/releaser.go | 2 +- .../partials/components/releasemanager-lambda-function-url.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/aws/lambda/function_url/releaser.go b/builtin/aws/lambda/function_url/releaser.go index f074722289f..69db3ff33df 100644 --- a/builtin/aws/lambda/function_url/releaser.go +++ b/builtin/aws/lambda/function_url/releaser.go @@ -480,7 +480,7 @@ func (r *Releaser) Documentation() (*docs.Documentation, error) { doc.Example( ` release { - use "aws-lambda" { + use "lambda-function-url" { auth_type = "NONE" } } diff --git a/website/content/partials/components/releasemanager-lambda-function-url.mdx b/website/content/partials/components/releasemanager-lambda-function-url.mdx index c07074dfc3e..6e2ff1c4699 100644 --- a/website/content/partials/components/releasemanager-lambda-function-url.mdx +++ b/website/content/partials/components/releasemanager-lambda-function-url.mdx @@ -11,7 +11,7 @@ Create an AWS Lambda function URL. ```hcl release { - use "aws-lambda" { + use "lambda-function-url" { auth_type = "NONE" } } From 4e2e2a9e50f2eb6f49d67d247b3d408c9e7ba765 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Wed, 4 May 2022 18:03:12 -0400 Subject: [PATCH 17/18] chore: code and comment cleanup --- builtin/aws/lambda/function_url/releaser.go | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/builtin/aws/lambda/function_url/releaser.go b/builtin/aws/lambda/function_url/releaser.go index 69db3ff33df..6e5b7b8d1a5 100644 --- a/builtin/aws/lambda/function_url/releaser.go +++ b/builtin/aws/lambda/function_url/releaser.go @@ -200,7 +200,6 @@ func (r *Releaser) resourceFunctionPermissionCreate( reset = true } case reflect.TypeOf(map[string]interface{}{}): - fmt.Println("3") if st.Principal.(map[string]interface{})["AWS"].(string) != principal { // principal has changed, we should update permissions reset = true @@ -292,7 +291,6 @@ func (r *Releaser) resourceFunctionUrlCreate( functionUrlAuthType = strings.ToUpper(r.config.AuthType) } - // TODO(thiskevinwang): source cors from HCL config cors := lambda.Cors{} step := sg.Add("Creating Lambda URL...") @@ -301,8 +299,7 @@ func (r *Releaser) resourceFunctionUrlCreate( createFunctionUrlConfigInput := lambda.CreateFunctionUrlConfigInput{ AuthType: aws.String(functionUrlAuthType), FunctionName: aws.String(dep.FuncArn), - // TODO(thiskevinwang): make Cors configurable via HCL - Cors: &cors, + Cors: &cors, } // Create or Update the lambda URL @@ -425,7 +422,6 @@ type ReleaserConfig struct { AuthType string `hcl:"auth_type,optional"` // Only permitted if AuthType is "AWS_IAM" otherwise defaults to "*" Principal string `hcl:"principal,optional"` - // todo(kevinwang): CORS } func (r *Releaser) Status( @@ -507,16 +503,6 @@ release { docs.Default("*"), ) - // todo(thiskevinwang): CORS - // doc.SetField( - // "cors", - // "the CORS configuration for the Lambda function URL", - // docs.Summary( - // "Use CORS to allow access to your function URL from any domain. You can also use CORS to control access for specific HTTP headers and methods in requests to your function URL", - // ), - // docs.Default("{}"), - // ) - return doc, nil } From a7ec5d81abcfc5194c2ea547141dde331d243920 Mon Sep 17 00:00:00 2001 From: Kevin Wang Date: Thu, 5 May 2022 19:06:34 -0400 Subject: [PATCH 18/18] gen/website-mdx + npm run format --- website/README.md | 1 - .../releasemanager-lambda-function-url.mdx | 2 +- website/package-lock.json | 92 ++++++++++++++----- 3 files changed, 70 insertions(+), 25 deletions(-) diff --git a/website/README.md b/website/README.md index 2b626210ec5..495c24eccd5 100644 --- a/website/README.md +++ b/website/README.md @@ -60,7 +60,6 @@ This file can be standard Markdown and also supports [YAML frontmatter](https:// title: 'My Title' description: "A thorough, yet succinct description of the page's contents" --- - ``` The significant keys in the YAML frontmatter are: diff --git a/website/content/partials/components/releasemanager-lambda-function-url.mdx b/website/content/partials/components/releasemanager-lambda-function-url.mdx index 6e2ff1c4699..e403cd0aa75 100644 --- a/website/content/partials/components/releasemanager-lambda-function-url.mdx +++ b/website/content/partials/components/releasemanager-lambda-function-url.mdx @@ -43,4 +43,4 @@ The Principal parameter specifies the principal that is allowed to invoke the fu - Type: **string** - **Optional** -- Default: * +- Default: \* diff --git a/website/package-lock.json b/website/package-lock.json index 2d07ba5f1ed..005214c1aff 100644 --- a/website/package-lock.json +++ b/website/package-lock.json @@ -1255,10 +1255,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-android-arm64/-/swc-android-arm64-12.1.0.tgz", "integrity": "sha512-/280MLdZe0W03stA69iL+v6I+J1ascrQ6FrXBlXGCsGzrfMaGr7fskMa0T5AhQIVQD4nA/46QQWxG//DYuFBcA==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["android"], + "os": [ + "android" + ], "engines": { "node": ">= 10" } @@ -1267,10 +1271,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-darwin-arm64/-/swc-darwin-arm64-12.1.0.tgz", "integrity": "sha512-R8vcXE2/iONJ1Unf5Ptqjk6LRW3bggH+8drNkkzH4FLEQkHtELhvcmJwkXcuipyQCsIakldAXhRbZmm3YN1vXg==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -1279,10 +1287,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-darwin-x64/-/swc-darwin-x64-12.1.0.tgz", "integrity": "sha512-ieAz0/J0PhmbZBB8+EA/JGdhRHBogF8BWaeqR7hwveb6SYEIJaDNQy0I+ZN8gF8hLj63bEDxJAs/cEhdnTq+ug==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "engines": { "node": ">= 10" } @@ -1291,10 +1303,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm-gnueabihf/-/swc-linux-arm-gnueabihf-12.1.0.tgz", "integrity": "sha512-njUd9hpl6o6A5d08dC0cKAgXKCzm5fFtgGe6i0eko8IAdtAPbtHxtpre3VeSxdZvuGFh+hb0REySQP9T1ttkog==", - "cpu": ["arm"], + "cpu": [ + "arm" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -1303,10 +1319,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-gnu/-/swc-linux-arm64-gnu-12.1.0.tgz", "integrity": "sha512-OqangJLkRxVxMhDtcb7Qn1xjzFA3s50EIxY7mljbSCLybU+sByPaWAHY4px97ieOlr2y4S0xdPKkQ3BCAwyo6Q==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -1315,10 +1335,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-linux-arm64-musl/-/swc-linux-arm64-musl-12.1.0.tgz", "integrity": "sha512-hB8cLSt4GdmOpcwRe2UzI5UWn6HHO/vLkr5OTuNvCJ5xGDwpPXelVkYW/0+C3g5axbDW2Tym4S+MQCkkH9QfWA==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -1327,10 +1351,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-gnu/-/swc-linux-x64-gnu-12.1.0.tgz", "integrity": "sha512-OKO4R/digvrVuweSw/uBM4nSdyzsBV5EwkUeeG4KVpkIZEe64ZwRpnFB65bC6hGwxIBnTv5NMSnJ+0K/WmG78A==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -1339,10 +1367,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-linux-x64-musl/-/swc-linux-x64-musl-12.1.0.tgz", "integrity": "sha512-JohhgAHZvOD3rQY7tlp7NlmvtvYHBYgY0x5ZCecUT6eCCcl9lv6iV3nfu82ErkxNk1H893fqH0FUpznZ/H3pSw==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["linux"], + "os": [ + "linux" + ], "engines": { "node": ">= 10" } @@ -1351,10 +1383,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-win32-arm64-msvc/-/swc-win32-arm64-msvc-12.1.0.tgz", "integrity": "sha512-T/3gIE6QEfKIJ4dmJk75v9hhNiYZhQYAoYm4iVo1TgcsuaKLFa+zMPh4056AHiG6n9tn2UQ1CFE8EoybEsqsSw==", - "cpu": ["arm64"], + "cpu": [ + "arm64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">= 10" } @@ -1363,10 +1399,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-win32-ia32-msvc/-/swc-win32-ia32-msvc-12.1.0.tgz", "integrity": "sha512-iwnKgHJdqhIW19H9PRPM9j55V6RdcOo6rX+5imx832BCWzkDbyomWnlzBfr6ByUYfhohb8QuH4hSGEikpPqI0Q==", - "cpu": ["ia32"], + "cpu": [ + "ia32" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">= 10" } @@ -1375,10 +1415,14 @@ "version": "12.1.0", "resolved": "https://registry.npmjs.org/@next/swc-win32-x64-msvc/-/swc-win32-x64-msvc-12.1.0.tgz", "integrity": "sha512-aBvcbMwuanDH4EMrL2TthNJy+4nP59Bimn8egqv6GHMVj0a44cU6Au4PjOhLNqEh9l+IpRGBqMTzec94UdC5xg==", - "cpu": ["x64"], + "cpu": [ + "x64" + ], "dev": true, "optional": true, - "os": ["win32"], + "os": [ + "win32" + ], "engines": { "node": ">= 10" } @@ -4842,7 +4886,9 @@ "dev": true, "hasInstallScript": true, "optional": true, - "os": ["darwin"], + "os": [ + "darwin" + ], "peer": true, "engines": { "node": "^8.16.0 || ^10.6.0 || >=11.0.0"